def blob_collision(self, item): print(self.tag, item.tag) if self.size[0] > item.size[1]: game.room.remove(self) else: game.room.remove(item) game.sound("audio/blast.ogg")
def onClickBomb(item): if not (game.pause): if (item.size[0] > 32): score.text += 20 item.size = (4, 4) game.sound("sfx/hoop.wav") else: item.sizeAdd(8, 8) game.sound("sfx/boom.wav")
def ball_collision(item): if item == bgoal: game.sound("audio/fallsmall.ogg") bscore.text += 1 randSpeed() elif item == rgoal: game.sound("audio/fallbig.ogg") rscore.text += 1 randSpeed()
def end(name, color): game.sound("audio/launch.ogg") game.pause = True game.Label(name + " is winner!", (140, 180), color, size=72, tag="temp") re = game.Label(" Restart ", (240, 300), game.WHITE, back=color, size=72, radius=.3, tag="temp") re.click = restart
def onCollisionPlayer(collider): global score, score_add if collider.tag == "bomb": game.sound("sfx/haaa.wav") game.pause = True game.Label("GAME OVER", position=(220, 200), color=game.ROSE, size=64) r = game.Label(" Restart ", position=(280, 300), color=game.LIME, back=game.ROSE, size=64, radius=.5) r.click = onClickRestart '''elif collider.tag == "inc":
def ball_collision(item): if item == rocket1: game.sound("audio/fallbig.ogg") ball_return(1) elif item == rocket2: game.sound("audio/fallsmall.ogg") ball_return(-1) elif item == wall1: game.sound("audio/blast.ogg") score2.text += 1 start(1) elif item == wall2: game.sound("audio/blast.ogg") score1.text += 1 start(-1)
def onStart(): global score_add, score, player, counter player = game.Box(color=game.ORANGE, size=(40, 40), speed=(4, 4), radius=.4, tag="player") player.collision = onCollisionPlayer game.Image("images/coins.png", position=(10, 10)) score = game.Label(0, position=(45, 0), color=game.LIGHT_CHOCOLATE) score.format = int for i in range(random.randint(2, 4)): addRandom("inc", game.INDEGO, None) for i in range(random.randint(2, 4)): addRandom("dec", game.GREEN, None) for i in range(random.randint(6, 8)): addRandom("bomb", game.RED, onClickBomb) game.sleep(3) game.sound("sfx/123start.wav")
def ball_bounce(): game.sound("audio/hit1.ogg")