(function() {
			
				var level1 = [  
						[ [12,25], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [14,23], [12,26] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [9,35], [9,36], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,24], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [9,34], [9,34], [9,34], [9,34], [9,34], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [10,35], [10,36], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,22] ],
						[ [13,25], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [12,23], [13,26] ]
				];
			
				function NinjaGame() {
				
					//Example of BasicNinja Class and GameSkeleton quick game setup.  wall jumps, wall slides, and double jumps.
					var gameSpecs = { 
						gWidth:640, gHeight:320,cameraWidth:320, cameraHeight:320, 
						cameraFollowOffsetX:-160, cameraFollowOffsetY:0,  tileW:16, tileH:16, 
						spriteSheetImage: "firstNinja.png", containerDivId:"container", rootDivId:"root",
						controllerDivId:"controller", gameScale:0, useScreenOrganizer:true,startWidth:50, startHeight:25,
						controllerHeight:144, initialLives:3, initPlayerPosition:new tabageos.MoverPoint(32,104), 
						gameLoop:this.loop,initializationSpecifics:this.specificInitializations, 
						addedResizeMethod:null, sceneResetSpecifics:null,fullResetSpecifics:null, additionalSceneResetSpecifics:null, 
						positionResetSpecifics:null, cameraType:1, backgroundColor:"#6495ed" 
					};

					tabageos.GameSkeleton.call(this,  gameSpecs);
					
					this.enableGamePad = 1;
					this.establishKeyEventsForReset();
					
				}
	
				NinjaGame.prototype = Object.create(tabageos.GameSkeleton.prototype);
				
				NinjaGame.prototype.specificInitializations = function() {
				
					//inside these functions we have references inherited from GameSkeleton using 'this'.
					
					//in this example i've layed out the background as a whole section in the sprite sheet.
					//another option would be to make a pattern for the background, like level1, and use BlitMath to draw it onto backgroundLayer.
					//by default the background is just a solid color, this is one way to draw something onto it.
					this.backgroundLayer.copyPixels(this._image, new tabageos.Rectangle(0, 768, 640, 320), new tabageos.MoverPoint());
				
					tabageos.BlitMath.specificPatternBlit(this.display, this._image, level1);//drawing of the level.
				
					var playerAnimation = new tabageos.CanvasAnimation(this._image, this.charLayer,null,0,0,16,16);
					
					playerAnimation.defineAnimation("left", [4,26,6,26,8,26,10,26,12,26,14,26,16,26,18,26,20,26,22,26,24,26,26,26]);
					playerAnimation.defineAnimation("right", [4,22,6,22,8,22,10,22,12,22,14,22,16,22,18,22,20,22,22,22,24,22,26,22]);
					playerAnimation.defineAnimation("up", [4,16]);
					playerAnimation.defineAnimation("upright", [4,16]);
					playerAnimation.defineAnimation("upleft", [8,16]);
					playerAnimation.defineAnimation("down", [4,18]);
					playerAnimation.defineAnimation("downright", [4,18]);
					playerAnimation.defineAnimation("downleft", [8,18]);
					playerAnimation.defineAnimation("onwallright", [4,8]);
					playerAnimation.defineAnimation("onwallleft", [4,12]);
					playerAnimation.defineAnimation("rightidle", [4,30]);
					playerAnimation.defineAnimation("leftidle", [4,34]);
					playerAnimation.defineAnimation("flip", [4,4,6,4,8,4,10,4,12,4,14,4]);
					playerAnimation.defineAnimation("flipright", [4,4,6,4,8,4,10,4,12,4,14,4]);
					playerAnimation.defineAnimation("flipleft", [4,4,6,4,8,4,10,4,12,4,14,4]);
					
					playerAnimation.fromWidthOffset = 16;
					playerAnimation.fromHeightOffset = 16;
					
					playerAnimation.currentAnimation = "left";
					playerAnimation.animate();
					
					this.removeHUD();
				
					this.player = new tabageos.BasicNinja(32,104,16,16,level1, playerAnimation, 1, 0, 16,16);//Ninjas wall jump and double jump.
					this.player._autoAnimate = 1;//the playerAnimation will automatically use changeDirectionAnimation and animate and blitt at the end of player move calls.
					
				};
				
				NinjaGame.prototype.loop = function() {
					
					//we dont have to do anything much in the loop, just that player is a BasicNinja it will now wall jump and double jump.
					this.player.move(this.controller.buttons.left, this.controller.buttons.right,this.controller.buttons.up || this.controller.buttons.a, this.controller.buttons.down);
				
					//one option for manual animation and blitting, this is what is called for us when we set the _autoAnimate property of the BasicNinja class.
					//your free to change the _canvasAnimation currentAnimation property however you need and then call animate, then blit to draw it.
					//changeDirectionAnimation is one of the methods that changes the currentAnimation property for us based on the direction that the player is currently moving.
					/*this.player._canvasAnimation.x = this.player.x;
					this.player._canvasAnimation.y = this.player.y;
					
					this.player._canvasAnimation.changeDirectionAnimation(this.player._veloc.x < 0,this.player._lastVeloc.x > 0, this.player._veloc.y < 0, this.player._veloc.y > 0);
					
					this.player._canvasAnimation.animate();
					this.player._canvasAnimation.blitt();*/
					//setting _autoAnimate does the above for us.
					
				};
			
				new NinjaGame();//constructing the NinjaGame class starts everything.
				
			})();
		
		
		


back to top