Tiles 2.0
all movement works with baddie
by Kyle Bezio
HTML
<canvas id="myCanvas" width="500" height="500" style="border:1px solid #000000;"></canvas>
JavaScript
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var tileW = 64;
var tileH = 64;
var dirX = 0;
var dirY = 0;
var spd = 8;
var drawSpeed = 40; // 100/drawSpeed
var turnSpeed = 0;
//man and baddie
var mImg;
var man;
var bImg;
var baddie;
//starting x and y tiles
var manStartX = 1 * tileW;
var manStartY = 4 * tileH;
var baddieStartX = 5 * tileW;
var baddieStartY = 2 * tileH;
//center of the game board
var centerX = 250 - 16;
var centerY = 250 - 16;
//control jumping and falling
var gravity = .9;
var jumpstart = -12;
/*
- Change if you make a zelda style -
*/
var overhead = false;
var oh = prompt("Zelda Style? (T/F)");
if(oh === "true" || oh === "T" || oh === "t" || oh === "True") {
overhead = true;
}
var frame;
//change to your images vvvv
var manImage = "https://s15.postimg.org/6jh8dvkxn/Adventure_Game_Sprite.png";
var baddieImage = "https://s18.postimg.org/cyru1tni1/Baddie_Sprite_Robot.png";
var tileImage = "https://s22.postimg.org/ou2mq3t81/Cobble_Stone_Wall_Tile.png"
/*
https://s15.postimg.org/6jh8dvkxn/Adventure_Game_Sprite.png
https://s18.postimg.org/cyru1tni1/Baddie_Sprite_Robot.png
https://s21.postimg.org/3leinmfpj/Cobble_Stone_Wall_Tile.jpg
https://s22.postimg.org/ou2mq3t81/Cobble_Stone_Wall_Tile.png round
*/
var thread;
/****************
change for your own map
****************/
var map = [
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1],
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1],
[1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]
];
//tile colors
var colors = ["white", "black"];
/*******
Man object
*******/
function Man(x, y, color, img) {
this.x = x;
this.y = y;
this.width = 32;
this.height = 32;
this.color = color;
this.img = img;
this.upleft = 0;
this.upright = 0;
this.downleft = 0;
this.downright = 0;
this.jumping = false;
this.jumpspeed =...