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, cell_size) for ...
Get Python Game Programming By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.