change speed

This commit is contained in:
Aron Petau 2025-10-12 10:53:46 +02:00
parent 62a177108c
commit 169b7782ba
3 changed files with 5 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Before After
Before After

View file

@ -35,16 +35,16 @@ class Enemy:
elif self.controlled:
dx = dy = 0
if keys[pygame.K_UP]:
dy -= PLAYER_SPEED // 1.5
dy -= PLAYER_SPEED
self.dir = "up"
if keys[pygame.K_DOWN]:
dy += PLAYER_SPEED // 1.5
dy += PLAYER_SPEED
self.dir = "down"
if keys[pygame.K_LEFT]:
dx -= PLAYER_SPEED // 1.5
dx -= PLAYER_SPEED
self.dir = "left"
if keys[pygame.K_RIGHT]:
dx += PLAYER_SPEED // 1.5
dx += PLAYER_SPEED
self.dir = "right"
self.x = max(0, min(map_w - PLAYER_SIZE // 2, self.x + dx))
self.y = max(0, min(map_h - PLAYER_SIZE // 2, self.y + dy))
@ -54,7 +54,7 @@ class Enemy:
dx = player.x - self.x
dy = player.y - self.y
dist = max(1, (dx ** 2 + dy ** 2) ** 0.5)
speed = PLAYER_SPEED // 2
speed = PLAYER_SPEED // 1.5
self.x += int(speed * dx / dist)
self.y += int(speed * dy / dist)
self.x = max(0, min(map_w - PLAYER_SIZE // 2, self.x))

Binary file not shown.