Defining some constants in the beginning will help us to easily tweek the
game if needed.
MAXH hold the game
MAXVX is the maximum ball velocity. I will be using
j5g3, my game engine.
This is where we define the Spritesheet. A neat trick is to include assets using data URLs. This should probably only be done with smalls images since the strings can get pretty long.
We also cut our spritesheet and setup the game sprites and text.
Here we extend the
j5g3.Map to define our
World class. This will render the game background.
update function will take care of updating the ball
position and resolving collissions.
This is our AI function. It will basically follow the ball, and move the paddle using an accelaration factor.
The complete source code is hosted at github. Check out my other games here.