//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.7; //the amount of gravity in the level. Only applicable in sideScroller
var moveStyle = "sideScroller"; //"rotationBased", "RPG", or "sideScroller"
/******************************************
IMAGES
******************************************/
//the background --optional--
var backgroundImage = ""; //the url of the pic
var bgImage = new Image(); //defining the name of the image
bgImage.src = backgroundImage; //setting the .src
//character image
var spriteSheet = "https://s1.postimg.org/9o3ntp5zwf/New_Piskel_4_2_1_1_5_2.png"; //the url of the pic
var ssImage = new Image(); //defining the name of the image
ssImage.src = spriteSheet; //setting the .src
//top down grass
var grassTopImage = "https://s26.postimg.org/huzdqvh5l/New_Piskel_2.png"; //the url of the pic
var gtImage = new Image(); //defining the name of the image
gtImage.src = grassTopImage; //setting the .src
//side view of grass
var grassSideImage = "https://s25.postimg.org/3ml5v24yn/New_Piskel_2_1.png"; //the url of the pic
var gsImage = new Image(); //defining the name of the image
gsImage.src = grassSideImage; //setting the .src
//dirt
var dirtImage = "https://s25.postimg.org/mex0z0r6n/New_Piskel_2_2.png"; //the url of the pic
var drImage = new Image(); //defining the name of the image
drImage.src = dirtImage; //setting the .src
//stone bricks
var brickImage =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.