Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

Table of Contents (15 chapters)
Cocos2d Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring a varied scene


Once the initial scene and the basic components have been initialized, we are going to create the rest of the blocks that will form our game. The purpose of this section is to learn how to configure a varied terrain based on a few restrictions, so the game is playable and not impossible to win.

We'll start by declaring the variables that will support this configuration, so add the following constants definition:

// Number of different platforms
const int kPLATFORM_TYPES = 6;

// Number of different floors
const int kFLOOR_TYPES = 4;

This will help us to create the floors and platforms randomly later. Next, add the following variable declarations:

    // Declare small abyss' width
    float _smallAbyss;
    
    // Declare big abyss' width
    float _bigAbyss;
    
    // Declare next platform's position
    float _nextPlatformPosition;
    
    // Declare next floor's position
    float _nextFloorPosition;

The small and big abyss variables will be constants that will...