The SPIRE Engine

Elijah Cirioli

by ElijahCirioli

HTML

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

JavaScript

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

/******************************************
							GLOBAL VARIABLES
******************************************/
//general variables
var playing = true; //is the game running
var tileSize = 64; //the side length of individual tiles
var framerate = 30; //how many frames per second should the game run at

//arrays
var enemies = []; //the array of bad guys
var map = []; //where current maps are stored
var tileSet = []; //the array of tile types

//movement variables
var gravity = 1; //the amount of gravity in the level. Only applicable in sideScroller
var moveStyle = "sideScroller"; //"rotationBased", "RPG", or "sideScroller"


/******************************************
							     IMAGES
******************************************/
var backgroundImage = "https://s24.postimg.org/9l26me0id/new_Wall.png"; //the url of the pic
var bgImage = new Image(); //defining the name of the image
bgImage.src = backgroundImage; //setting the .src


/******************************************
							     SOUNDS
******************************************/
var exampleSound = new Audio(""); //an example sound file


/******************************************
							      MAPS
******************************************/
var map1 = [
	[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
  [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
  [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],
  [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1],
  [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
  [1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],
  [1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1],
  [1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],
  [1, 0, 0, 0, 0, 1, 1, 1, 1,...