Compare commits

...

2 commits

Author SHA1 Message Date
65c5ce0f55 Merge branch 'main' of https://forgejo.petau.net/aron/cdec 2025-10-12 10:53:57 +02:00
169b7782ba change speed 2025-10-12 10:53:46 +02:00
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: elif self.controlled:
dx = dy = 0 dx = dy = 0
if keys[pygame.K_UP]: if keys[pygame.K_UP]:
dy -= PLAYER_SPEED // 1.5 dy -= PLAYER_SPEED
self.dir = "up" self.dir = "up"
if keys[pygame.K_DOWN]: if keys[pygame.K_DOWN]:
dy += PLAYER_SPEED // 1.5 dy += PLAYER_SPEED
self.dir = "down" self.dir = "down"
if keys[pygame.K_LEFT]: if keys[pygame.K_LEFT]:
dx -= PLAYER_SPEED // 1.5 dx -= PLAYER_SPEED
self.dir = "left" self.dir = "left"
if keys[pygame.K_RIGHT]: if keys[pygame.K_RIGHT]:
dx += PLAYER_SPEED // 1.5 dx += PLAYER_SPEED
self.dir = "right" self.dir = "right"
self.x = max(0, min(map_w - PLAYER_SIZE // 2, self.x + dx)) 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)) self.y = max(0, min(map_h - PLAYER_SIZE // 2, self.y + dy))
@ -54,7 +54,7 @@ class Enemy:
dx = player.x - self.x dx = player.x - self.x
dy = player.y - self.y dy = player.y - self.y
dist = max(1, (dx ** 2 + dy ** 2) ** 0.5) 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.x += int(speed * dx / dist)
self.y += int(speed * dy / dist) self.y += int(speed * dy / dist)
self.x = max(0, min(map_w - PLAYER_SIZE // 2, self.x)) self.x = max(0, min(map_w - PLAYER_SIZE // 2, self.x))

Binary file not shown.