I found the docs lacking for some basic things when it came to using Heaps.
These are some really basic examples to get you up and running.
These are not progressive examples. I.e. the fourth example is not more "difficult" than the first. They're numbered for convenience.
The examples are already compiled and can be ran by opening the index.html
in a browser.
If you want to recompile the game for some reason, you can do so with:
haxe build.hxml
Shows how to properly move a square using the keyboard. Note the use of delta time so even on a low frame rate we move consistently.
Also note the use of a vector ([0, 1]
) for movement instead of hardcoding
player's x
and y
coordinates.
Shows how to have multiple players on the screen and TAB between them. Gives off some serious The Lost Vikings vibes.
The gist of it is that we create a playerGroup
and put all of our players
within it and track the active player.
Simple rectangle collision detection. When the player enters the block, he turns white.
Demonstrates spawning and updating bullets in the Player's direction.
Shows how to switch between different scenes. E.g. Going from a main menu to the actual game and into a shop.
Demonstrates shaking the screen. When the player enters the block, the screen shakes.
The screen shake has been implemented as a static extension to keep the code as clean as possible.