Island Adventure Game

1207 WordsJan 30, 20185 Pages
<!doctype html> <html> <head> <title>Island Adventure Game</title> <style> #platform { position: relative; width: 384px; height: 384px; background-image: url("images/background.png"); } .cell { display: block; position: absolute; width: 64px; height: 64px; } p { width: 500px; } </style> </head> <div id="platform"></div> <p id="outcome"></p> <script language='JavaScript'> //Referencing to the platform and result //The platform is essentially the grid var platform = document.querySelector("#platform"); var outcome = document.querySelector("#outcome"); //Added a keyboard listener feature //Use window because the event is taking place on the window window.addEventListener("keydown", down_key, false); //The map of the game //Refer to 'map code' to see what each number corresponds to var map = [ [0, 0, 0, 0, 0, 1], [0, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 2, 0, 0], [0, 0, 0, 0, 0, 3] ]; //Positions of the boat //Refer to 'map code' for number correspondance var gameObjects = [ [4, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0] ]; //Map code //Images corresponding with grid above var WATER = 0; var HOBO = 1; var ISLAND = 2; var HOME = 3; var BOAT = 4; //The size of each square containing each image in pixels var SIZE = 64; //How many rows and columns are present in the grid var ROWS = map.length; var COLUMNS = map[0].length;
Open Document