Mercurial > nagslang
diff nagslang/screens/area.py @ 371:21c1c329f8e3
Automatic weapons.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 06 Sep 2013 21:56:57 +0200 |
parents | 3aa3981a64a4 |
children | 51deb78cae52 |
line wrap: on
line diff
--- a/nagslang/screens/area.py Fri Sep 06 21:37:00 2013 +0200 +++ b/nagslang/screens/area.py Fri Sep 06 21:56:57 2013 +0200 @@ -7,7 +7,7 @@ from nagslang.constants import ( COLLISION_TYPE_WALL, COLLISION_TYPE_PLAYER, CALLBACK_COLLIDERS, COLLISION_TYPE_FURNITURE, COLLISION_TYPE_WEREWOLF_ATTACK, - CMD_TOGGLE_FORM, CMD_ATTACK, CMD_ACTION) + CMD_TOGGLE_FORM, CMD_ACTION) from nagslang.enemies import DeadEnemy from nagslang.events import ( ScreenChange, DoorEvent, FireEvent, EnemyDeathEvent, ClawEvent) @@ -25,10 +25,10 @@ (1, 0): set([pygame.locals.K_RIGHT, pygame.locals.K_d]), } + attack_keys = set([pygame.locals.K_z, pygame.locals.K_LCTRL]) + command_keys = { pygame.locals.K_c: CMD_TOGGLE_FORM, - pygame.locals.K_z: CMD_ATTACK, - pygame.locals.K_LCTRL: CMD_ATTACK, pygame.locals.K_SPACE: CMD_ACTION, } @@ -55,6 +55,9 @@ dy += ty return (dx, dy) + def is_attacking(self): + return bool(self.keys_down & self.attack_keys) + def get_command_key(self, key): return self.command_keys.get(key, None) @@ -233,6 +236,8 @@ def tick_protagonist(self): dx, dy = self.keys.get_direction() self.protagonist.set_direction(dx, dy) + if self.keys.is_attacking(): + self.protagonist.handle_attack_key_down() def tick(self, seconds): super(AreaScreen, self).tick(seconds)