//setup canvas
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
/******************************************
GLOBAL VARIABLES
******************************************/
var playing = true; //is the game running
var tileSize = 128; //the side length of individual tiles
var gravity = 1; //the amount of gravity in the level
var enemies = []; //the array of bad guys
var map = []; //where current maps are stored
var tileSet = []; //the array of tile types
var staticCamera = false; //should the camera stay still
var framerate = 30; //how many frames per second should the game run at
/******************************************
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 = [
[0,0,0,0,0,0],
[0,1,1,1,1,0],
[0,1,0,0,0,0],
[0,1,1,1,0,0],
[0,1,0,0,0,0],
[0,1,1,1,1,0],
[0,0,0,0,0,0]
];
map = map1;
/******************************************
CHARACTERS
******************************************/
var player = { //The player-character
x: 250, //the starting x-position
y: 250, //the starting y-position
angle: 0, //the angle the player is looking in
speed: 0, //the speed the play is moving
}
/******************************************
MAIN THREAD
******************************************/
function gameCycle() {
if (playing === true) {
drawMap();
} else {
}
}
/******************************************
SETUP TILES
******************************************/
function tile(symbol,...
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.