import threading
from Setup import *
-from PhysicsBody import PhysicsBody
+# from PhysicsBody import PhysicsBody
from Block import Block
self.stun_time = max(self.stun_time, 0)
self.invincibility_frames -= delta
self.invincibility_frames = max(self.invincibility_frames, 0)
- if self.invincibility_frames == 0:
+ if self.invincibility_frames == 0 and self.on_ground:
self.attacked = False
for area in self.areas.values():
self.stun_time = -amount * 10
self.is_dead(reason)
- def attack(self, enemy, weapon):
- self.modify_health(weapon.damage, "enemy")
- self.push(enemy)
- self.attacked = True
- self.invincibility_frames = self.invincibility_time
+ def attack(self, enemy, weapon, direction):
+ if not self.attacked:
+ self.push(direction, 2, -1)
+ self.modify_health(weapon.damage, "enemy")
+ self.attacked = True
+ self.invincibility_frames = self.invincibility_time
- def follow_target(self, node, follow_range=None, stop_dist=None):
- if stop_dist is None:
- stop_dist = max(self.height, self.width) * 1.5
+ def follow_target(self, node, follow_range=100000, stop_dist=115):
+ # if stop_dist is None:
+ # stop_dist = max(self.height, self.width) * 1.5
target = node.position
# So that actor doesn't come up and hug u lol
- if (self.position - target).length_squared() < pow(stop_dist, 2):
+ distance_between = ((self.position+pg.Vector2(self.width,self.height)/2) - (target+pg.Vector2(node.width,node.height)/2)).length_squared()
+
+ if abs(self.position.x - target.x) < stop_dist:
+ self.velocity.x = 0
+ return
+ if distance_between > follow_range ** 2:
return
- if target.x < self.position.x:
+ if target.x + node.width < self.position.x:
self.move_left()
elif target.x > self.position.x:
self.move_right()
- if target.y < self.position.y:
+ if not (target.y - node.height/2< self.position.y < target.y + node.height/2):
self.jump()
def jump(self):
def dash_right(self):
pass
- def move_left(self, customSpeed=speed):
+ def move_left(self, customSpeed=None):
+ if customSpeed is None:
+ customSpeed = self.speed
if self.stun_time == 0:
self.velocity.x = -customSpeed
- def move_right(self, customSpeed=speed):
+ def move_right(self, customSpeed=None):
+ if customSpeed is None:
+ customSpeed = self.speed
if self.stun_time == 0:
self.velocity.x = customSpeed
- def push(self, enemy):
- v = enemy.weapon.direction
- # if enemy.velocity.x != pg.Vector2(0,0):
- # v = enemy.velocity.normalize().x
-
- self.velocity += pg.Vector2(v, -1)
-
- def push2(self, direction):
- self.velocity += pg.Vector2(direction, -1)
+ def push(self, direction, strength=1, y=-1):
+ self.velocity += pg.Vector2(direction * strength, y)
def move_and_collide(self, pos, vel, delta):
pos.x += vel.x * delta
if thing == self:
continue
if collision_rect.colliderect(thing.get_collision_rect()):
- if thing.movable:
- if vel.x > 0:
- thing.position.x = pos.x + self.width
- elif vel.x < 0:
- thing.position.x = pos.x - thing.width
+ # if thing.movable:
+ # if vel.x > 0:
+ # thing.position.x = pos.x + self.width
+ # elif vel.x < 0:
+ # thing.position.x = pos.x - thing.width
if vel.x > 0:
pos.x = thing.position.x - self.width
# vel.x = min(vel.x, 0)
self.coyote_time = datetime.utcnow()
elif vel.y < 0:
pos.y = thing.position.y + thing.height
- vel.y = max(vel.y, 0)
+ # vel.y = max(vel.y, 0)
# collision_rect = self.get_collision_rect(pos)
return pos, vel
from Actors import Actor
from Weapon import Melee
+
class Enemy(Actor):
width, height = 50, 100
speed = Actor.speed * 0.5
- jump_strength = Actor.jump_strength * 0.5
+ # jump_strength = Actor.jump_strength * 0.5
colour = (235, 64, 52)
-
+ friction = 0.9
def __init__(self, pos, collision_layer, collision_mask):
super().__init__(pos, collision_layer, collision_mask)
- self.areas = {"head":Area(self.position,pg.Vector2(self.width * 1/3 * 1/2,-2), self.width * 2/3, 25, Player, self.knockout)}
- self.movable = True
+ self.areas = {
+ "head": Area(self.position, pg.Vector2(self.width * 1 / 3 * 1 / 2, -2), self.width * 2 / 3, 25, Player,
+ self.knockout)}
+ self.movable = False
self.dizzy_time = 0
- # self.health = 0 # for debugging without getting killed
+ self.direction = -1
- self.weapon = Melee(self.position, (-Melee.width/2 + 7, Melee.height/2 + self.height/3 - 8), (-5,Melee.height), self.width,-1, -10)
+ # self.health = 0 # for debugging without getting killed
+ self.weapon = Melee(self.position, (-Melee.width / 2 + 7, Melee.height / 2 + self.height / 3 - 8),
+ (-5, Melee.height), self.width, -1, -10)
def update(self, delta, target=None):
super().update(delta)
- if target is not None and self.dizzy_time == 0:
- self.follow_target(target,stop_dist=self.weapon.width * 0.99)
- if random.random() < 4.5/fps and not self.weapon.attacking and self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
- self.weapon.swing()
- target.attack(self, self.weapon)
+ if not self.attacked and target is not None and self.dizzy_time == 0:
+ self.follow_target(target)
+ if random.random() < 2/fps and not self.weapon.attacking and self.weapon.get_collision_rect().colliderect(target.get_collision_rect()):
+ target.attack(self, self.weapon, self.direction)
+ print('attack')
self.dizzy_time -= delta
- self.dizzy_time = max(0,self.dizzy_time)
-
+ self.dizzy_time = max(0, self.dizzy_time)
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
if self.velocity.x == 0:
- direction = 0
+ self.direction = 0
else:
- direction = math.copysign(1,self.velocity.x)
- self.weapon.update(delta,self.position, direction)
+ self.direction = math.copysign(1, self.velocity.x)
+ self.weapon.update(delta, self.position, self.direction)
+
+ # print(self.velocity)
def knockout(self, node):
self.dizzy_time = 100
self.modify_health(-25, None)
- node.push2(math.copysign(1,self.velocity.x))
+ node.on_ground = False
+ node.push(math.copysign(1, node.velocity.x), 0.25, -2.25)
# self.crouch(1000)
def draw(self, surf):
self.weapon.draw(surf)
super(Enemy, self).draw(surf)
+ pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2)
# self.pet.update(delta, self.player, self.camera_pos)
def draw(self, surf):
- screen.fill((0, 191, 255))
-
+ # screen.fill((0, 191, 255))
+ # screen.fill((255,255,255))
+ sky = pg.image.load("Assets/world/SKY.png")
+ surf.blit(sky,(0,0))
self.Transition.draw(surf, self.player.position, [40, -250], 120, 625)
- # screen.fill((255,255,255))
- # sky = pg.image.load("Assets/world/SKY.png")
- # surf.blit(sky,(0,0))
+
self.world.draw(surf)
for enemy in self.enemies:
enemy.draw(surf)
--- /dev/null
+none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|none|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world|world
+1150.0,0.0|1100.0,0.0|1100.0,50.0|1150.0,50.0|1150.0,100.0|1100.0,100.0|1100.0,150.0|1150.0,150.0|1150.0,200.0|1150.0,300.0|1150.0,250.0|1100.0,200.0|1100.0,250.0|1100.0,300.0|1100.0,550.0|1100.0,500.0|1100.0,450.0|1100.0,400.0|1100.0,350.0|1150.0,350.0|1150.0,400.0|1150.0,450.0|1150.0,500.0|1150.0,550.0|1150.0,600.0|1150.0,700.0|1150.0,650.0|1100.0,600.0|1100.0,650.0|1100.0,700.0|150.0,650.0|300.0,650.0|550.0,650.0|800.0,650.0|1000.0,850.0|1150.0,750.0|1100.0,750.0|1100.0,800.0|1150.0,800.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1050.0,800.0|1000.0,800.0|950.0,800.0|950.0,850.0|900.0,850.0|900.0,800.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|600.0,800.0|550.0,800.0|500.0,800.0|450.0,800.0|400.0,800.0|350.0,800.0|300.0,800.0|250.0,800.0|200.0,800.0|150.0,800.0|100.0,800.0|50.0,800.0|0.0,800.0|0.0,850.0|50.0,850.0|100.0,850.0|150.0,850.0|200.0,850.0|250.0,850.0|300.0,850.0|350.0,850.0|400.0,850.0|450.0,850.0|500.0,850.0|550.0,850.0|600.0,850.0|650.0,850.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|0.0,700.0|1000.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,500.0|0.0,450.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,0.0|0.0,50.0|0.0,100.0|0.0,150.0|50.0,0.0|100.0,0.0|150.0,0.0|200.0,0.0|250.0,0.0|300.0,0.0|350.0,0.0|400.0,0.0|450.0,0.0|500.0,0.0|550.0,0.0|600.0,0.0|650.0,0.0|700.0,0.0|750.0,0.0|800.0,0.0|850.0,0.0|900.0,0.0|950.0,0.0|1000.0,0.0|1000.0,50.0|1000.0,100.0|1000.0,150.0|1000.0,200.0|1000.0,250.0|1000.0,300.0|1000.0,350.0|1000.0,400.0|1000.0,450.0|1000.0,500.0|1000.0,550.0|1000.0,600.0|1000.0,650.0|1050.0,0.0|1050.0,50.0|1050.0,100.0|1050.0,150.0|1050.0,200.0|1050.0,250.0|1050.0,300.0|1050.0,350.0|1050.0,400.0|1050.0,450.0|1050.0,500.0|1050.0,550.0|1050.0,600.0|1050.0,650.0|1050.0,700.0|0.0,750.0|1050.0,750.0|1000.0,750.0|950.0,700.0|900.0,700.0|850.0,700.0|800.0,700.0|750.0,700.0|700.0,700.0|650.0,700.0|600.0,700.0|550.0,700.0|500.0,700.0|450.0,700.0|400.0,700.0|350.0,700.0|300.0,700.0|250.0,700.0|200.0,700.0|150.0,700.0|100.0,700.0|50.0,700.0|50.0,750.0|100.0,750.0|150.0,750.0|200.0,750.0|250.0,750.0|300.0,750.0|350.0,750.0|400.0,750.0|450.0,750.0|500.0,750.0|550.0,750.0|600.0,750.0|650.0,750.0|700.0,750.0|750.0,750.0|800.0,750.0|850.0,750.0|900.0,750.0|950.0,750.0
+PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLAYER|ENEMY|ENEMY|ENEMY|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER
+
+
+
+
+
+
+
+
+
+
+
+
from Setup import *
from Block import Block
from Function.createText import createText
+from Actors import Actor
+
class PhysicsBody:
- speed = 0.2
- jump_strength = 1
- gravity = 0.098
- friction = 0.9
+ gravity = Actor.gravity
+ friction = Actor.friction
invincibility_time = 150
def __init__(self, pos, vel, width, height, colour, collision_layer, collision_mask):
self.dead = False
- self.movable =True
+ self.movable = True
self.attacked = False
self.invincibility_frames = 0
self.collision_layer = collision_layer
self.collision_mask = collision_mask # the layer the actor detects collisions against
- def update(self, delta, test=None):
- self.invincibility_frames -= delta
- self.invincibility_frames = max(self.invincibility_frames, 0)
- if self.invincibility_frames == 0:
- self.attacked = False
- # Apply friction so the enemy isn't walking on ice
+ def update(self, delta, test=None, test2=None):
if self.on_ground:
self.velocity.x *= self.friction
- # Apply gravity
self.velocity.y += self.gravity
+
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
- # print(self.position)
- def attack(self, enemy, weapon):
- self.push(enemy)
+
+ if self.on_ground:
+ self.attacked = False
+
+ def attack(self, enemy, weapon, direction):
+ self.push(direction, 2, -1)
self.attacked = True
self.invincibility_frames = self.invincibility_time
- def push(self, enemy):
- v = enemy.weapon.direction
- # if enemy.velocity.x != pg.Vector2(0,0):
- # v = enemy.velocity.normalize().x
+ def push(self, direction, strength=1, y=-1):
+ self.velocity += pg.Vector2(direction * strength, y)
- self.velocity += pg.Vector2(0.5 * v, -1)
def move_and_collide(self, pos, vel, delta):
pos.x += vel.x * delta
collision_rect = self.get_collision_rect(pos)
if thing == self:
continue
if collision_rect.colliderect(thing.get_collision_rect()):
- if thing.movable:
- if vel.x > 0:
- thing.position.x = pos.x + self.width
- elif vel.x < 0:
- thing.position.x = pos.x - thing.width
+ # if thing.movable:
+ # if vel.x > 0:
+ # thing.position.x = pos.x + self.width
+ # elif vel.x < 0:
+ # thing.position.x = pos.x - thing.width
if vel.x > 0:
pos.x = thing.position.x - self.width
- vel.x = min(vel.x, 0)
+ # vel.x = min(vel.x, 0)
elif vel.x < 0:
pos.x = thing.position.x + thing.width
- vel.x = max(vel.x, 0)
+ # vel.x = max(vel.x, 0)
collision_rect = self.get_collision_rect(pos)
+
self.on_ground = False
pos.y += vel.y * delta
collision_rect = self.get_collision_rect(pos)
self.on_ground = True
elif vel.y < 0:
pos.y = thing.position.y + thing.height
- vel.y = max(vel.y, 0)
- collision_rect = self.get_collision_rect(pos)
+ # vel.y = max(vel.y, 0)
+ # collision_rect = self.get_collision_rect(pos)
return pos, vel
def get_collision_rect(self, pos=None):
def draw(self, surf):
# print(self.position, self.velocity)
pg.draw.rect(surf, self.colour, get_display_rect(self.get_collision_rect()), border_radius=8)
-
import pygame.key
+import Setup
from Setup import *
import time
from Actors import Actor
attack_gif = Image.open("Assets/player/Sword_Slash.gif")
attack_frames = []
for i in range(attack_gif.n_frames):
- attack_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(attack_gif, i)), (200,200)))
+ attack_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(attack_gif, i)), (200, 200)))
width, height = idle_frames[0].get_size()
self.starting_potions = 999
self.potion_bag = [Potion(self)]
for i in range(self.starting_potions):
- self.potion_bag.append(Potion(self)) # use one liner
+ self.potion_bag.append(Potion(self)) # use one liner
- self.weapon = Sword(self.position, (0,0), self.width, -1)
+ self.weapon = Sword(self.position, (0, 0), self.width, -1)
self.targets = can_hurt
self.direction = -1
self.state = "IDLE"
self.current_frame = 0
self.display = self.idle_frames[0]
- self.display_offsets = {"weapon": pg.Vector2(0, 0), "player":pg.Vector2(0,0)}
+ self.display_offsets = {"weapon": pg.Vector2(0, 0), "player": pg.Vector2(0, 0)}
+
# def attack(self, enemy, weapon):
# super(Player, self).attack(enemy, weapon)
# self.state = "ATTACK"
# print('a')
-
def update(self, delta):
super().update(delta)
self.weapon.update(delta, self.position, self.direction)
if self.state == "IDLE":
- self.display_offsets["player"] = pg.Vector2(0,0)
+ self.display_offsets["player"] = pg.Vector2(0, 0)
frame = math.floor(self.current_frame)
if self.direction == 1:
# 1 - 10 up, 11 down by 1, 12 - 18 down by 2, 19-20 down 1 FIX THIS
frame += 1
if 3 < frame < 12:
- self.display_offsets["weapon"] = pg.Vector2( 3, -2)
+ self.display_offsets["weapon"] = pg.Vector2(3, -2)
else:
- self.display_offsets["weapon"] = pg.Vector2( 3, -5)
+ self.display_offsets["weapon"] = pg.Vector2(3, -5)
self.current_frame = (self.current_frame + 0.1) % len(self.idle_frames)
elif self.state == "ATTACK":
frame = math.floor(self.current_frame)
if self.direction == 1:
self.display = self.attack_frames[math.floor(frame)]
- self.display_offsets["player"] = pg.Vector2(-50,-50)
+ self.display_offsets["player"] = pg.Vector2(-50, -50)
elif self.direction == -1:
self.display = pg.transform.flip(self.attack_frames[math.floor(frame)], True, False)
- self.display_offsets["player"] = pg.Vector2(-100,-50)
+ self.display_offsets["player"] = pg.Vector2(-100, -50)
else:
self.direction = prev_direction
if prev_direction == 1:
- self.display_offsets["player"] = pg.Vector2(-50,-50)
+ self.display_offsets["player"] = pg.Vector2(-50, -50)
self.display = self.attack_frames[math.floor(frame)]
elif prev_direction == -1:
self.display = pg.transform.flip(self.attack_frames[math.floor(frame)], True, False)
- self.display_offsets["player"] = pg.Vector2(-100,-50)
+ self.display_offsets["player"] = pg.Vector2(-100, -50)
self.current_frame += 0.4
if math.floor(self.current_frame) == self.attack_gif.n_frames:
if self.state != "ATTACK":
self.state = "ATTACK"
self.current_frame = 0
- elif self.state == "ATTACK":
- if math.floor(self.current_frame) > 2:
- for mask in self.targets:
- for enemy in mask:
- if not enemy.attacked and self.weapon.get_collision_rect().colliderect(enemy.get_collision_rect()):
- enemy.attack(self, self.weapon)
+ if self.state == "ATTACK":
+ if 12 > math.floor(self.current_frame) > 6:
+ for mask in self.targets:
+ for enemy in mask:
+ # if not enemy.attacked and self.weapon.get_collision_rect().colliderect(
+ # enemy.get_collision_rect()):
+ if not enemy.attacked and get_display_rect(self.weapon.get_collision_rect()).colliderect(
+ get_display_rect(enemy.get_collision_rect())):
+ enemy.attack(self, self.weapon, self.direction)
def draw(self, surf):
if self.state == "IDLE":
# self.weapon.draw(surf, self.display_offsets["weapon"])
if self.direction == 1:
- surf.blit(pg.transform.flip(self.weapon.img, True, True), get_display_rect(self.get_collision_rect()).topleft+pg.Vector2(-25,55) + self.display_offsets["weapon"])
+ surf.blit(pg.transform.flip(self.weapon.img, True, True),
+ get_display_rect(self.get_collision_rect()).topleft + pg.Vector2(-25, 55) +
+ self.display_offsets["weapon"])
elif self.direction == -1:
- surf.blit(pg.transform.flip(self.weapon.img, False, True), get_display_rect(self.get_collision_rect()).topleft+pg.Vector2(0,55) + self.display_offsets["weapon"])
+ surf.blit(pg.transform.flip(self.weapon.img, False, True),
+ get_display_rect(self.get_collision_rect()).topleft + pg.Vector2(0, 55) +
+ self.display_offsets["weapon"])
surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["player"])
# super().draw(surf)
# print(self.position, self.velocity, get_display_rect(self.get_collision_rect()).topleft, Setup.camera_offset)
# pg.draw.rect(surf, self.colour, get_display_rect(self.get_collision_rect()), border_radius=8)
- pg.draw.rect(surf, (255,0,0),get_display_rect(self.weapon.get_collision_rect()),width=3)
- # pg.draw.rect(surf,self.colour,pg.Rect(center, (self.width, self.height)),border_radius=8)
+ pg.draw.rect(surf, (255, 0, 0), get_display_rect(self.weapon.get_collision_rect()), width=3)
+ pg.draw.rect(surf, (0, 255, 0), get_display_rect(self.get_collision_rect()), 2)
+ # pg.draw.rect(surf,self.colour,pg.Rect(center, (self.width, self.height)),border_radius=8)
# # Healthbar Stuff
# # bar is made of 2 rectanges, background which is just a simple rectange and foreground which goes on top and has a bit of math involved
# text_rect = current_health_display.get_rect(center=background_rect.center)
# surf.blit(current_health_display, text_rect)
-
-
def potion_cooldown_timer(self):
while self.potion_cooldown > 0:
self.potion_cooldown -= 1
- print(self.potion_cooldown)
+ # print(self.potion_cooldown)
time.sleep(1)
-
-
pg.init()
+display_info = pg.display.Info()
+
SCREEN_WIDTH, SCREEN_HEIGHT = 1080, 640
+# SCREEN_WIDTH, SCREEN_HEIGHT = display_info.current_w, display_info.current_h-10
dimensions = (SCREEN_WIDTH, SCREEN_HEIGHT)
center = pg.Vector2(dimensions) / 2
def get_gif_frame(img, frame):
img.seek(frame)
- return img.convert(FORMAT)
\ No newline at end of file
+ return img.convert(FORMAT)
# scene = TransitionScene()
scene = DevLevelSelect()
old_level = 0
-level = 1
+level =1
next_level = 0
while is_running:
scene = Game(1)
case 2:
scene = Game(2)
+ case 3:
+ scene = Game(3)
old_level = level
scene.update(delta)