The components of an interactive, graphic application:
These things are the basic building blocks of any interactive, graphic application.
JavaScript is a great language to use when starting out (or even beyond that) because the same concepts apply here as anywhere else, but you can save your code, and run it in your favorite browser!
Here's a Tetris example I've been working on lately in JavaScript that draws the board on an HTML5 canvas. It may seem a little complicated and overwhelming, but all the pieces are there that I've discussed (except for sound =/).
Just for reference, the tick
function is my main animation loop. It runs as fast as the window will return animation frames, which is usually quicker than necessary. Once the tick
function is called once, it will continue to run until explicitly stopped.
Tet.prototype.tick = function()
{
var _self = this; // needed for next step
// This line is what will make this function run repeatedly
this.requestId = requestAnimationFrame(function(){_self.tick()});
// Get some time information
this.tickNow = Date.now();
this.tickDelta = this.tickNow - this.tickThen;
// If it's been long enough, and it's time to draw a frame...
if (this.tickDelta > this.tickInterval)
{
this.tickThen = this.tickNow - (this.tickDelta % this.tickInterval);
// Run the game loop
this.doGameLoop();
// Draw the updated board
this.renderer.drawBoard(this.data, this.curPiece, this.curPieceGuide);
}
}
Game making can be intimidating at first, because it seems there are SO MANY pieces that need to be understood before you can accomplish what you see in your head, but if you take the concepts one-at-a-time, and start small, you'll be making crazy stuff in no time!