Book Image

Python Game Programming By Example

Book Image

Python Game Programming By Example

Overview of this book

Table of Contents (14 chapters)
Python Game Programming By Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Game scene


The game layer contains several attributes for holding the reference to the HUD layer, the scenario, and the game information, such as the score or the number of points that can be spent to build new turrets.

These classes are added to the gamelayer module, which has contained only the game over transition so far:

class GameLayer(cocos.layer.Layer):
    def __init__(self, hud, scenario):
        super(GameLayer, self).__init__()
        self.hud = hud
        self.scenario = scenario
        self.score = self._score = 0
        self.points = self._points = 40
        self.turrets = []

        w, h = director.get_window_size()
        cell_size = 32
        self.coll_man = cm.CollisionManagerGrid(0, w, 0, h,
                                                cell_size,
                                                cell_size)
        self.coll_man_slots = cm.CollisionManagerGrid(0, w, 0, h,
                                                      cell_size,
                         ...