How to store the position of enemies on stage for a game in HTML5 and Javascript?

I`m trying to make a game like Doodle Jump and I need to generate the lines, where the character can jump on, but I have no idea how to do it, or how to store the position of each line on what the character can jump on. And there should be something to limit the number of lines as the game advances to make it more and more difficult, but without have impossible situations.

My main question is what would be a good method to store the position of each line ? Thanks in advice

Answers


There is a tutorial over here which shows you how to build a doodle jump style game using HTML5 Canvas http://michalbe.blogspot.com/2010/09/simple-game-with-html5-canvas-part-1.html.

In that example the developer creates an array of platform objects and draws them to canvas and then does some simple collision detection:

http://michalbe.blogspot.com/2010/09/tutorial-simple-game-with-html5-canvas_19.html

var GameLoop = function(){
clear();
//MoveCircles(5);
DrawCircles();

if (player.isJumping) player.checkJump();
if (player.isFalling) player.checkFall();

platforms.forEach(function(platform){
platform.draw();
});

checkCollision();

player.draw();
gLoop = setTimeout(GameLoop, 1000 / 50);
}

Need Your Help

hash using multiple array value in ruby

ruby-on-rails ruby hash

How I'm trying to build a hash for the following input

How to insert ($x-$y) inside a bash printed string

linux bash shell command-line sh

I have this simple problem but I am very unfamiliar with bash syntax;