Commits

Chris Logsdon committed 854306c

Made vy var in Man class static, and deleted jumpReset() function.
Put speed limit checks outside of jumping function
Made separate X and Y speed limit variables for a more realistic falling speed.
Fixed bug where player couldn't sit on top of vertical walls.
Fixed bug where player was able to jump in-air after walking off a platform.

Comments (0)

Files changed (5)

obj/IfritConfig.old

     </define>
     <define append="true">
       <name>CONFIG::timeStamp</name>
-      <value>'10/29/2011'</value>
+      <value>'10/30/2011'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
-      <path-element>C:\Users\Jake\Documents\New folder\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\New folder\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>'10/29/2011'</value>
+      <value>'10/30/2011'</value>
     </define>
     <verbose-stacktraces>true</verbose-stacktraces>
     <source-path append="true">
-      <path-element>C:\Users\Jake\Documents\New folder\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\New folder\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>
 			
 			Input.init(stage);
 			
-			man = new Man(50, 260);
+			man = new Man(420, 0);
 			addChild(man);
 			
 			addChild(new HorizontalWall(man, 250, 375, false));
 			addChild(new HorizontalWall(man, 170, 320, false));
 			addChild(new HorizontalWall(man, 30, 280, false));
 			addChild(new HorizontalWall(man, 310, 250, false));
-			addChild(new HorizontalWall(man, 640, 250, false));
+			addChild(new HorizontalWall(man, 660, 250, false));
 			addChild(new HorizontalWall(man, 700, 320, true));
 			
 			addChild(text);
 			if (Input.isKeyDown(Input.SPACE))	Man.SB = true;
 			else Man.SB = false;
 			
-			if (Input.isKeyDown(Input.D)) // 'D' key
+			if (Input.isKeyDown(Input.D))
 			{
 				shootTiming();
 			}

src/ifrit/HorizontalWall.as

 	import flash.display.Sprite;
 	import flash.events.Event;
 	
+	
+	//TODO: block any and all objects
+	/*
+	 * Put all objects into an array and have each wall 
+	 * block every element in that object array
+	 */
 	public class HorizontalWall extends Sprite
 	{		
 		public var hWall:Bitmap = Library.IMG("horizontal.png");
 			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;
 			
 			{
 				if (this.rotation == 0)
 				{
-					if (obj.y <= this.y) // top
+					if (obj.y < this.y) // top
 					{
 						obj.y -= oy;
 						Man.gravUp = false;
 						Man.jumpTimer.reset();
 					}
-					else if (obj.y >= this.y) // bottom
+					else if (obj.y > this.y) // bottom
 					{
+						Man.vy = 0;
 						obj.y += oy;
-						(obj as Man).jumpReset();
 					}
 					else if (obj.x <= this.x) obj.x -= ox; // left
 					else if (obj.x >= this.x) obj.x += ox; // right
 				}
 				else 
 				{
-					if (obj.x <= this.x) obj.x -= ox; // left
-					else if (obj.x >= this.x) obj.x += ox; // right
+					if (obj.x < this.x) obj.x -= ox; // left
+					else if (obj.x > this.x) obj.x += ox; // right
 					else if (obj.y <= this.y) // top
 					{
 						obj.y -= oy;
 					else if (obj.y >= this.y) // bottom
 					{
 						obj.y += oy;
-						(obj as Man).jumpReset();
+						Man.vy = 0;
 					}
 				}
 			}
 	}
 }
 
-//BUG: Strange results if player touching >1 platform at a time
+//BUG: player forced down if touching >1 platform at a time
 /*
  * 
  */
 		private var man:Bitmap = Library.IMG("rogue.png");
 		private var manC:Sprite = new Sprite;
 		
-		private var vx:Number;
-		private var vy:Number;
-		private var speedLimit:Number;
+		public static var vx:Number;
+		public static var vy:Number;
+		private var speedLimitX:Number;
+		private var speedLimitY:Number;
 		
 		public static var gravity:Number;
 		
 		public function Man(x:Number, y:Number) 
 		{
 			addChild(manC);
-			manC.x = man.x - (man.width / 2); // Set registration point to center
+			manC.x = man.x - (man.width / 2);
 			manC.y = man.y - (man.height / 2);
 			man.smoothing = true;
 			manC.addChild(man);
 			
 			vx = 0;
 			vy = 0;
-			speedLimit = 7;
+			speedLimitX = 7;
+			speedLimitY = 20;
 			gravity = 1;
 			
 			addEventListener(Event.ENTER_FRAME, onEnterFrame);
 		}
 		
-		//TODO: Make vy static var and reset from HorizontalWall class?
-		/*
-		 * Took out any tweaking of Man.jumpTimer() because it either reset at an
-		 * inappropriate time, or it never reached it's repeat count (2). This cause the
-		 * sticking to bottoms of platforms while Spacebar was down. In order to jump,
-		 * the following must be true: currentCount < repeatCount. (see enter frame function).
-		 */
-		public function jumpReset():void
-		{
-			vy = 0;
-		}
-		
 		
 		//BUG: Upward thrust when player hits corner of platform
 		private function onEnterFrame(e:Event):void
 			else vy = 0;
 			
 			// Jump(rise) until spacebar up or until timer ends.
-			if (SB && jumpTimer.currentCount < jumpTimer.repeatCount)
+			if (SB && jumpTimer.currentCount < jumpTimer.repeatCount && vy <= 1)
 			{
 				if (!jumpTimer.running) {  jumpTimer.start();  }
 				
 				vy += -5;
-				
-				if (vx >= speedLimit) {	vx = speedLimit; }
-				if (vx < -speedLimit) {	vx = -speedLimit; }
-				if (vy >= speedLimit) {	vy = speedLimit; }
-				if (vy < -speedLimit) {	vy = -speedLimit; }
-				
 			}
 			if (jumpTimer.currentCount == jumpTimer.repeatCount) {  jumpTimer.stop();  }
 			
+			if (vx >= speedLimitX) {  vx = speedLimitX;  }
+			if (vx < -speedLimitX) {  vx = -speedLimitX;  }
+			if (vy >= speedLimitY) {  vy = speedLimitY;  }
+			if (vy < -speedLimitY) {  vy = -speedLimitY;  }
+			
 			// Apply physics to player movement
 			this.x += vx;
 			this.y += vy;
 			// Stage boundaries
 			var thisHalfW:uint = (this.width / 2);
 			var thisHalfH:uint = (this.height / 2);
-			if (this.x + thisHalfW > stage.stageWidth) {  this.x = stage.stageWidth - thisHalfW;  }
-			if (this.x - thisHalfW < 0) {  this.x = 0 + thisHalfW;  }
+			if (this.x + thisHalfW > stage.stageWidth)
+			{
+				this.x = stage.stageWidth - thisHalfW;
+				vx = 0;
+			}
+			if (this.x - thisHalfW < 0)
+			{
+				this.x = 0 + thisHalfW;
+				vx = 0;
+			}
 			if (this.y + thisHalfH > stage.stageHeight)
 			{
-				vx = 0;
 				vy = 0;
 				this.y = stage.stageHeight - thisHalfH;
 				
-				jumpTimer.reset(); // Reset when on floor, to avoid constant jumping in air
+				jumpTimer.reset();
 			}
 			if (this.y - thisHalfH < 0)
 			{
-				vx = 0;
 				vy = 0;
 				this.y = 0 + thisHalfH;
 			}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.