ZAMBIE GAM

by Kyle Bezio

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 = 16;
var key = 0;
var newX = 0;
var newY = 0;
var bullets = [];
var angle = 0;
var i = 0;
var length = 0;
var height = 0;


//The Map
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 : 32,
	y : 32,
	dir : 0,
	rot : 1.5707963268,
	speed : 0,
	moveSpeed : 2,
	rotSpeed : 6 * Math.PI / 180,
  strafe : 0
}

//The Bad Guy
var baddie = {
	x : 128,
	y : 144,
	dir : 0,
	rot : 1.5707963268,
	angle: 0,
  speed : 0,
	moveSpeed : 2,
	rotSpeed : 6 * Math.PI / 180,
  strafe : 0,
	canSEE: false,
	rayX: 0,
  rayY: 0,
	length: 0
}

function bullet() {
	this.x = player.x;
  this.y = player.y;
  this.rot = player.rot;

}

//That One Function That Does Everthing
function gameCycle() {
	move();
	drawMap();
  bulletUpdate();
  render();
  renderBaddie();
  player.draw();
  baddie.draw();
  context.fillStyle = "black";
  context.font = "40px Arial";
  context.fillText("Key: " + key, 300, 40);
	context.fillText("Speed: " + player.speed, 300, 80);
  context.fillText("Direction: " + player.dir, 300, 120);
  context.fillText("Rotation: " + player.rot, 300, 160);
  context.fillText("X: " + player.x, 300, 200);
  context.fillText("Y: " + player.y, 300, 240);
  context.fillText("Strafe: " + player.strafe, 300, 280);
  context.fillText("i: " + i, 300, 320);
  context.fillText("Ray X: " + rayX, 300, 360);
  context.fillText("Ray Y: " + rayY, 300, 400);
  context.fillText("Height: " + height, 300, 440);
 ...