def draw(canvas): canvas.draw_polygon([(0, 400), (0, 100), (500, 100), (500, 400)], 5, "Grey", "Grey") global selected, pointer aisprite.updateStatic(canvas) redsprite.updateStatic(canvas) greensprite.updateStatic(canvas) bluesprite.updateStatic(canvas) yellowsprite.updateStatic(canvas) interaction() if (Mouse.multiNoSel): pointer = Ai.level Mouse.multiNoSel = False selected = True if selected and pointer == 1: Master.levelSelect() if selected and pointer == 0: Master.spriteSelect() canvas.draw_polygon( [[100 + (pointer * 200), 315], [100 + (pointer * 200), 150], [200 + (pointer * 200), 150], [200 + (pointer * 200), 315]], 5, "Red") canvas.draw_text("Vs Player", (108, 300), 20, "White") canvas.draw_text("Vs CPU", (315, 300), 20, "White")
def draw(canvas): canvas.draw_polygon([(0, 400), (0, 100), (500, 100), (500, 400)], 5, "Grey", "Grey") global selected global pointer redsprite.updateStatic(canvas) greensprite.updateStatic(canvas) bluesprite.updateStatic(canvas) yellowsprite.updateStatic(canvas) interaction() if (Mouse.levelSel): pointer = Ai.level - 1 Mouse.levelSel = False selected = True if selected and pointer == 0: Ai.level = pointer + 1 #more efficient than assigning everytime loop is run, although more code Master.gameLoop('Base', 'Red', True) if selected and pointer == 1: Ai.level = pointer + 1 Master.gameLoop('Base', 'Green', True) if selected and pointer == 2: Ai.level = pointer + 1 Master.gameLoop('Base', 'Yellow', True) if selected and pointer == 3: Ai.level = pointer + 1 Master.gameLoop('Base', 'Blue', True) canvas.draw_polygon( [[50 + (pointer * 100), 315], [50 + (pointer * 100), 150], [150 + (pointer * 100), 150], [150 + (pointer * 100), 315]], 5, "Red") canvas.draw_text("Level 1", (75, 300), 20, "White") canvas.draw_text("Level 2", (175, 300), 20, "White") canvas.draw_text("Level 3", (275, 300), 20, "White") canvas.draw_text("Level 4", (375, 300), 20, "White")
def draw(canvas): updateText(canvas) global timer if timer > 90: red.draw(canvas) if timer > 130: yellow.draw(canvas) if timer > 170: green.draw(canvas) if timer > 210: canvas.draw_text("Press any button to start!", (50, 450), 40, "White") if kbd.next: Master.menu() timer += 1
def handler(position): click = Vector(position[0], position[1]) if Mouse.screen == "splash": #todo change to dict Master.menu() elif Mouse.screen == "menu": Mouse.mainMenuButtons(click) elif Mouse.screen == "instructions": Master.menu() elif Mouse.screen == "game": Mouse.gameMenuButtons(click) elif Mouse.screen == "MultOrNo": Mouse.multiplayer(click) elif Mouse.screen == "lvlSelect": Mouse.lvlSelect(click) elif Mouse.screen == "spriteSelect": Mouse.spriSel(click) else: pass
def mainMenuButtons(click): radius = 36 red = Vector(246, 74) yel = Vector(246, 157) gre = Vector(246, 240) cenToClick = click.copy().subtract( red.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball quit(0) cenToClick = click.copy().subtract( yel.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball Master.instructions() cenToClick = click.copy().subtract( gre.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball # Master.gameLoop() Master.modeSelect()
def gameMenuButtons(click): #Red, yel and green correspond to the position of the buttons displayed during the game radius = 20 red = Vector(30, 40) yel = Vector(80, 40) gre = Vector(130, 40) cenToClick = click.copy().subtract( red.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball quit(0) cenToClick = click.copy().subtract( yel.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball Master.instructions() cenToClick = click.copy().subtract( gre.copy()) # dist between centre of ball and click if (cenToClick.length() <= radius): # check click is in ball # Master.gameLoop() Master.menu()
def drawSpriteSheet(canvas): canvas.draw_polygon([[125, 105], [125, 420], [375, 420], [375, 105]], 1, 'Grey', 'Grey') canvas.draw_text("Select Sprite", (200, 50), 20, "White") player1.update() player2.update() selection.draw(canvas) if Mouse.spriteSel1: cursor1.selected = True if not Mouse.spriteSel2: cursor1.position = Mouse.spriteSelection if Mouse.spriteSel2: Mouse.spriteSel1 = False cursor2.selected = True cursor2.position = Mouse.spriteSelection Mouse.spriteSel2 = False if cursor1.getSelected(): selectedSprite1.changeState("on") selectedSprite1.nextSprite() else: selectedSprite1.changeState("off") selectedSprite1.nextSprite() if cursor2.getSelected(): selectedSprite2.changeState("on") selectedSprite2.nextSprite() else: selectedSprite2.changeState("off") selectedSprite2.nextSprite() cursor1.draw(canvas) cursor2.draw(canvas) Sprite(previewSprites[cursor1.previewSelection()], 2, 14, (50, 250), 8, "idle", "right").updateStatic(canvas) Sprite(previewSprites[cursor2.previewSelection()], 2, 14, (450, 250), 8, "idle", "left").updateStatic(canvas) selectedSprite1.draw(canvas) selectedSprite2.draw(canvas) if ready(): Master.gameLoop(finalnames[cursor1.previewSelection()], finalnames[cursor2.previewSelection()], False)
def draw(canvas): if kbd.ai and round.startTimer % ai.loopsPerGo == 0: ##allows the ai to select a move once every x cycles of the gameloop Ai.move(Ai) if round.startTimer % 20 == 0: #stops moves lasting more than 20 cycles kbd.ai_keyup() round.startTimer += 1 interactions.update(round) background.draw(canvas) player1.draw(canvas, player2) #fireball drawing done in character draw player2.draw(canvas, player1) #platform_bottom.draw(canvas) if round.gameEnded: if round.startTimer < round.endTime + 180: round.drawend(canvas) else: #enter main menu kbd.key_up(next) round.gameEnded = False Master.menu() if round.startTimer < 180: round.draw(canvas)
def draw(canvas): instructions(canvas) if kbd.next: kbd.key_up(next) Master.menu()
def instructions(): kbd.key_up(next) Master.instructions()
def playgame(): kbd.key_up(next) Master.modeSelect()
def main(): Master.runGame()
def draw(canvas): storysplash(canvas) if kbd.next: kbd.key_up(next) Master.menu()