Commits

Chris Logsdon committed e643926

Created and implemented LightningBolt class;
Collision detection between bolts and enemies currently unimplemented;
Known issues with magic targeting system exist;

  • Participants
  • Parent commits 07cc95c

Comments (0)

Files changed (10)

 <!--http://www.thaumaturgistgames.com/FLAKit-->
 <library>
     <images>
+        <image>bolt.png</image>
+        <image>crosshair.png</image>
         <image>enemy.png</image>
         <image>fighterAtkWalk.png</image>
         <image>fireballShot.png</image>
         <image>icicle.png</image>
         <image>lightningBolt.png</image>
         <image>mageAtkWalk.png</image>
+        <image>mageWalk.png</image>
         <image>rogue.png</image>
         <image>rogueAtkWalk.png</image>
         <image>shuriken.png</image>

lib/bolt.png

Added
New image

lib/crosshair.png

Added
New image

lib/lightningBolt.png

Old
Old image
New
New image

obj/IfritConfig.old

     </define>
     <define append="true">
       <name>CONFIG::timeStamp</name>
-      <value>'11/4/2011'</value>
+      <value>'11/5/2011'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
-      <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src</path-element>
-      <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
+      <path-element>C:\Dev\Flash Projects\ifrit\src</path-element>
+      <path-element>C:\Program Files\FlashDevelop\Library\AS3\classes</path-element>
     </source-path>
   </compiler>
   <file-specs>
-    <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src\Game.as</path-element>
+    <path-element>C:\Dev\Flash Projects\ifrit\src\Game.as</path-element>
   </file-specs>
   <default-background-color>#FFFFFF</default-background-color>
   <default-frame-rate>30</default-frame-rate>

obj/IfritConfig.xml

     </define>
     <define append="true">
       <name>CONFIG::timeStamp</name>
-      <value>'11/4/2011'</value>
+      <value>'11/5/2011'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
-      <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src</path-element>
-      <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
+      <path-element>C:\Dev\Flash Projects\ifrit\src</path-element>
+      <path-element>C:\Program Files\FlashDevelop\Library\AS3\classes</path-element>
     </source-path>
   </compiler>
   <file-specs>
-    <path-element>C:\Users\Jake\Documents\FlashDevelop\Ifrit\src\Game.as</path-element>
+    <path-element>C:\Dev\Flash Projects\ifrit\src\Game.as</path-element>
   </file-specs>
   <default-background-color>#FFFFFF</default-background-color>
   <default-frame-rate>30</default-frame-rate>
 		public static var Mobs:Vector.<Mob>;
 		public static var Platforms:Vector.<Platform>;
 		
+		//////////////////////
+		private var boltAttack:LightningBolt;
+		private var bolting:Boolean; // Lightning bolt animation is playing
+		//////////////////////
+		
 		public function Game()	{}
 		
 		override public function init():void 
 			addWall(640, 250, false);
 			addWall(700, 320, true);
 			
+			boltAttack = null;
+			bolting = false;
+			
 			addChild(text);
 		}
 		
 		private function enterFrame(e:Event):void
 		{
-			
 			if (Input.isKeyDown(Input.LEFT))
 			{
 				man.graphic.play("walk");
 				man.shoot();
 			}
 			
+			//////////////////Magic Targeting System///////////////////
+			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);
+						addChildAt(boltAttack, 0);
+					}
+					else if (man.rotationY == 180)
+					{
+						boltAttack = new LightningBolt(false, man.x, man.y);
+						addChildAt(boltAttack, 0);
+					}
+				}
+			}
+			else
+			{
+				if (boltAttack)
+				{
+					bolting = true;
+					boltAttack.sendBolt();
+					boltAttack = null;
+				}
+			}
+			///////////////////////////////////////////////////////////
+			
 			if (Mobs.length > 0)
 			{
 				for (var l:int = Mobs.length - 1; l >= 0; l--)
 						}
 					}
 					
+					if (boltAttack)
+					{
+						//trace ("2nd: ", bolting);
+						if (Mobs[l].hitTestPoint(boltAttack.wisp.x, boltAttack.wisp.y, true))
+						{
+							//trace ("3rd: ", bolting);
+							if (bolting && !Mobs[l].friendly)
+							{
+								trace("bolt hit");
+							}
+						}
+					}
+					
 					if (removed) break;
 				}	
 			}
 					}
 				}
 			}
-			
+			//trace ("------------------------------------");
 		}
 		
 		private function addWall(x:Number, y:Number, vertical:Boolean):void

src/com/jacobalbano/Animation.as

 		 * @param	restart	Whether the named animation should restart from the beginning
 		 */
 		public function play(name:String, restart:Boolean = false):void
-		{
+		{	
 			for each (var item:Anim in this.animations) 
 			{
 				if (item.name == name)
 					}
 					
 					frameDelay = 0;
-					trace("Frame index", frame);
-					trace("Frame", this.animation.frames[frame]);
+					//trace("Frame index", frame);
+					//trace("Frame", this.animation.frames[frame]);
 				}
 				
 				setRect();

src/ifrit/LightningBolt.as

+package ifrit 
+{
+	import com.jacobalbano.Animation;
+	import com.thaumaturgistgames.flakit.Library;
+	import flash.display.Bitmap;
+	import flash.display.Sprite;
+	import flash.events.Event;
+	import flash.utils.Timer;
+	/**
+	 * ...
+	 * @author Chris Logsdon
+	 */
+	public class LightningBolt extends Sprite
+	{
+		public var wisp:Animation;
+		protected var wispC:Sprite = new Sprite();
+		
+		public var bolt:Animation;
+		protected var boltC:Sprite = new Sprite();
+		
+		public var boltHalfHeight:Number;
+		
+		private var dir:Boolean; // True = right, False = left
+		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);
+			wispC.x = -20 / 2;
+			wispC.y = -20 / 2;
+			wispC.addChild(wisp);
+			
+			addChild(boltC);
+			bolt = new Animation(Library.IMG("lightningBolt.png"), 10, 75);
+			boltC.x = -10 / 2;
+			boltC.y = -75 / 2;
+			boltHalfHeight = bolt.height / 2;
+			
+			wisp.add("wisp", [0], 12, true);
+			bolt.add("strike", [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 30, false);
+			
+			boltTime = new Timer(10, 0);
+			
+			
+			dir = direction;
+			wisp.x = x;
+			wisp.y = y;
+			
+			vx = 0;
+			if (direction)  { acceleration = 0.3; }
+			else if (!direction)  { acceleration = -0.3; }
+			
+			addEventListener(Event.ENTER_FRAME, enterFrame);
+		}
+		
+		private function enterFrame(e:Event):void 
+		{
+			vx += acceleration;
+			wisp.x += vx;
+		}
+		
+		//FIXME: Bolt child does not get removed
+		/*
+		 * Have not been able to figure out to make it work right,
+		 * so the last chunk of the animation remains on the stage.
+		 * 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();
+			bolt.x = wisp.x;
+			bolt.y = wisp.y - (bolt.height / 2);
+			this.removeChild(wispC);
+			
+			boltC.addChild(bolt);
+			bolt.play("strike");
+			//trace(boltTime.currentCount);
+			//boltTime.stop();
+			//boltTime.reset();
+		}
+		
+	}
+
+}

src/ifrit/Platform.as

 			this.x = x;
 			this.y = y;
 			
-			//TODO: Change how hor/ver walls are done?
-			/*
-			 * Make a Horizontal and Vertical wall class, and instantiate them within one Wall class?  
-			 */
 			if (vertical) this.rotation = 90;
 			else this.rotation = 0;