Skip to content

Commit

Permalink
fix ducked up physics
Browse files Browse the repository at this point in the history
  • Loading branch information
bydariogamer committed Dec 28, 2022
1 parent 31255ea commit 47c485a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,10 @@ async def level_loop():
damage.fill((20, 0, 0, 30))
time_started = None
won = False
dt = 1/config.BASE_FPS
lose_played = False
lose = pygame.mixer.Sound("assets/sounds/lose.ogg")

while state == "level":
for event in pygame.event.get():
if event.type == pygame.QUIT:
Expand All @@ -436,7 +438,7 @@ async def level_loop():

# LOGIC
if player.run:
player.update((pygame.time.get_ticks() - time_started) / 1000)
player.update(dt)

# RENDER
player.draw(game)
Expand Down
6 changes: 3 additions & 3 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ def update(self, dt):
if self.vel_y < config.VELOCITY_Y_DURING_DAMAGE:
self.vel_y = float(config.VELOCITY_Y_DURING_DAMAGE)
if not self.collide:
self.vel_y -= self.level.gravity / config.BASE_FPS
self.rect.y -= self.vel_y / config.BASE_FPS
self.vel_y -= self.level.gravity * dt / 1000
self.rect.y -= self.vel_y * dt / 1000
if self.rect.y >= self.floor:
self.rect.y = self.floor
self.vel_y = 0
Expand Down Expand Up @@ -128,7 +128,7 @@ def update(self, dt):
# move stars and delete the ones out of screen
if self.run and self.level.obstacles:
for index, star in enumerate(self.stars):
star[0] -= 1
star[0] -= dt / 10
if star[0] < -5:
del self.stars[index]
# every time half of the stars are deleted, new ones are added
Expand Down

0 comments on commit 47c485a

Please sign in to comment.