HTML and CSS Reference
In-Depth Information
Inside of the Level object, we declare and initialize a new enemy object array. Inside of the
Level constructor, we then assign a position for a new enemy object to be drawn to.
This position is then stored inside of the enemy object array and passed into the AddEnemy
function. This function loops through each tile within the levels tile array and then loops
through the enemy object array and places the enemy at the position above the tile that it
corresponds to.
The inal code extract refers to loading the enemy sprite sheet texture into the application.
This is done exactly as we previously did for each of the textures within the game. A new
enemy image object was created within the Main object and an external path that shows the
location of the enemy sprite sheet texture was passed to the image object in question.
Adding pickups (Must know)
To allow the player to do more than just jump and avoid enemies, this recipe will focus its
attention on the implementation of collectible items known as pickups. These pickups will be
similar to the idea of collecting coins in Mario or gold rings in Sonic and will contribute to the
player's score and increase the sense of enjoyability, that is, how fun the game is.
How to do it...
In order to implement pickups into our application, we will follow the exact same
steps we took when implementing enemies.
We start off by creating a new object that represents a pickup. We begin by creating
the pickups object, which is as follows:
function Pickup() {
this.InitPickup = function(texture, x, y, z, frameCount,
frameRate) {
this.InitAnimationManager(texture, x, y, z, frameCount,
return this;
this.DisposePickup = function() {
this.Update = function(deltaTime, context, deltaX, deltaY) {
Search WWH ::

Custom Search