changeset 470:3b04e921c93d

Added the fireball projectile. Added a new ship images for the boss. Some enemies now shoot directly at the player.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Wed, 14 Apr 2010 19:15:27 +0000
parents 5994e61cdebd
children 7a79dc2a0592
files demos/shooter/maps/shooter_map1.xml demos/shooter/objects/projectiles/fireball/fire_ball.png demos/shooter/objects/projectiles/fireball/object.xml demos/shooter/objects/ships/boss1/explode/animation.xml demos/shooter/objects/ships/boss1/explode/boss_0.png demos/shooter/objects/ships/boss1/explode/boss_1.png demos/shooter/objects/ships/boss1/explode/boss_2.png demos/shooter/objects/ships/boss1/explode/boss_3.png demos/shooter/objects/ships/boss1/explode/boss_4.png demos/shooter/objects/ships/boss1/explode/boss_5.png demos/shooter/objects/ships/boss1/flash/animation.xml demos/shooter/objects/ships/boss1/flash/boss_0.png demos/shooter/objects/ships/boss1/flash/boss_1.png demos/shooter/objects/ships/boss1/fly/animation.xml demos/shooter/objects/ships/boss1/fly/boss.png demos/shooter/objects/ships/boss1/object.xml demos/shooter/scripts/scene.py demos/shooter/scripts/ships/enemies.py demos/shooter/scripts/weapons.py
diffstat 19 files changed, 98 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/demos/shooter/maps/shooter_map1.xml	Wed Apr 14 17:42:24 2010 +0000
+++ b/demos/shooter/maps/shooter_map1.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -4,7 +4,9 @@
 	<import file="../objects/ships/player/object.xml"></import>
 	<import file="../objects/ships/saucer1/object.xml"></import>
 	<import file="../objects/ships/saucer2/object.xml"></import>
+	<import file="../objects/ships/boss1/object.xml"></import>
 	<import file="../objects/projectiles/bullet1/object.xml"></import>
+	<import file="../objects/projectiles/fireball/object.xml"></import>
 	<layer y_scale="1.0" y_offset="0.0" pathing="cell_edges_and_diagonals" grid_type="square" id="background" rotation="0.0" x_scale="1.0" x_offset="0.0" transparency="0">
 		<instances>
 			<i o="starfield" ns="http://www.fifengine.de/xml/tutorial" x="-2.0" r="0" y="-1.0" z="0.0"></i>
@@ -564,7 +566,7 @@
 			<i r="0" id="streaker" x="147.0" o="saucer2" z="0.0" y="4.0"></i>
 			<i r="0" id="streaker" x="147.0" o="saucer2" z="0.0" y="-5.0"></i>
 			
-			<i r="0" id="boss" x="147.0" o="saucer1" z="0.0" y="0.0"></i>
+			<i r="0" id="boss" x="147.0" o="boss1" z="0.0" y="0.0"></i>
 
 		</instances>
 	</layer>
Binary file demos/shooter/objects/projectiles/fireball/fire_ball.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/shooter/objects/projectiles/fireball/object.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -0,0 +1,4 @@
+<?fife type="object"?>
+<object id="fireball" namespace="http://www.fifengine.de/xml/tutorial" blocking="0" static="1">
+	<image source="fire_ball.png" direction="0" />
+</object>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/shooter/objects/ships/boss1/explode/animation.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -0,0 +1,9 @@
+<animation delay="200" namespace="http://www.fifengine.de/xml/tutorial" id="boss1:explode" x_offset="0" y_offset="0">
+	<frame source="boss_0.png" />
+	<frame source="boss_1.png" />
+	<frame source="boss_2.png" />
+	<frame source="boss_3.png" />
+	<frame source="boss_4.png" />
+	<frame source="boss_5.png" />
+</animation>
+
Binary file demos/shooter/objects/ships/boss1/explode/boss_0.png has changed
Binary file demos/shooter/objects/ships/boss1/explode/boss_1.png has changed
Binary file demos/shooter/objects/ships/boss1/explode/boss_2.png has changed
Binary file demos/shooter/objects/ships/boss1/explode/boss_3.png has changed
Binary file demos/shooter/objects/ships/boss1/explode/boss_4.png has changed
Binary file demos/shooter/objects/ships/boss1/explode/boss_5.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/shooter/objects/ships/boss1/flash/animation.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -0,0 +1,5 @@
+<animation delay="25" namespace="http://www.fifengine.de/xml/tutorial" id="boss1:flash" x_offset="0" y_offset="0">
+	<frame source="boss_0.png" />
+	<frame source="boss_1.png" />
+</animation>
+
Binary file demos/shooter/objects/ships/boss1/flash/boss_0.png has changed
Binary file demos/shooter/objects/ships/boss1/flash/boss_1.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/shooter/objects/ships/boss1/fly/animation.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -0,0 +1,3 @@
+<animation delay="2000" namespace="http://www.fifengine.de/xml/tutorial" id="boss1:fly" x_offset="0" y_offset="0">
+	<frame source="boss.png" />
+</animation>
Binary file demos/shooter/objects/ships/boss1/fly/boss.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demos/shooter/objects/ships/boss1/object.xml	Wed Apr 14 19:15:27 2010 +0000
@@ -0,0 +1,12 @@
+<?fife type="object"?>
+<object id="boss1" namespace="http://www.fifengine.de/xml/tutorial" blocking="0" static="0">
+	<action id="fly">
+		<animation source="fly/animation.xml" direction="0" />
+	</action>
+	<action id="explode">
+		<animation source="explode/animation.xml" direction="0" />
+	</action>
+	<action id="flash">
+		<animation source="flash/animation.xml" direction="0" />
+	</action>
+</object>
--- a/demos/shooter/scripts/scene.py	Wed Apr 14 17:42:24 2010 +0000
+++ b/demos/shooter/scripts/scene.py	Wed Apr 14 19:15:27 2010 +0000
@@ -274,10 +274,6 @@
 				self.moveObjectInScene(obj)
 
 			if obj != self._player:
