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