Mercurial > skaapsteker
annotate skaapsteker/sprites/enemies.py @ 373:a2efe5470b79
start of patrolling monsters
author | Neil Muller <drnlmuller@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 15:00:53 +0200 |
parents | c8fd82ff0c71 |
children | ed26bbfec03a |
rev | line source |
---|---|
373
a2efe5470b79
start of patrolling monsters
Neil Muller <drnlmuller@gmail.com>
parents:
336
diff
changeset
|
1 from base import Monster, PatrollingMonster |
239
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
2 from pygame import transform |
25 | 3 |
4 | |
240 | 5 class RedOni(Monster): |
236
9528c6fc7f75
Hook up attack anaimation (needs facing support still)
Neil Muller <drnlmuller@gmail.com>
parents:
202
diff
changeset
|
6 image_dir = 'sprites/oni red' |
9528c6fc7f75
Hook up attack anaimation (needs facing support still)
Neil Muller <drnlmuller@gmail.com>
parents:
202
diff
changeset
|
7 |
9528c6fc7f75
Hook up attack anaimation (needs facing support still)
Neil Muller <drnlmuller@gmail.com>
parents:
202
diff
changeset
|
8 attack_frame = 1 |
9528c6fc7f75
Hook up attack anaimation (needs facing support still)
Neil Muller <drnlmuller@gmail.com>
parents:
202
diff
changeset
|
9 attack_damage = 10 |
333
e499a10eb41f
Time based animation for npcs and monsters. Make oni attack faster
Neil Muller <drnlmuller@gmail.com>
parents:
240
diff
changeset
|
10 frame_pause = 0.05 # Fast attacks |
47 | 11 |
239
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
12 facings = { |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
13 'running' : (('left', None), |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
14 ('right', lambda x: transform.flip(x, True, False))), |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
15 'attacking' : (('left', None), |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
16 ('right', lambda x: transform.flip(x, True, False))), |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
17 } |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
18 |
25 | 19 def setup(self, direction): |
127
e1dd3b785269
Initial game state stuff.
Jeremy Thurgood <firxen@gmail.com>
parents:
59
diff
changeset
|
20 self.facing = direction |
239
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
21 |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
22 def start_attack(self, player): |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
23 if self._animation != 'attacking': |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
24 # Turn to face the player we're attacking |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
25 if player.collide_rect.centerx > self.collide_rect.centerx: |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
26 self.facing = 'right' |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
27 else: |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
28 self.facing = 'left' |
6a2f366d5e62
Add facing support for attack animations
Neil Muller <drnlmuller@gmail.com>
parents:
236
diff
changeset
|
29 Monster.start_attack(self, player) |
336
c8fd82ff0c71
Hook up fire buttons to attack functions. Use correct check for tails. Add skeleton for projectiles.
Simon Cross <hodgestar@gmail.com>
parents:
333
diff
changeset
|
30 |
c8fd82ff0c71
Hook up fire buttons to attack functions. Use correct check for tails. Add skeleton for projectiles.
Simon Cross <hodgestar@gmail.com>
parents:
333
diff
changeset
|
31 |
c8fd82ff0c71
Hook up fire buttons to attack functions. Use correct check for tails. Add skeleton for projectiles.
Simon Cross <hodgestar@gmail.com>
parents:
333
diff
changeset
|
32 class FireballOni(RedOni): |
c8fd82ff0c71
Hook up fire buttons to attack functions. Use correct check for tails. Add skeleton for projectiles.
Simon Cross <hodgestar@gmail.com>
parents:
333
diff
changeset
|
33 pass # TODO |
373
a2efe5470b79
start of patrolling monsters
Neil Muller <drnlmuller@gmail.com>
parents:
336
diff
changeset
|
34 |
a2efe5470b79
start of patrolling monsters
Neil Muller <drnlmuller@gmail.com>
parents:
336
diff
changeset
|
35 |
a2efe5470b79
start of patrolling monsters
Neil Muller <drnlmuller@gmail.com>
parents:
336
diff
changeset
|
36 class PatrollingOni(RedOni, PatrollingMonster): |
a2efe5470b79
start of patrolling monsters
Neil Muller <drnlmuller@gmail.com>
parents:
336
diff
changeset
|
37 pass |