-				#TODO: enemy should fire weapon in their update function
-				if obj.running:
-					obj.fire(fife.DoublePoint(-1,0))
-			
 				if obj.running and obj.boundingbox.intersects(self._player.boundingbox):
 					#player touched an enemy.  Destroy player and 
 					#re-initialize scene
--- a/demos/shooter/scripts/ships/enemies.py	Wed Apr 14 17:42:24 2010 +0000
+++ b/demos/shooter/scripts/ships/enemies.py	Wed Apr 14 19:15:27 2010 +0000
@@ -43,7 +43,13 @@
 		if action.getId() == 'explode':
 			self._ship.removeFromScene()
 			self._ship.endLevel()
-
+		elif action.getId() == 'flash':
+			if self._ship._flashnumber > 0:
+				self._ship.instance.act('flash', self._ship.instance.getFacingLocation())
+				self._ship._flashnumber -= 1	
+			else:	
+				self._ship._flashing = False
+				
 class Saucer1(Ship):
 	def __init__(self, scene, name, instance, findInstance=True):
 		super(Saucer1, self).__init__(scene, name, findInstance)
@@ -79,6 +85,9 @@
 		self._time += self._scene.timedelta
 		
 		super(Saucer1, self).update()
+	
+		self.fire(fife.DoublePoint(-1,0))		
+		
 		
 class Saucer2(Ship):
 	def __init__(self, scene, name, instance, findInstance=True):
@@ -117,6 +126,8 @@
 		
 		super(Saucer2, self).update()
 		
+		self.fire(fife.DoublePoint(-1,0))		
+		
 class DiagSaucer(Ship):
 	def __init__(self, scene, name, direction, instance, findInstance=True):
 		super(DiagSaucer, self).__init__(scene, name, findInstance)
@@ -140,6 +151,9 @@
 	def update(self):	
 		self.applyThrust(fife.DoublePoint(-0.25,self._ythrust))
 		super(DiagSaucer, self).update()
+
+		self.fire(fife.DoublePoint(-1,0))		
+
 		
 class Streaker(Ship):
 	def __init__(self, scene, name, instance, findInstance=True):
@@ -150,8 +164,8 @@
 		
 		self._maxvelocity = 2.0
 		
-		self.weapon = Cannon(self._scene, self, 2000)
-		self.weapon.projectilevelocity = 1.0
+		self.weapon = FireBall(self._scene, self, 2000)
+		self.weapon.projectilevelocity = 0.25
 		
 		self._actionlistener = EnemyActionListener(self)
 		
@@ -161,17 +175,26 @@
 	def update(self):	
 		self.applyThrust(fife.DoublePoint(-0.40,0))
 		super(Streaker, self).update()
+
+		playerloc = self._scene.player.location.getExactLayerCoordinates()
+		enemyloc = self.location.getExactLayerCoordinates()
+		
+		playerloc.x -= enemyloc.x
+		playerloc.y -= enemyloc.y
+		
+		self.fire(fife.DoublePoint(playerloc.x,playerloc.y))
+
 		
 class Boss(Ship):
 	def __init__(self, scene, name, instance, findInstance=True):
 		super(Boss, self).__init__(scene, name, findInstance)
 		self._instance = instance
-		self.width = 0.2
-		self.height = 0.2		
+		self.width = 0.85
+		self.height = 0.25		
 		
 		self._maxvelocity = 2.0
 		
-		self.weapon = Cannon(self._scene, self, 1000)
+		self.weapon = FireBall(self._scene, self, 1000)
 		self.weapon.projectilevelocity = 0.5
 		
 		self._actionlistener = BossActionListener(self)
@@ -183,4 +206,17 @@
 		self._scene.endLevel()
 		
 	def update(self):
-		super(Boss, self).update()
\ No newline at end of file
+		super(Boss, self).update()
+		
+		playerloc = self._scene.player.location.getExactLayerCoordinates()
+		bossloc = self.location.getExactLayerCoordinates()
+		
+		playerloc.x -= bossloc.x
+		playerloc.y -= bossloc.y
+		
+		self.fire(fife.DoublePoint(playerloc.x,playerloc.y))		
+		
+		
+	def applyHit(self, hp):
+		self.flash(2)
+		super(Boss, self).applyHit(hp)
\ No newline at end of file
--- a/demos/shooter/scripts/weapons.py	Wed Apr 14 17:42:24 2010 +0000
+++ b/demos/shooter/scripts/weapons.py	Wed Apr 14 19:15:27 2010 +0000
@@ -124,5 +124,23 @@
 			pjctl.run(velocity, self._ship.location)
 			self._lastfired = self._scene.time
 			self._scene.addProjectileToScene(pjctl)
-			
+
+class FireBall(Weapon):
+	def __init__(self, scene, ship, firerate):
+		super(FireBall, self).__init__(scene, ship, firerate)
+		
+		#cannon's projectile velocity
+		self._projectileVelocity = 0.50
 
+		
+	def fire(self, direction):
+		velocity = normalize(direction)
+		velocity.x = velocity.x * self._projectileVelocity
+		velocity.y = velocity.y * self._projectileVelocity
+	
+		if (self._scene.time - self._lastfired) > self._firerate:
+			pjctl = Projectile(self._scene, self._ship, "fireball", 6000 )
+			pjctl.run(velocity, self._ship.location)
+			self._lastfired = self._scene.time
+			self._scene.addProjectileToScene(pjctl)	
+