Mercurial > fife-parpg
annotate demos/shooter/scripts/ships/enemies.py @ 452:f07d779362da
Added different enemy types which behave differently.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 03 Apr 2010 19:19:33 +0000 |
parents | |
children | cf53848fb187 |
rev | line source |
---|---|
452
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # Copyright (C) 2005-2009 by the FIFE team |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # http://www.fifengine.de |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 from fife import fife |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 from scripts.ships.shipbase import Ship |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 from scripts.common.helpers import Rect |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 from scripts.weapons import Weapon |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 class Saucer1(Ship): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 def __init__(self, model, name, layer, findInstance=True): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 super(Saucer1, self).__init__(model, name, layer, findInstance) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 self._time = 500 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 self.width = 0.075 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 self.height = 0.075 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 self.velocity.x = -0.5 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 def update(self, timedelta): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 self.applyThrust(fife.DoublePoint(0,-0.5), timedelta) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 self.applyThrust(fife.DoublePoint(0,0.5), timedelta) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 if self._time >= 1000: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 self._dir = 1 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self._time = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self._time += timedelta |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 super(Saucer1, self).update(timedelta) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 class Saucer2(Ship): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 def __init__(self, model, name, layer, findInstance=True): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 super(Saucer2, self).__init__(model, name, layer, findInstance) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 self._time = 1000 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 self.width = 0.2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 self.height = 0.2 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 self.velocity.x = -0.1 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 def update(self, timedelta): |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 self.applyThrust(fife.DoublePoint(0,-0.25), timedelta) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 self.applyThrust(fife.DoublePoint(0,0.25), timedelta) |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 if self._time >= 2000: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 if self._dir == 1: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 self._dir = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 elif self._dir == 0: |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 self._dir = 1 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 self._time = 0 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 self._time += timedelta |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 |
f07d779362da
Added different enemy types which behave differently.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 super(Saucer2, self).update(timedelta) |