Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Dev to Main #5

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
modified
  • Loading branch information
durb-afk committed Feb 24, 2024
commit fcd0037da2140c5fcbf264026eaf5001af3415fe
Binary file modified code/__pycache__/level.cpython-311.pyc
Binary file not shown.
Binary file modified code/__pycache__/player.cpython-311.pyc
Binary file not shown.
14 changes: 7 additions & 7 deletions code/level.py
Original file line number Diff line number Diff line change
@@ -134,7 +134,7 @@ def horizontal_movement_collision(self):
#merging knock back, wall collision and invisble frames
for enemy in self.enemies.sprites():
for sprite in self.tiles.sprites():
if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state != 'attack':
if enemy.rect.colliderect(player.rect) and not player.is_invincible: #and player.state2 != 'attack':


# check if player is on the left of enemy or right and knock in that direction
@@ -166,8 +166,8 @@ def horizontal_movement_collision(self):
player.jump()
player.on_ground = False
# check collision with the wall
if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state == 'attack' and player.direction.x != enemy.direction.x:
enemy.kill()
# if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state2 == 'attack' and player.direction.x != enemy.direction.x:
# enemy.kill()
if sprite.rect.colliderect(player.rect) and sprite != self.doors.sprite:
if player.direction.x < 0:
player.rect.left = sprite.rect.right
@@ -184,7 +184,7 @@ def vertical_movement_collision(self):
#merging vertical knock back, wall collision and invislbe frames
for enemy in self.enemies.sprites():
for sprite in self.tiles.sprites():
if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state != 'jumpAttack':
if enemy.rect.colliderect(player.rect) and not player.is_invincible: #and player.state2 != 'jumpAttack':
if player.rect.left < enemy.rect.left:
#player.direction.y = -15
player.is_attacked(-1)
@@ -208,8 +208,8 @@ def vertical_movement_collision(self):

player.jump()
player.on_ground = False
if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state == 'jumpAttack':
enemy.kill()
# if enemy.rect.colliderect(player.rect) and not player.is_invincible and player.state2 == 'jumpAttack':
# enemy.kill()
if sprite.rect.colliderect(player.rect):
if player.direction.y > 0:
player.rect.bottom = sprite.rect.top
@@ -247,6 +247,6 @@ def run(self):
self.enemies.draw(self.display_surface)

def check_player(self):
if self.player.sprite.current_health == 0 or (self.player.sprite.rect.left < 0 or self.player.sprite.rect.right > screen_width) or (self.player.sprite.rect.bottom > screen_height or self.player.sprite.rect.top < 0):
if self.player.sprite.current_health == 0 or (self.player.sprite.rect.left < 0 or self.player.sprite.rect.right > screen_width) or (self.player.sprite.rect.bottom > screen_height or self.player.sprite.rect.bottom < -64):
return 0
return 1
11 changes: 5 additions & 6 deletions code/player.py
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ def import_character_assets(self,size:(int,int)):
character_path = path.join(base_path, 'freeknight')
self.animations = {'idle': [], 'run': [], 'jump': [], 'attack': [], 'dead': [], 'jumpAttack': [], 'walk': []}
self.health_icons = {
'full': pygame.transform.smoothscale(pygame.image.load(base_path+'Tiles\\dirt.png'), (size[0]//2, size[1]//2)),
'half': pygame.transform.smoothscale(pygame.image.load(base_path+'Tiles\\dirtHalf.png'), (size[0]//2, size[1]//2)),
'noHealth': pygame.transform.smoothscale(pygame.image.load(base_path+'Tiles\\boxAlt.png'), (size[0]//2, size[1]//2))
'full': pygame.transform.smoothscale(pygame.image.load(base_path + 'Tiles\\dirt.png'), (size[0]//2, size[1]//2)),
'half': pygame.transform.smoothscale(pygame.image.load(base_path +'Tiles\\dirtHalf.png'), (size[0]//2, size[1]//2)),
'noHealth': pygame.transform.smoothscale(pygame.image.load(base_path + 'Tiles\\boxAlt.png'), (size[0]//2, size[1]//2))
}

for animation in self.animations.keys():
@@ -145,8 +145,7 @@ def is_attacked(self,dir=0):
self.is_invincible = True
self.attacked_dir = dir
self.attacked_c = 1
if self.state != 'attack' or self.state != 'attack':
self.current_health -= 1
self.current_health -= 1
#self.jump()

def get_input(self):
@@ -204,4 +203,4 @@ def jump(self,wind=0):
def update(self):
self.get_input()
self.update_state()
self.animate()
self.animate()