ZAMBIE GAM

by ElijahCirioli

HTML

<canvas id="myCanvas" width="800" height="550" style="border:1px solid #000000;"></canvas>

JavaScript

var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");

//The Variables
var tileSize = 32;
var key = 0;
var newX = 0;
var newY = 0;
var bullets = [];
var xRayAngles = [];
var angle = 0;
var i = 0;
var length = 0;
var height = 0;
var bob = 10;
var bi = 1;
var overheat = 0;
var ammo = 6;
var bx = 0;
var by = 0;
var baddie = [];
var playing = false;
var bl = 0;

var wallImage = "https://s24.postimg.org/9l26me0id/new_Wall.png"
//"https://s29.postimg.org/eg2pzme4n/Wall.png";
var gunImage = "https://s27.postimg.org/r9k05mg3n/arm.png";
var gunShot = "https://s27.postimg.org/qz7tacgn7/Gun_Arm.png"
var baddieImage = "https://cdn3-5.cdn.schoology.com/system/files/imagecache/attachment_image_icon/attachments/files/library/201701/zambo_58813d68c8d0a.png"
var mainScreenImage = "https://s24.postimg.org/k33o4s6rp/Zombie_Title_Screen.jpg"

var gunSound = new Audio("https://app.schoology.com/system/files/attachments/files/m/201701/group/897353812/ColtDesertEagleSoundBiblecom1042567256mp3cutnetmp3_587d60e2d8081.mp3");

//calculate as 160/Tan(1/2 of viewing angle in radians) ---- assume viewing angle of 60 degrees
var distanceToPlane = 400/Math.abs(Math.tan(30 * Math.PI / 180));// 277;

for( var x = 0; x < 800; x += 2 ){
    var xAng = Math.atan( ( x - 400 ) / distanceToPlane );
    xRayAngles.push( xAng );
}

var map = [
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,1,0,0,0,1,1,1,1,1,1,0,0,0,1],
[1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1],
[1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1],
[1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];

//The Guy
var player = {
	x : 80,
	y : 80,
	dir : 0,
	rot : 1.5707963268,
	speed : 0,
	moveSpeed : 3,
	rotSpeed : 4 * Math.PI / 180,
  strafe : 0
}
//The Bad Guy
var...