def run(self): r = self.background(self.images[0][1]) gfx.dirty(r) self.moveship() gfx.updatestars(self.background, gfx) if not self.done: self.drawlist() for img in self.images: r = gfx.surface.blit(img[0], img[1]) gfx.dirty(r) else: if gfx.rect.colliderect(self.images[0][1]) and not self.aborted: if self.current[0] >= 0: g = self.gamelist[self.current[0]] r = gfx.surface.blit(g[1][0], g[1][1]) gfx.dirty(r) for img in self.images: r = gfx.surface.blit(img[0], img[1]) gfx.dirty(r) else: self.clearlist() if self.aborted: game.handler = self.prevhandler else: game.handler = gameplay.GamePlay(self.prevhandler) for img in self.images[1:]: r = self.background(img[1]) gfx.dirty(r)
def playClicked(self): #save the inventory to ensure the buy's are not lost Inventory.save() game = gameplay.GamePlay() # A scene that contains the layer hello_layer main_scene = cocos.scene.Scene(game) # And now, start the application, starting with main_scene director.replace(main_scene)
#!/usr/bin/python3 ''' @Author: Esteban Sierra Munera @PersonalEmail: [email protected] @CollegeEmail: [email protected] @CollegeEmail2: [email protected] @LasUpdate: August 27th, 2018 Main script for minesweeper game for PSL Internship Programming Challenge ''' import gameplay as gp canPlay = False while (not canPlay): try: h, w, m = input("Insert Height, Width an Number of mines: ").split() canPlay = True except ValueError: print("Enter all the data.") game = gp.GamePlay(int(h), int(w), int(m)) game.printBoard() while (game.isPlaying()): msg = game.play() game.printBoard() print(msg)
def preGameStart(prevhandler): """ Funcao executa antes da inicializacao do jogo. """ return gameplay.GamePlay(prevhandler)
tts = gTTS(text=whatToSay, lang='en') tts.save("x.mp3") os.system("mpg321 -q x.mp3") else: print(whatToSay) name = raw_input("Enter your name: ") max_number = int(raw_input("Enter a maximum number for the game: ")) response = raw_input("Select (V)isual or (A)udio: ") if response == "V": mode = "visual" else: mode = "audio" game = gameplay.GamePlay(name, max_number, mode) first_line = "Guess a number between 1 and %d" % max_number saySomething(first_line, mode) #keep looping unil we guess correctly while (not game.solved): this_guess = input('?') game.guess(this_guess) print("You solved the puzzle in %d guesses." % game.guessCount) board = lb.Leaderboard() board.addGame(game) board.printleaderboard()
def main_menu(): Background_sound = pygame.mixer.music.load('./res/background.mp3') pygame.mixer.music.play(-1) menu = True selected = 10000 while menu: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.KEYDOWN: if event.key == pygame.K_UP: selected -= 1 elif event.key == pygame.K_DOWN: selected += 1 if event.key == pygame.K_RETURN: if selected % 4 == 0: print("Start") game = gameplay.GamePlay() game.InitGame() game.RunGame() if selected % 4 == 1: howtoplay() if selected % 4 == 2: credit() if selected % 4 == 3: pygame.quit() quit() # Main Menu UI screen.fill(black) title = drawMenu("Sword Master", menuFont, 70, yellow) if selected % 4 == 0: text_start = drawMenu("START", menuFont, 35, blue) else: text_start = drawMenu("START", menuFont, 35, white) if selected % 4 == 1: text_how = drawMenu("How to Play", menuFont, 35, blue) else: text_how = drawMenu("How to Play", menuFont, 35, white) if selected % 4 == 2: text_settings = drawMenu("Credit", menuFont, 35, blue) else: text_settings = drawMenu("Credit", menuFont, 35, white) if selected % 4 == 3: text_quit = drawMenu("QUIT", menuFont, 35, blue) else: text_quit = drawMenu("QUIT", menuFont, 35, white) title_rect = title.get_rect() start_rect = text_start.get_rect() how_rect = text_how.get_rect() settings_rect = text_settings.get_rect() quit_rect = text_quit.get_rect() # 디스플레이 screen.blit(pygame.image.load("./res/wall.png"), (0, 0)) screen.blit(title, (screen_width / 2 - (title_rect[2] / 2), 30)) screen.blit(text_start, (screen_width / 2 - (start_rect[2] / 2), 120)) screen.blit(text_how, (screen_width / 2 - (how_rect[2] / 2), 160)) screen.blit(text_settings, (screen_width / 2 - (settings_rect[2] / 2), 200)) screen.blit(text_quit, (screen_width / 2 - (quit_rect[2] / 2), 240)) pygame.display.update() clock.tick(FPS) pygame.display.set_caption("Sword Master")
def preGameStart(prevhandler): if not players.players: game.player = players.Player('') return gameplay.GamePlay(prevhandler) else: return GameStart(prevhandler)
import sys import pygame as pg import prepare # needs to be imported first to ensure correct initialization import custom import gameplay import menu import splashscreen states = { "Custom": custom.Custom(), "GamePlay": gameplay.GamePlay(), "NewGameMenu": menu.NewGameMenu(), "MainMenu": menu.MainMenu(), "SplashScreen": splashscreen.SplashScreen() } state = states[prepare.START_STATE_NAME] state.start(prepare.START_STATE_NAME, {}, pg.display.get_surface()) clock = pg.time.Clock() if __name__ == "__main__": while True: dt = clock.tick(prepare.FPS_MAX) # in milliseconds if pg.event.get(pg.QUIT) or state.quit: break state.process_events(pg.event.get()) if state.done: state.done = False persistent = state.persist next_state_name = state.next_state_name