View Full Version : Are views and levels possible with JavaScript?

10-08-2008, 02:14 AM
I was just kind of curious if it would be possible to make views with javascript. Say you wanted to make a game kind of like mario how would you make it so it scrolls with the object as you move throught the room? Also i was wondering how you would load the next level when you finish the one you are on?

thank you,

10-08-2008, 04:00 AM
Entirely possible, through various ways. You can animate pretty much through the canvas element, VML or SVG - you could even generate HTML or actual graphics (BMP are simple to generate but not so small in memory, as an example). You can load levels through creating script elements that load JavaScript code for the next level, or you can use XMLHttpRequest, or you can use a form (making each level a separate HTML page) etc. The technique you use for the graphics part is pretty much the same as for desktop or Flash games, only a few years behind in technology level.

10-11-2008, 04:33 AM
ok so i kind of get how to load the levels but i'm not really quite sure how to get the level to scroll as you move through it. i was thinking you would make a variable go up every time you move and check if the variable is at a certain number to move the background or something. but then if there were enemies farther in the level how would i get those to appear when i get far enough in the room. i'm really confused lol.

10-11-2008, 02:40 PM
It is called learning how to program and thinking how things work.

You set up conditions. If player is in X1 area, I do this. If player is in X2 area I do this.

If I were you, I would worry less about enemies at this time and get a character moving through some screen.

Here is an example for you to start out with: http://ajaxpatterns.org/wiki/index.php?title=Sprite#Solutions