import threading
from Setup import *
+from Particle import Dust
# from PhysicsBody import PhysicsBody
from Block import Block
terminal_velocity = 15
invincibility_time = 150
+
def __init__(self, pos, collision_layer, collision_mask):
self.position = pg.Vector2(pos)
self.velocity = pg.Vector2(0, 0)
self.jumping = False
self.coyote_time = datetime.utcnow()
self.hold_jump = datetime.utcnow()
- self.stun_time = 750
+ self.stun_time = 1000
self.attacked = False
self.invincibility_frames = 0
if self.jumping:
if self.on_ground:
self.jumping = False
+ Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(-16,-15), 32, 0)
self.stun_time -= delta
self.stun_time = max(self.stun_time, 0)
from Setup import *
from Player import Player
from Actors import Actor
-from Weapon import Melee
-
+from Weapon import Sword
+from Particle import Dust
class Enemy(Actor):
speed = Actor.speed * 0.33
jump_strength = Actor.jump_strength * 0.5
colour = (235, 64, 52)
friction = 0.9
- run_gif = Image.open("Assets/skeleton/skeleton_run.gif")
+ run_gif = Image.open("Assets/enemy/Goon_Run.gif")
run_frames = []
for i in range(run_gif.n_frames):
- run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (125, 125)))
+ run_frames.append(pg.transform.scale(pil_to_game(get_gif_frame(run_gif, i)), (180, 180)))
def __init__(self, pos, collision_layer, collision_mask):
super().__init__(pos, collision_layer, collision_mask)
# 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)
+ self.weapon = Sword(self.position, (0, 0), self.width, -1)
+
self.buffer = []
def update(self, delta, target=None):
super().update(delta)
if not self.attacked and target is not None and self.stun_time == 0:
- # print('a')
- 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.follow_target(target, stop_dist=target.width/2+self.weapon.width)
+ if not target.attacked and get_display_rect(self.weapon.get_collision_rect()).colliderect(
+ get_display_rect(target.get_collision_rect())):
+ target.attack(self, self.weapon, self.direction)
# Deals with collision and applying velocity
self.position, self.velocity = self.move_and_collide(self.position.copy(), self.velocity.copy(), delta)
frame = math.floor(self.current_frame)
if self.velocity.x > 0:
self.display = self.run_frames[math.floor(frame)]
- self.display_offsets["enemy"] = pg.Vector2(-40, -35)
+ self.display_offsets["enemy"] = pg.Vector2(-60, -35)
elif self.velocity.x <= 0:
self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
- self.display_offsets["enemy"] = pg.Vector2(-55, -35)
-
+ self.display_offsets["enemy"] = pg.Vector2(-60, -35)
+ if frame % 4 == 0 and self.on_ground:
+ Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
def draw(self, surf):
self.weapon.draw(surf)
- # super(Enemy, self).draw(surf)
+ super(Enemy, self).draw(surf)
surf.blit(self.display, get_display_rect(self.get_collision_rect()).topleft + self.display_offsets["enemy"])
# for b in self.buffer:
self.collision_layer["enemy"].remove(enemy)
self.collision_layer["body"].add(self.enemies[i])
+ for particle in particles:
+ particle.update(delta)
+
self.world.update(delta)
self.fade = self.Transition.fade
pass;
self.world.draw(surf)
+
+ for particle in particles:
+ particle.draw(surf)
+
for enemy in self.enemies:
enemy.draw(surf)
-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|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
-1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|2050.0,700.0
-GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|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|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY
+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|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
+1250.0,750.0|1200.0,750.0|1350.0,750.0|1350.0,700.0|1450.0,750.0|1450.0,700.0|1450.0,650.0|1450.0,600.0|1450.0,550.0|1250.0,700.0|1900.0,550.0|1900.0,600.0|1900.0,650.0|1900.0,700.0|1900.0,750.0|50.0,800.0|100.0,800.0|150.0,800.0|200.0,800.0|250.0,800.0|300.0,800.0|350.0,800.0|400.0,800.0|450.0,800.0|500.0,800.0|550.0,800.0|600.0,800.0|650.0,800.0|700.0,800.0|750.0,800.0|800.0,800.0|850.0,800.0|900.0,800.0|950.0,800.0|1000.0,800.0|1050.0,800.0|1100.0,800.0|1150.0,800.0|1200.0,800.0|1250.0,800.0|1300.0,800.0|1350.0,800.0|1400.0,800.0|1450.0,800.0|1500.0,800.0|1550.0,800.0|1600.0,800.0|1650.0,800.0|1700.0,800.0|1750.0,800.0|1800.0,800.0|1850.0,800.0|1900.0,800.0|1950.0,800.0|2000.0,800.0|2050.0,800.0|2100.0,800.0|2150.0,850.0|2100.0,850.0|2050.0,850.0|2000.0,850.0|1950.0,850.0|1900.0,850.0|1850.0,850.0|1800.0,850.0|1750.0,850.0|1700.0,850.0|1650.0,850.0|1600.0,850.0|1550.0,850.0|1500.0,850.0|1450.0,850.0|1400.0,850.0|1350.0,850.0|1300.0,850.0|1250.0,850.0|1200.0,850.0|1150.0,850.0|1100.0,850.0|1050.0,850.0|1000.0,850.0|950.0,850.0|900.0,850.0|850.0,850.0|800.0,850.0|750.0,850.0|700.0,850.0|650.0,850.0|600.0,850.0|550.0,850.0|500.0,850.0|450.0,850.0|400.0,850.0|350.0,850.0|300.0,850.0|250.0,850.0|200.0,850.0|150.0,850.0|100.0,850.0|50.0,850.0|0.0,850.0|0.0,800.0|0.0,750.0|0.0,700.0|0.0,650.0|0.0,600.0|0.0,550.0|0.0,400.0|0.0,350.0|0.0,300.0|0.0,250.0|0.0,200.0|0.0,150.0|0.0,100.0|0.0,50.0|0.0,0.0|2200.0,850.0|2200.0,800.0|2200.0,750.0|2200.0,700.0|2200.0,650.0|2200.0,600.0|2150.0,400.0|2200.0,200.0|2200.0,150.0|2200.0,100.0|2200.0,50.0|2200.0,0.0|2150.0,0.0|2150.0,50.0|2150.0,100.0|2150.0,150.0|2150.0,200.0|2150.0,250.0|2150.0,350.0|2150.0,300.0|2200.0,250.0|2200.0,300.0|2200.0,350.0|2200.0,400.0|2200.0,550.0|2150.0,550.0|2150.0,600.0|2150.0,650.0|2150.0,700.0|2150.0,750.0|2150.0,800.0|300.0,600.0|0.0,450.0|2200.0,450.0|2150.0,450.0|2150.0,500.0|2200.0,500.0|0.0,500.0|2050.0,700.0
+GOLDCOIN|BRONZECOIN|PEDESTAL|INTERDIMENSIONALPOWDER|PILLAR_|PILLAR_|PILLAR_|PILLAR_|PILLAR_|SILVERCOIN|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|PLAYER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|PLACEHOLDER|ENEMY
--- /dev/null
+import Setup
+from Setup import *
+
+class Dust:
+ dust_gif = Image.open("Assets/player/DUSTCLOUD.gif")
+ dust_frames = []
+ for i in range(dust_gif.n_frames):
+ dust_frames.append(pil_to_game(get_gif_frame(dust_gif, i)))
+
+ def __init__(self, pos, dust_size, direction):
+ self.position = pg.Vector2(pos)
+ self.dust_size = dust_size
+ self.velocity = pg.Vector2(0,0)
+ self.direction = -direction
+ self.current_frame = 0
+ self.display = self.dust_frames[math.floor(self.current_frame)]
+ Setup.particles.append(self)
+
+ def update(self, delta):
+ self.position += self.velocity
+ self.velocity = pg.Vector2(self.direction * delta / 64, -self.current_frame * delta / 256)
+ self.display = pg.transform.scale(self.dust_frames[math.floor(self.current_frame)], (self.dust_size, self.dust_size))
+ self.current_frame = (self.current_frame + 0.25)
+ if math.floor(self.current_frame) >= self.dust_gif.n_frames-1:
+ del Setup.particles[Setup.particles.index(self)]
+
+ def draw(self, surf):
+ surf.blit(self.display, get_display_point(self.position))
from datetime import datetime, timedelta
from Potion import Potion
from Weapon import Sword
+from Particle import Dust
class Player(Actor):
+ friction = 0.2
scale = 100
factor = 640 / scale
crop = pg.Rect(179, 169, 170, 401)
# print('a')
def update(self, delta):
+
+ if self.attacked:
+ self.friction = 0.9
+ else:
+ self.friction = 0.2
+
super().update(delta)
# Get and handle input
self.display = pg.transform.flip(self.run_frames[math.floor(frame)], True, False)
self.display_offsets["player"] = pg.Vector2(-65, -35)
+ if frame % 2 == 0 and self.on_ground:
+ Dust(pg.Vector2(self.get_collision_rect().midbottom) + pg.Vector2(math.copysign(1, self.velocity.x) * -self.width/2,-15), 16, self.direction)
+
self.current_frame = (self.current_frame + 0.5) % self.run_gif.n_frames
if self.state == "RUN":
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"])
+
+ a = get_display_rect(self.get_collision_rect())
+ b = a.topleft + self.display_offsets["player"]
+ if pg.Rect(b,a.size).colliderect(screen_rect):
+ surf.blit(self.display, b)
#
# for b in self.buffer:
# pg.draw.rect(surf,(0,0,255),get_display_rect(b),3)
dimensions = (SCREEN_WIDTH, SCREEN_HEIGHT)
center = pg.Vector2(dimensions) / 2
+screen_rect = pg.Rect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT)
+
pg.display.set_caption("Jam")
# icon = pg.transform.scale(pg.image.load("logo.ico"), (32, 32))
# pg.display.set_icon(icon)
def get_gif_frame(img, frame):
img.seek(frame)
return img.convert(FORMAT)
+
+particles = []
pg.display.update()
delta = clock.tick(fps)
+ print(clock.get_fps())
pg.quit()