projects
/
koperkapel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update the menu.
[koperkapel.git]
/
koperkapel
/
scenes
/
level.py
diff --git
a/koperkapel/scenes/level.py
b/koperkapel/scenes/level.py
index 54449dcc8513f7d2d91b5768d7549307f54e1e94..6a8e232284b14746b6b592b5b9c8239754b2ad93 100644
(file)
--- a/
koperkapel/scenes/level.py
+++ b/
koperkapel/scenes/level.py
@@
-4,9
+4,10
@@
from pgzero.constants import keys
from pygame import Surface
import pygame.locals as pgl
from ..loaders.levelloader import levels
from pygame import Surface
import pygame.locals as pgl
from ..loaders.levelloader import levels
-from .base import Scene, ChangeSceneEvent, MoveViewportEvent, defer_to_update
+from .base import Scene, ChangeSceneEvent, MoveViewportEvent,
AddRoachEvent,
defer_to_update
from ..constants import TILE_SIZE, WIDTH, HEIGHT
from ..vehicles.base import Vehicle
from ..constants import TILE_SIZE, WIDTH, HEIGHT
from ..vehicles.base import Vehicle
+from ..roaches import RoachFactory, WorldRoach
class BaseLevelScene(Scene):
class BaseLevelScene(Scene):
@@
-87,6
+88,7
@@
class GameLevelScene(BaseLevelScene):
return
super().enter(world)
self._roaches = self.actors.add_layer("roaches", level=10)
return
super().enter(world)
self._roaches = self.actors.add_layer("roaches", level=10)
+ self._friends = self.actors.add_layer("friendly roaches", level=9)
self._vehicle = Vehicle.current(world)
self._mode = 'walk'
self._angle = 0
self._vehicle = Vehicle.current(world)
self._mode = 'walk'
self._angle = 0
@@
-99,6
+101,8
@@
class GameLevelScene(BaseLevelScene):
self._set_pos(x, y)
self._avatar.pos = (WIDTH // 2, HEIGHT // 2)
self._roaches.add(self._avatar)
self._set_pos(x, y)
self._avatar.pos = (WIDTH // 2, HEIGHT // 2)
self._roaches.add(self._avatar)
+ for friend in self._level.friends:
+ self._friends.add(friend)
# Fix viewport offset
return [
MoveViewportEvent((
# Fix viewport offset
return [
MoveViewportEvent((
@@
-107,6
+111,7
@@
class GameLevelScene(BaseLevelScene):
def _set_pos(self, x, y):
self._player_pos = (x, y)
def _set_pos(self, x, y):
self._player_pos = (x, y)
+ #print('At ', (x, y))
def _can_move(self, x, y):
if self._mode == 'walk':
def _can_move(self, x, y):
if self._mode == 'walk':
@@
-138,6
+143,9
@@
class GameLevelScene(BaseLevelScene):
def update(self, world, engine, dt):
super().update(world, engine, dt)
events = world.pop_events()
def update(self, world, engine, dt):
super().update(world, engine, dt)
events = world.pop_events()
+ for friend in self._friends:
+ friend.pos = self.calc_offset(
+ friend.game_pos[0] * TILE_SIZE, friend.game_pos[1] * TILE_SIZE)
return events
def on_key_down(self, key, mod, unicode):
return events
def on_key_down(self, key, mod, unicode):
@@
-176,6
+184,11
@@
class GameLevelScene(BaseLevelScene):
self._mode = 'walk'
elif self._level.is_keypad(x, y):
self._level.press_keypad(x, y, self._roaches)
self._mode = 'walk'
elif self._level.is_keypad(x, y):
self._level.press_keypad(x, y, self._roaches)
+ elif self._level.is_on_friend(x, y):
+ friend = self._level.remove_friend(x, y)
+ self._friends.remove(friend)
+ self._vehicle_changed()
+ return [AddRoachEvent()]
return
elif key == keys.X:
# Fire
return
elif key == keys.X:
# Fire