Hi again!
Actually, I think I've figured it out now. Made a demo using plain HTML.
It was actually easier than I thought.
Sorry all non Firefox users, but so far it's Firefox only....
http://keryx.se/dev/js/game-engine.php
https://gist.github.com/1488451 (or view source, since nothing is
happening in the PHP code)
Relevant parts:
// Move in memory and collision detect
// Ideal update frequency 200 fps
function move() {
// Lots of stuff goes here
setTimeout(move, 5);
}
// Just update the screen, no math
// Approximate update frequency 50-60 fps
function draw() {
ball.dom.style.left = ball.left + "px";
ball.dom.style.top = ball.top + "px";
if (ball.isMoving) {
mozRequestAnimationFrame(draw);
}
}
Next up is setting up a registry-object that will contain all moving or
movable objects and have the move() and draw() functions cycle through
that object, and untie game-over from the ball object...
--
Lars Gunther
http://keryx.se/
http://twitter.com/itpastorn/
http://itpastorn.blogspot.com/
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/jsmentors@jsmentors.com/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/jsmentors@googlegroups.com/
To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com