O'Reilly logo

Instant HTML5 2D Platformer by Aidan Temple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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...

  1. In order to implement pickups into our application, we will follow the exact same steps we took when implementing enemies.
  2. 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required