Commits

Chris Logsdon  committed cbeb68e

Implemented collision detection between lightning bolts and enemies;
Added wisp animation;

  • Participants
  • Parent commits e643926

Comments (0)

Files changed (4)

File lib/Library.xml

         <image>rogue.png</image>
         <image>rogueAtkWalk.png</image>
         <image>shuriken.png</image>
+        <image>wisp.png</image>
     </images>
     <sounds />
 </library>

File lib/wisp.png

Added
New image
 		//////////////////////
 		private var boltAttack:LightningBolt;
 		private var bolting:Boolean; // Lightning bolt animation is playing
+		public var boltTime:Timer = new Timer(10, 0);
+		
 		//////////////////////
 		
 		public function Game()	{}
 			}
 			
 			//////////////////Magic Targeting System///////////////////
+			//FIXME: Stop player from moving when shooting target spell
 			if (Input.isKeyDown(Input.S))
 			{
 				man.graphic.play("attack"); //TODO: Stop animation on last frame
 				if (boltAttack == null)
 				{
-					bolting = false;
 					if (man.rotationY == 0)
 					{
 						boltAttack = new LightningBolt(true, man.x, man.y);
 			{
 				if (boltAttack)
 				{
-					bolting = true;
+					boltTime.start();
 					boltAttack.sendBolt();
-					boltAttack = null;
 				}
 			}
+			if (boltTime.currentCount >= 6)
+			{
+				boltTime.stop();
+				bolting = false;
+				boltTime.reset();
+				boltAttack = null;
+			}
 			///////////////////////////////////////////////////////////
 			
 			if (Mobs.length > 0)
 									//stage.removeChild(Mobs[l]);
 									//Mobs.splice(l, 1);
 									Mobs[l].hitpoints -= 5;
-									trace("hit");
+									trace("shuriken hit");
 									
 									removed = true;
 									
 						}
 					}
 					
-					if (boltAttack)
+					if (boltAttack && boltTime.running)
 					{
-						//trace ("2nd: ", bolting);
-						if (Mobs[l].hitTestPoint(boltAttack.wisp.x, boltAttack.wisp.y, true))
+						bolting = true;
+						
+						if (boltTime.currentCount >= 4)
 						{
-							//trace ("3rd: ", bolting);
-							if (bolting && !Mobs[l].friendly)
+							if (bolting && Mobs[l].hitTestObject(boltAttack.bolt))
 							{
-								trace("bolt hit");
+								if (!Mobs[l].friendly)
+								{
+									trace("bolt hit")
+									Mobs[l].hitpoints -= 10;
+								}
 							}
 						}
 					}
 					}
 				}
 			}
-			//trace ("------------------------------------");
 		}
 		
 		private function addWall(x:Number, y:Number, vertical:Boolean):void

File src/ifrit/LightningBolt.as

 		private var vx:Number;
 		private var acceleration:Number;
 		
-		public var boltTime:Timer;
-		
 		public function LightningBolt(direction:Boolean, x:Number, y:Number) 
 		{
 			addChild(wispC);
-			wisp = new Animation(Library.IMG("crosshair.png"), 20, 20);
+			wisp = new Animation(Library.IMG("wisp.png"), 15, 15);
 			wispC.x = -20 / 2;
 			wispC.y = -20 / 2;
 			wispC.addChild(wisp);
 			boltC.y = -75 / 2;
 			boltHalfHeight = bolt.height / 2;
 			
-			wisp.add("wisp", [0], 12, true);
+			wisp.add("wisp", [0, 1, 2, 3], 10, true);
 			bolt.add("strike", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 30, false);
-			
-			boltTime = new Timer(10, 0);
-			
+			wisp.play("wisp", true);
 			
 			dir = direction;
 			wisp.x = x;
 		 * You can see this by the small yellow specks that remain
 		 * afterwards.
 		 */
-		//TODO: Figure out how what is being done wrong with the timer
 		public function sendBolt():void
 		{
-			boltTime.start();
+			vx = 0;
 			bolt.x = wisp.x;
 			bolt.y = wisp.y - (bolt.height / 2);
-			this.removeChild(wispC);
+			
+			if (this.contains(wispC)) this.removeChild(wispC);
 			
 			boltC.addChild(bolt);
 			bolt.play("strike");
-			//trace(boltTime.currentCount);
-			//boltTime.stop();
-			//boltTime.reset();
 		}
 		
 	}