Game Development Reference
In-Depth Information
Extending the level
The next step is to include the goal game object in the level image. Remember that
each pixel color represents a certain game object in the world of Canyon Bunny. For
the goal game object, we choose red as the pixel color ( R=255, G=0, B=0 ).
Add the new red pixel marked as Goal to the level image. Use the following
screenshot for reference:
Obviously, the goal should be placed at the far right-hand side to make it harder to
reach for the player. In our example level, this is the elongated platform right after
the arrow that is made out of gold coins.
Now, we need to tell the level loader about the new pixel and game object to let it
handle correctly.
Add the following import lines to the Level class:
import com.packtpub.libgdx.canyonbunny.game.objects.Carrot;
import com.packtpub.libgdx.canyonbunny.game.objects.Goal;
After this, add the following code to the same class:
public Array<Carrot> carrots;
public Goal goal;
Furthermore, add the following constant to the BLOCK_TYPE enumeration that
defines the goal's red pixel color:
GOAL(255, 0, 0), // red
 
Search WWH ::




Custom Search