def handle_events(): global curCannonPrepareTime events = get_events() for event in events: spearRespawnButton.handleEvent(event, coin) axeRespawnButton.handleEvent(event, coin) swordRespawnButton.handleEvent(event, coin) if event.type == SDL_QUIT: gameFramework.running = False elif event.type == SDL_MOUSEMOTION: camera.handleEvent(event.x) elif event.type == SDL_KEYDOWN: if event.key == SDLK_ESCAPE: gameFramework.change_state(titleState) elif event.key == SDLK_SPACE: if curCannonPrepareTime <= 0.0: for i in range(4): worldObjManager.addObject(cannon.Cannon(), 3) curCannonPrepareTime = cannonPrepareTime
def enter(): global allyBase, enemyBase global coin, spearRespawnButton, axeRespawnButton, swordRespawnButton global font global oldScroll worldObjManager.deleteAllObjects() camera.enter() tempCannon = cannon.Cannon() del (tempCannon) # fourth type is base type True: ally allyBase = AllyBase("base\\allyBase.png", 200, 150) enemyBase = EnemyBase("base\\enemyBase.png", camera.backgroundImage.w - 200, 150) coin = GUI.Coin() spearRespawnButton = GUI.SpearmanRespawnButton() axeRespawnButton = GUI.AxemanRespawnButton() swordRespawnButton = GUI.SwordmanRespawnButton() worldObjManager.addObject(allyBase, 0) worldObjManager.addObject(enemyBase, 0) oldScroll = GUI.OldScroll() font = load_font('textfile\\Sofija.TTF', 25)
def update(): global curCannonPrepareTime if enemyBase.update(): worldObjManager.addObject(enemyCharacter.HammerOrk(1600, 100), 2) worldObjManager.addObject(enemyCharacter.AxeOrk(1600, 100), 2) worldObjManager.addObject(enemyCharacter.SwordOrk(1600, 100), 2) worldObjManager.update() camera.update() coin.update() spearRespawnButton.update() axeRespawnButton.update() swordRespawnButton.update() if curCannonPrepareTime >= 0.0: curCannonPrepareTime -= gameFramework.frameTime
def makeObjectAndReturn(self, coin): if coin.currentMoney - self.cost >= 0: coin.currentMoney -= self.cost worldObjManager.addObject(allyCharacter.SwordMan(300, 100), 1) return True return False