Lostcast Episode 5: Left 4 Questions
Lostcast is our podcast about HTML5 games. In episode 5, we answer a list of questions sent in by Jarrod Oberto, one of our listeners. Here are the questions he sent us:
1) Setting your frame rate: So in the attached code I use setInterval(main, 20); Now I have an idea what this means but have not fully wrapped my head around it. I see in your tutorial you set this value to 1 (so it runs as fast as possible) and then control the speed with your "modifier" value? I tried your method and it killed my performance in Firefox. Could you explain the pros/cons in the two different techniques?
2) HTML5 code Setup: As you can see, I have spilled all my code in to one file! Is this good? bad? Should each object go into a separate file? All tutorials I see have the code jammed in the same file.
3) Menu/Opening screen: Here I'm talking the screen where you select the number of players or choose your car. Specifically how is the code organised? Is this code even in the "game" loop? it's own loop? no loop? Again, tutorials skip this and throw you straight in the game.
4) Lastly, everything in the code attached is what I believe is correct. Therefore it may be completely wrong and I'll never know until someone better than me points out mistakes. If you do decide to have a post cast/blog about bringing your code to the next level, I'm sure you will find plenty of fodder from my code!
Also, I used Logic Pro 9 (yay shiny new Xmas toy!) to edit this episode, and I'm brand new to it, so please do let me know about any issues, like editing or volume woes.
- Racing game source code by Jarrod Oberto
- Our HTML5 Rocks article, including a section on time-based modeling
- Spacius! -- (source code)
Thanks for listening! If you have your own HTML5 game development questions, please send them and we'll answer what we can.