Top down shooter example.
The art used is the vacaroxa generic old west graphics.
Use wasd to walk around. Use the mouse to aim and shoot.
Click here for full screen

(function() {


	//these arrays can be created from art using the array maker tool found here https://www.tabageos.com/fromArtToCode .
	var map = [
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [27,1], [27,2], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10] ],
[ [4,10], [4,10], [4,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [28,1], [28,2], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [4,10] ],
[ [4,10], [4,10], [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [2,2], [2,2], [2,2], [2,2], [2,2], [6,12], [6,12], [4,10] ],
[ [4,10], [4,10], [4,10], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [0,0], [0,0], [0,0], [2,2], [2,2], [2,2], [2,2], [2,2], [6,12], [6,12], [4,10] ],
[ [4,10], [4,10], [4,10], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [2,2], [2,2], [2,2], [2,2], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [5,10], [5,10], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [2,2], [2,2], [2,2], [6,12], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [40,3], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [40,3], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [6,12], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [0,0], [0,0], [6,12], [6,12], [6,12], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [28,5], [6,12], [6,12], [6,12], [21,2], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [28,5], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [28,5], [6,12], [6,12], [6,12], [21,2], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [28,5], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [28,5], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [2,2], [2,2], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [6,12], [40,3], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [28,5], [28,5], [6,12], [6,12], [6,12], [21,2], [6,12], [6,12], [6,12], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [2,2], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [28,5], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [2,2], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [2,2], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [6,12], [6,12], [0,0], [6,12], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [11,4], [11,5], [11,5], [11,5], [11,5], [11,5], [11,5], [11,5], [11,5], [11,6], [0,0], [0,0], [0,0], [6,12], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [2,2], [2,2], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [12,4], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,6], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [40,3], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [12,4], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,6], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [12,4], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,5], [12,6], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [13,4], [13,5], [13,5], [13,5], [13,5], [13,5], [13,5], [13,5], [13,5], [13,6], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [6,12], [0,0], [4,10] ],
[ [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [6,12], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [0,0], [4,10] ],
[ [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10], [4,10] ],
[ [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10], [5,10] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ]
  ];


  var b1 = [
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [11,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [8,11], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [11,11], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [8,7], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [7,8], [7,9], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [8,13], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [8,8], [8,9], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [8,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [9,12], [11,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [11,8], [11,9], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [12,8], [12,9], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [11,11], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [12,7], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [11,10], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [12,7], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12] ],
[ [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [6,12], [12,7], [6,12] ]
  ];

	var exF;
	var pmp = new tabageos.MoverPoint();
	var bullets =[];
	var pBulletThrott = 300;
	var eBulletThrott = 400;
	var gun;
	var enemies = [];
	var portals = [];
	var crates = [];
	var chests = [];

	var rightGunFace = new tabageos.Rectangle(400,64,96,96);
	var leftGunFace = new tabageos.Rectangle(544,64,96,96);

	function ThreeSixtyShooter() {

		//the games using one of the Rotating Classes work easiest at either no scale or full scale.
		//to get them to work at some scale in between we'd have to calculate the difference in scale and camera cords and add that to the mouseMoveOffset.
		var gameSpecs = {
			gWidth:800, gHeight:480,cameraWidth:400, cameraHeight:480,
			cameraFollowOffsetX:-200, cameraFollowOffsetY:0,  tileW:16, tileH:16,
			spriteSheetImage: "sheetWest360.png", containerDivId:"container", rootDivId:"root",
			controllerDivId:"controller", gameScale:0, hudScale:4,useScreenOrganizer:true,startWidth:50, startHeight:25,
			controllerHeight:144, initialLives:3, initPlayerPosition:new tabageos.MoverPoint(164,164),
			gameLoop:this.loop,initializationSpecifics:this.setup, disableBackgroundAlpha:0,useSceneChanger:0,
			addedResizeMethod:null, sceneResetSpecifics:null,fullResetSpecifics:null, additionalSceneResetSpecifics:null,
			positionResetSpecifics:null, cameraType:1, backgroundColor:"#c8c8c8"
		};

		tabageos.GameSkeleton.call(this,  gameSpecs);
		
		this.dontResizeVertical = 1;//this together with a gameScale of 4, the game is at its original size.
		//a gameScale of 0 means to not scale the game at all, it does not get touched.
		//so setting the gameScale from 0 to 1 to goto fullScreen works, but setting it back to 0 does nothing to the scale.
		//so if we intend to be able to go from fullscreen and back we have to set the scale to something.
		//but if we don't actually want to scale the game, then the scale we choose needs to match the dimensions of the game.
		//to help with that we can set dontResizeVertical or dontResizeHorizontal ,not both, so that only one portion gets scaled.
		//in this case at gameScale of 4 it happens to be exactly at the same dimensions as no scale, in other cases it may need to be something like 2.895 or such.
		//all of this is only needed if you need to be able to go from fullscreen and back yourself.
		//for many game portals your game will be in its own iframe or page, so just letting gameScale be 1 would let it fit to the dimensions of that iframe or page.
		
		
	}

	ThreeSixtyShooter.constructor = ThreeSixtyShooter;
	ThreeSixtyShooter.prototype = Object.create(tabageos.GameSkeleton.prototype);


	ThreeSixtyShooter.prototype.setup = function(sax,say) {
		this.lives = 3;

		this.title.floor.context.fillStyle = "#ffffff";
		this.title.floor.context.fillRect(0,0,1280,128);


		tabageos.BlitMath.ignoredArrays = [ [40,3],[2,2],[21,2],[28,5] ];//values to be ignored during specificPatternBlit.

		tabageos.BlitMath.specificPatternBlit(this.display, this._image, b1, 16,16);//drawing of background onto display layer.

		tabageos.BlitMath.specificPatternBlit(this.display, this._image, map, 16,16);//drawing of scene onto display layer.

		var playerAnimation = new tabageos.CanvasAnimation(this._image,this.charLayer,null,0,0,16,16);
		//the inner arrays define x,y frame index location. x*playerAnimation.width y*playerAnimation.height and potential offsets.
		playerAnimation.animationSpecs = { 
			"left":[70, [22,70,22,70,22,70,22,70,19,70,19,70,19,70,19,70,16,70,16,70,16,70,16,70,13,70,13,70,13,70,13,70,10,70,10,70,10,70,10,70,7,70,7,70,7,70,7,70,4,70,4,70,4,70,4,70,1,70,1,70,1,70,1,70] ],
			"right":[63, [1,63,1,63,1,63,1,63,4,63,4,63,4,63,4,63,7,63,7,63,7,63,7,63,10,63,10,63,10,63,10,63,13,63,13,63,13,63,13,63,16,63,16,63,16,63,16,63,19,63,19,63,19,63,19,63,22,63,22,63,22,63,22,63] ],
			"up":[70, [22,70,22,70,22,70,22,70] ],
			"down":[63, [1,63,1,63,1,63,1,63] ],
			"upleft":[70, [22,70,22,70,22,70,22,70,19,70,19,70,19,70,19,70,16,70,16,70,16,70,16,70,13,70,13,70,13,70,13,70] ],
			"upright":[63, [1,63,1,63,1,63,1,63,4,63,4,63,4,63,4,63,7,63,7,63,7,63,7,63,10,63,10,63,10,63,10,63] ],
			"downleft":[70, [22,70,22,70,22,70,22,70] ],
			"downright":[63, [1,63,1,63,1,63,1,63] ],
			"rightidle":[60, [1,60,1,60,1,60,1,60,4,60,4,60,4,60,4,60,7,60,7,60,7,60,7,60,10,60,10,60,10,60,10,60,13,60,13,60,13,60,13,60,16,60,16,60,16,60,16,60] ],
			"leftidle":[67, [22,67,22,67,22,67,22,67,19,67,19,67,19,67,19,67,16,67,16,67,16,67,16,67,13,67,13,67,13,67,13,67,10,67,10,67,10,67,10,67,7,67,7,67,7,67,7,67] ],
			"upidle":[67, [22,67,22,67,22,67,22,67] ],
			"downidle":[67, [22,67,22,67,22,67,22,67] ],
			"idle":[67, [22,67,22,67,22,67,22,67] ]
		};
		playerAnimation.currentAnimation = "right";
		playerAnimation.fromWidthOffset = 16;//offset the amount to draw by 16, so start from a 16x16 spot but draw 32x32.
		playerAnimation.fromHeightOffset = 16;//there is also fromXOffset and fromYOffset that would offset where to draw from.
		//using these offsets the playerAnimation can be defined as the same width and height as the player.
		//and yet the animation can be bigger/smaller than the players collision area.



		//the player is just a MapTraveler.
		this.player = new tabageos.MapTraveler(164,198,16,16,map,playerAnimation,0,0,16,16,map.length,map[0].length);

		this.player._gravityLevel = .285;
		this.player._jumps = 0;//0 for no gravity.
		//this player._autoAnimate = 1;//we will animate it ourselves with just left right and idle animations.
		this.resizeRootForNoTouch = 1;
		this.charLayer.context.fillStyle = "#6495ed";
		this.controller.basicArrows.d = 69;
		this.controller.basicWasd.d = 69;

		
		//let the player walk over ground tiles and other tiles we want it to pass.
		this.player._map = tabageos.BlitMath.replaceValuesFromMultiArray(this.player._map, [ [6,12],[10,6], [9,6] ,[9,11],[10,11] ,[9,9],  [40,3],[11,4], [11,5], [11,6], [12,4], [12,5], [12,6], [13,4], [13,5], [13,6] ],0,0);



		var rotationImage = new tabageos.CanvasObject(null,96,96);//the offscreen rotation image for the gun.

		var wd = new tabageos.WayDeterminer(0,null);
		wd._defaultReturn = true;//a defaulted WayDeterminer, we wont actually be using it, WayDeterminer is for pixel collision detection.

		//just the gun is a RotatingShooter, and because we pass a map array at the end, the bullets shot will be MapTravelers instead of BlittedTravelers.
		gun = new tabageos.RotatingShooter(wd,this._image,this.charLayer,null,0,0,32,32, rotationImage, rightGunFace,this.charLayer,new tabageos.Rectangle(576,0,16,16), this.player._map);


		exF = new tabageos.ExplosionFactory(16,16,9,608,0);//many quick animations, all horizontal in the sprite sheet, all from a default location if not specified otherwise.

		var goDiv = document.createElement("div");
		goDiv.setAttribute("style", "position:absolute;font-family: 'soupoj', sans-serif;width:640px;color:black;text-align:center");
		goDiv.innerHTML = "<h2>Game Over</h2><br /><span style='cursor:pointer' onclick='tabageos.GameSkeleton.game.hudExit()'>Press Start</span>";
		this.gameOverContainer.div.appendChild(goDiv);

		//we call setupMouseTouchHandle passing 1 to also handle mouse/touch down, which we access via the mouseIsDown property.
		this.setupMouseTouchHandle(1);

		if(tabageos.seekTouch()) {
			this.controller._basicControllerButtonTakedown();
			this.controller.rotationalControllerButtonSetup();//setup rotation controller for touch rotation.

		}
		
		this.beforeStartGameLoop = function() {
			
			this.controller.centerRotationX = ((window.innerWidth/2) - 200) + 64;
			this.controller.centerRotationY = 480 + 64;
			
		};
		this.mouseMoveOffset = 32;//default is 32.


		tabageos.BlitMath.functionAssignments = [[40,3],  [28,5], [2,2], [21,2]];
		//calls the portalsAndCoins function every time one of the functionAssignments is found in the map.
		tabageos.BlitMath.dispatchFunctionAssignments(new tabageos.EventDispatcher(),"portalsAndCoins",this,map,16,16);
		//its not recursive its done with events.

	};
	
	
	ThreeSixtyShooter.prototype.gotoFullScreen = function() {
		
		if(this.gameScale != 1) {
			
			
			document.getElementById("thecode").style.display = "none";
			
			this.dontResizeVertical = 0;
			this.gameScale = 1;
			this.__instanceBasicTwoLayerResize();
			
			
			this.controller.centerRotationX = 0 + 64;
			if(this._scaleRectRef.height) {
				//these numbers must be tested and arrived at via dev tools.
				this.controller.centerRotationY = ( 480 + (this._scaleRectRef.height/(this._scaleRectRef.height/480)) ) - 240;
			} else {
				this.controller.centerRotationY = 480 + 64;
			}
			
			this.screenOrganizer.currentScreen = -1000;//by default when esc is pressed a simple reset happens if the screen is 1.
			//so we just manually set the screen to some number that is not 1 or 2.
			//in this manner we prevent the default esc press behavior.
			//but typically the currentScreen property is changed automatically.
			
			document.getElementById("container").style.position = "absolute";
			
			window.addEventListener('keyup', this._fullScreenEvent, false);
			
			
		}
		
		
	};
	
	ThreeSixtyShooter.prototype._fullScreenEvent = function(e) {
		if(e.keyCode === 27) {
			tabageos.GameSkeleton.game.escFromFullScreen(1);
		}
	}
	
	ThreeSixtyShooter.prototype.escFromFullScreen = function(e) {
		
		if(this.gameScale != 0) {
			
			document.getElementById("thecode").style.display = "block";
			
			this.dontResizeVertical = 1;
			this.gameScale = 4;
			this.__instanceBasicTwoLayerResize();
			
			this.controller.centerRotationX = ((window.innerWidth/2) - 200) + 64;
			
			this.controller.centerRotationY = 480 + 64;
			
			this.screenOrganizer.currentScreen = 1;
			
			document.getElementById("container").style.position = "relative";
			
			window.removeEventListener('keyup', this._fullScreenEvent, false);
			
		}
		
		
	};
	
	ThreeSixtyShooter.prototype.portalsAndCoins = function(e) {//e is a PatternActionEvent with properties about the tile that caused the event.


		if(e.tileValue[0] == 40 && e.tileValue[1] == 3) {//create a portal for each 40,3 tile in the map.

			portal = new tabageos.CanvasAnimation(tabageos.GameSkeleton.game._image,tabageos.GameSkeleton.game.charLayer,null,e.x,e.y,16,16);
			portal.animationSpecs = {
				"idle":[31, [13,31]],
				"spawn":[31, [13,31,13,31,13,31,13,31,16,31,16,31,16,31,16,31,19,31,19,31,19,31,19,31,19,31,19,31,19,31,19,31,22,31,22,31,22,31,22,31,22,31,22,31,22,31,22,31] ]};
			portal.currentAnimation = "idle";
			portal.fromWidthOffset = 32 - 16;
			portal.fromHeightOffset = 32 - 16;

			portals.push(portal);

		}
		if(e.tileValue[0] == 28 && e.tileValue[1] == 5) {//place a crate for each 28,5 tile in the map

			//crates.

			var crate  = new tabageos.CanvasAnimation(tabageos.GameSkeleton.game._image,tabageos.GameSkeleton.game.charLayer,null,e.x,e.y,16,16);
			crate.animationSpecs = {
				"idle":[40, [5,28]],
				"hit1":[40, [5,26]],
				"hit2":[40, [7,26]],
				"hit3":[40, [9,26]],
			};
			crate.currentAnimation = "idle";
			crate.x = e.x; crate.y=e.y;
			crates.push(crate);


		}

		if(e.tileValue[0] == 2 && e.tileValue[1] == 2) {
			//coins.
			tabageos.GameSkeleton.game.player._map[e.tileYIndex][e.tileXIndex] = [0,0];

		}

		if(e.tileValue[0] == 21 && e.tileValue[1] == 2) {

			//chests.
			tabageos.GameSkeleton.game.player._map[e.tileYIndex][e.tileXIndex] = [0,0];
		}

	};


	ThreeSixtyShooter.prototype.spawnEnenmy = function(x,y) {
		var eca = new tabageos.CanvasAnimation(this._image,this.charLayer,null,x,y,16,16);
		eca.animationSpecs = {
			"right":[7, [1,7,1,7,1,7,1,7,2,7,2,7,2,7,2,7,3,7,3,7,3,7,3,7,4,7,4,7,4,7,4,7,5,7,5,7,5,7,5,7] ],
			"left":[7, [1,7,1,7,1,7,1,7,2,7,2,7,2,7,2,7,3,7,3,7,3,7,3,7,4,7,4,7,4,7,4,7,5,7,5,7,5,7,5,7] ]

		};
		eca.currentAnimation = "left";
		var en = new tabageos.MapTraveler(x,y,16,16,this.player._map,eca,1);
		en.setX(x);en.setY(y);
		en.health = 3;
		en.maxSpeed = 5;
		en.maxForce = 8;
		enemies.push(en);
	}

	ThreeSixtyShooter.prototype.loop = function() {
		var cb = this.controller.buttons;

		this.player.move(cb.left,cb.right,cb.up,cb.down);

		gun.setX( this.player.x - 8 );//set the gun to be in middle of player
		gun.setY( this.player.y - 16 );

		if(!this.device) {
			gun.rotateWithMoverPoint(this.mousePoint, 32,32);//gun rotates with the mouse/ desktop touch/pointer.
		} else {
			gun.setRotation(this.controller.rotation);//rotation controllerpad, true touch device, phones/tablets.
		}


		var gr = gun.getRotation();var pidle="";
		if(gr < -90 || gr > 90) {//when rotated to the left side, change to keep hands under gun.
			gun.rFromRect = leftGunFace;//this is how to change what the rotation image is on the fly, just change the rFromRect.
			pidle = (this.player._veloc.x == 0 && this.player._veloc.y == 0) ? "idle" : "";  //change animation to left or leftidle.
			this.player._canvasAnimation.currentAnimation = "left"+pidle;

			this.player._canvasAnimation.x = this.player.x;this.player._canvasAnimation.y = this.player.y;
			this.player._canvasAnimation.animate(.5);  //animate and blit.
			this.player._canvasAnimation.blit();
		} else {
			gun.rFromRect = rightGunFace;
			pidle = (this.player._veloc.x == 0 && this.player._veloc.y == 0) ? "idle" : ""; //change animation to right or rightidle.
			this.player._canvasAnimation.currentAnimation = "right"+pidle;

			this.player._canvasAnimation.x = this.player.x;this.player._canvasAnimation.y = this.player.y;
			this.player._canvasAnimation.animate(.5);//animate and blit.
			this.player._canvasAnimation.blit();
		}


		if(cb.d || this.mouseIsDown) {//if d button or mouse held down, gun shoots.
			if(pBulletThrott <= 0) {
				pBulletThrott = 300;
				bullets.push(gun.shoot(-8,-8));//gun shoot produces a MapTraveler bullet with adjusted velocity and position.
			} else { pBulletThrott -= 33.3; }
		}


		var i = 0;var b;var en; var ei = 0;var prt;
		var ran;
		for(i; i < portals.length; i++) {//for each rock portal.

			prt = portals[i];
			prt.animate(.3);//animate slowly.
			prt.blit(0,0,1);//the last param instructs it to ignore fromWidthOffset and fromHeightOffset when positioning the draw.

			ran = Math.random() * 775;

			if(ran > 774 && prt.currentAnimation != "spawn" && enemies.length < 25) {//at random intervals change to spawn animation.

				prt.currentAnimation = "spawn";
				break;

			}
			if(prt.currentAnimation == "spawn" && prt.finishedCurrentAnimation()) {//if spawn animation, and the animation is finished.

				this.spawnEnenmy(prt.x + 8, prt.y + 17);//spawn an enemy at the right spot.
				prt.currentAnimation = "idle";//change back to idle animation.

			}

		}


		i = 0;
		for(i;i<bullets.length;i++) {//bullet movement.
			b = bullets[i];
			b.maxSpeed = 18; b.maxForce = 12;b._walkSpeed = 12;
			b.update();//the shoot method already adjusts the _veloc and position, so we dont want to call move, just update.
			b._canvasAnimation.x = b.x;
			b._canvasAnimation.y = b.y;
			//b _canvasAnimation animate();//no need to animate the bullet, its just using the fromRect defined at construction.
			b._canvasAnimation.blit();

			//if the bullet goes off screen recycle it.
			if(b.x < this.camera.v.x || b.x > this.camera.v.x + this.camera.v.width || b.y < 0 || b.y > this.camera.v.y + this.camera.v.height) {
				tabageos.GeometricMath.splice(bullets, bullets.indexOf(b));//take bullet out of bullets array.
				gun.reclaimBullet(b);//put it back in the guns pool of bullets.
				break;
			}
			//if it hits something show an explosion, check if it hit a crate, recycle the bullet.
			if(b._pLeft || b._pRight || b._grounded || b._atCeiling) {//MapTraveler is handling basic collision with the map.
				exF.addExplosion(b.x,b.y);


				ei = 0;
				for(ei; ei < crates.length;ei++) {//potential hitting crates.

					en = crates[ei];
					if(tabageos.GeometricMath.testForPointInCircle(b._pos,32,en.getPosition())) {

						if(en.currentAnimation.indexOf("hit") != -1) {
							var frm = Number(en.currentAnimation.replace("hit", ""));
							if(frm < 3) {
								en.currentAnimation = "hit"+(frm+1)+"";
								en.animate();
								en.blit();
							} else {
								this.player._map[en.y/16][en.x/16] = [0,0];
								tabageos.GeometricMath.splice(crates, crates.indexOf(en));

							}
						} else {
							en.currentAnimation = "hit1";
							en.animate();
							en.blit();
						}
						tabageos.GeometricMath.splice(bullets, bullets.indexOf(b));
						gun.reclaimBullet(b);

						break;break;
					}

				}
				if(bullets.indexOf(b) != -1 ) {//it may be already out if it hit a crate.
					tabageos.GeometricMath.splice(bullets, bullets.indexOf(b));
					gun.reclaimBullet(b);
				}

				break;
			}
			ei = 0;
			for(ei;ei<enemies.length;ei++) {//for each enemy if the bullet is within a radius of it hit the enemy.

				en = enemies[ei];
				if(tabageos.GeometricMath.testForPointInCircle(b._pos,10,en._pos)) {

					exF.addExplosion(b.x,b.y ,1,672,16,32,32,1);//show an explosion animation where the bullet hit.
					tabageos.GeometricMath.splice(bullets, bullets.indexOf(b));
					gun.reclaimBullet(b);
					en.health -= 1;
					this._helperRect.x = en.x + (en.width * .5);
					this._helperRect.y = en.y - (16/2);
					this._helperRect.width = Math.round(en.health/5);
					this._helperRect.height = 3;
					this.charLayer.drawRect(this._helperRect, "#ff0000");//enemy health bar.
					if(en.health <= 0) {
						tabageos.GeometricMath.splice(enemies, enemies.indexOf(en));
						exF.addExplosion(en.x,en.y ,1,672,16,32,32,.2);
					}
					break;break;

				}

			}

		}//end bullets.

		i = 0; var rightTile, leftTile;
		for(i;i<enemies.length;i++) {//move and draw each enemy.
			en = enemies[i];
			en.separate(enemies);
			en.chase(this.player);
			en.update();
			en._canvasAnimation.x = en.x+1-1;en._canvasAnimation.y=en.y+1-1;
			en._canvasAnimation.currentAnimation = (en._veloc.x < 0) ? "left" : (en._veloc.x >= 1 ? "right" : en._canvasAnimation.currentAnimation+"");
			en._canvasAnimation.animate(.5);
			en._canvasAnimation.blit();//draw to charLayer.

		}

		i = 0;
		for(i; i < crates.length; i++) {
			en = crates[i];
			en.animate();
			en.blit();
		}

		exF.displayExplosions(this.charLayer, this._image);

		pmp.x = gun.x - 32; pmp.y = gun.y - 32;//offset the drawing of the rotation.
		gun.blit(0,0, pmp);

	};


	//in this example we put the whole game on the window so we can call gotoFullScreen.
	//in the side scroller 360 example we just reference a static resize method on the window.
	window._gameRef = new ThreeSixtyShooter();

})();










back to top