Commits

Anonymous committed c29734c

dirty panel done

Comments (0)

Files changed (6)

 		public static var levelArr:Array = [
 			Level0,
 			Fan, // most easy
+			Hole,
 			Hexagon,
-			Hole,
+			Bounce,
+			VStripe,
 			Xlash,
+			CornerFan,
 			Stripe,
-			VStripe,
+			Grid,
 		];
 		
 		
 		private static const WAIT_PHASE:int = 1;
 		private static const PLAY_PHASE:int = 2;
 		private static const HOLD_PHASE:int = 3;
+		private static const GAME_OVER:int  = 4;
 		
 		private var _bgplain:BgPlain;
 		private var _bgstripe:Entity;
+		private var _panel:Panel;
 		
 		private var _phase:int;
 		private var _framecnt:int;
 		private var _curlevel:LevelBase;
 		private var _curwave:int;
 		private var _curolist:Vector.<Obj>;
+		private var _levelix:int;
 		
-		private var _tline:Line;
+		private var _tline:Line; // temp pointer
+		
 		
 		override public function begin():void
 		{
 			
 			_bgplain = new BgPlain();
 			_bgstripe = new Entity(0, 0, new Backdrop(Au.ImgBg));
+			_panel = new Panel();
 			
 			add(_bgplain);
 			add(_bgstripe);
 			Indicator.staticInit(this);
 			Hurter.staticInit(this);
 			
-			// debug calls
-			switchLevel(new VStripe);
+			add(_panel);
+			
+			// init
+			_levelix = 0;
+			switchLevel(new (Au.levelArr[_levelix]));
 			switchPhase(INDI_PHASE);
+			
+			// debugs
+			//switchLevel(new Grid);
 //			FP.console.enable();
 		}
 	
 						_levellength = _curolist.length;
 //						trace(_curwave);
 					} else {
-						switchLevel(new VStripe);
+						if (_levelix++ < Au.levelArr.length) {
+							switchLevel(new (Au.levelArr[_levelix]));
+						} else {
+							// game is done!
+							FP.world = new MenuWorld();
+						}
 					}
 					switchPhase(INDI_PHASE);
 				}
 				FP.camera.y = (Math.random()*_intense*Au.HEIGHT*2-_intense*Au.HEIGHT);
 			}	
 		}
+		
+		public function showPanel(Hearts:int, Congrats:Boolean=false):void
+		{
+			if (Congrats) {
+				_panel.show(8, true);
+			} else {
+				_panel.show(7 - Hearts, Hearts == 0 ? true: false);
+			}
+		}
 	}
 }
+package
+{
+	import net.flashpunk.World;
+	
+	public class MenuWorld extends World
+	{
+		public function MenuWorld()
+		{
+			super();
+		}
+	}
+}
+package
+{
+	import net.flashpunk.Entity;
+	import net.flashpunk.Graphic;
+	import net.flashpunk.Mask;
+	import net.flashpunk.graphics.Spritemap;
+	
+	public class Panel extends Entity
+	{
+		[Embed(source = 'data/panel.png')]
+		public static const ImgPanel:Class;
+		
+		private var showarr:Array = [
+			-12, -10, -8, -6, -4, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+			 -2,  -4, -8, -10, -12,
+		];
+		
+		public var spr:Spritemap;
+		private var _showix:int = 0;
+		private var _show:Boolean = false;
+		private var _persistshow:Boolean = false;
+		
+		public function Panel()
+		{
+			spr = new Spritemap(ImgPanel, 96, 12);
+			super(0, -12, spr);
+		}
+		
+		public function show(Frame:int, Persist:Boolean):void
+		{
+			_show = true;
+			_persistshow = Persist;
+			_showix = 0;
+			spr.frame = Frame;
+		}
+		
+		override public function update():void
+		{
+			if (_show) {
+				y = showarr[_showix++];
+				if (_persistshow && _showix >6) _show = false;
+				else if (_showix == showarr.length) _show = false;
+			}
+			super.update();
+		}
+	}
+}
 			if (_player.active && collideWithEx(_player)) { 
 				// TODO die/hurt here
 				FP.console.log(Au._cnter++);
-				GameWorld.player.kill();
-				GameWorld.gworld.quake(20);
+				_player.kill();
+				GameWorld.gworld.quake(15);
+				GameWorld.gworld.showPanel(7 - _player.deathcount);
 			}
 			super.update();
 		}
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.