def __init__(self): self.screen = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT)) pygame.display.set_caption('Screaming Bird') self.pipegap = 120 self.intro = Intro(self.screen) self.highScore = HighScore(self.screen) self.settings = Setting(self.screen)
def opening_screen(ai_settings, game_stats, screen): """Display the menu in the beginning""" # Set up screen attributes menu = Intro(ai_settings, game_stats, screen) play_button = Button(ai_settings, screen, 'Play Game', y_factor=0.70) hs_button = Button(ai_settings, screen, 'High Scores', y_factor=0.80) intro = True # Manages the key presses of the game while intro: for events in pygame.event.get(): if events.type == pygame.QUIT: return False elif events.type == pygame.MOUSEBUTTONDOWN: click_x, click_y = pygame.mouse.get_pos() game_stats.game_active = play_button.check_button(click_x, click_y) intro = not game_stats.game_active if hs_button.check_button(click_x, click_y): ret_hs = high_score_screen(ai_settings, screen) if not ret_hs: return False screen.fill(ai_settings.bg_color) # Allow the menu to display on the top layer menu.show_menu() # Draw the button on the main screen hs_button.draw_button() play_button.draw_button() # Display past pygame.display.flip() return True
def startup_screen(ai_settings, game_stats, screen): """Display the startup menu on the screen, return False if the user wishes to quit, True if they are ready to play""" menu = Intro(ai_settings, game_stats, screen) play_button = Button(ai_settings, screen, 'Play Game', y_factor=0.70) hs_button = Button(ai_settings, screen, 'High Scores', y_factor=0.80) intro = True while intro: play_button.alter_text_color(*pygame.mouse.get_pos()) hs_button.alter_text_color(*pygame.mouse.get_pos()) for event in pygame.event.get(): if event.type == pygame.QUIT: return False elif event.type == pygame.MOUSEBUTTONDOWN: click_x, click_y = pygame.mouse.get_pos() game_stats.game_active = play_button.check_button( click_x, click_y) intro = not game_stats.game_active if hs_button.check_button(click_x, click_y): ret_hs = high_score_screen(ai_settings, game_stats, screen) if not ret_hs: return False screen.fill(ai_settings.bg_color) menu.show_menu() hs_button.draw_button() play_button.draw_button() pygame.display.flip() return True
def main(): pygame.init() size = width, height = 720, 700 black = (0, 0, 0) screen = pygame.display.set_mode(size) running = True bd = Board(3) intro = Intro() game = Game(0) # 0 -> intro menu, 1 ->game while running: screen.fill(black) for event in pygame.event.get(): if event.type == pygame.QUIT: #exit condition running = False # check for mouse positions for intro menu if game.state == 0: if event.type == pygame.MOUSEBUTTONDOWN: pos = pygame.mouse.get_pos() if intro.start_btn.is_clicked(pos): game.state = 1 #starts the game # check for mouse positions for the main game if game.state == 1: if event.type == pygame.MOUSEBUTTONDOWN: initial_pos = pygame.mouse.get_pos() tile = bd.get_selected_tile(initial_pos) if bd.solve_btn.is_clicked(initial_pos): bd.is_solving = True bd.solve_puzzle() if event.type == pygame.MOUSEBUTTONUP: if tile != None: final_pos = pygame.mouse.get_pos() direction = bd.drag_direction(initial_pos, final_pos) bd.move_tile(tile, direction) if game.state == 0: intro.draw(screen) else: if bd.is_solving == True: bd.walk_path(bd.solving_path) bd.draw(screen) time.sleep(0.3) # solving speed else: bd.draw(screen) pygame.display.update() pygame.display.quit() pygame.quit()
def IntroStart(ParentMenu): #Deletes previous MainMenu instance to avoid redundancy del(ParentMenu) global CurrentIntro #Starts Intro loop in file menu.py CurrentIntro = Intro() CurrentIntro.auto() GameStart(CurrentIntro)
def game_intro(): screen.fill(RGB_BLACK) #DRAWS MENU pygame.display.update() sound1.sound.set_volume(0) pygame.time.wait(100) sound2.sound.play() text = """[i] Initializing ... [i] Entering ghost mode ... done ...""" Intro(screen, text).run() Intro(screen, "End.", False).run()
class Game: settings: Settings def __init__(self): pygame.init() self.settings = Settings() self.settings.reset() self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) self.intro = Intro(self.screen, self.settings) self.menu = Menu(self.screen, self.settings) pygame.display.set_caption("Pacman Portal") self.maze = Maze(self.screen, mazefile='pacmap.txt') self.pacman = Pacman(self.screen) self.dashboard = Dashboard(self.screen) self.portal_enter = Portal("Enter", self.screen, self.settings) self.portal_exit = Portal("Exit", self.screen, self.settings) scoresheet = open('scoresheet.txt', 'r') self.settings.score_high = int(scoresheet.read()) def __str__(self): return 'Game(Pacman Portal), maze=' + str(self.maze) + ')' def play(self): eloop = EventLoop(finished=False) while not eloop.finished: eloop.check_events(self.pacman, self.menu, self.portal_enter, self.portal_exit, self.settings) self.update_screen() def update_screen(self): self.screen.fill((0, 0, 0)) if self.settings.mode == "Game": self.maze.check_pac_conditions(self.pacman, self.settings, self.portal_enter, self.portal_exit) self.maze.blitme(self.settings) self.pacman.blitme(self.settings) self.dashboard.blitme(self.settings) self.portal_enter.blitme() self.portal_exit.blitme() elif self.settings.mode == "Menu": self.menu.blitme() pass elif self.settings.mode == "Intro": self.intro.blitme() pygame.display.flip()
def __init__( self ): self.core = Core( 60, 1024, 768, "Ninja" ) self.intro = Intro() self.menu_background = Texture( "menu/background.png" ) self.menu_title = Menu_title() self.menu_play_button = Menu_play_button() self.menu_git_button = Menu_link_button( "menu/git.png", "https://github.com/Adriqun" ) self.menu_google_button = Menu_link_button( "menu/google.png", "https://en.wikipedia.org/wiki/Ninja" ) self.menu_facebook_button = Menu_link_button( "menu/facebook.png", "nothing", True ) self.menu_twitter_button = Menu_link_button( "menu/twitter.png", "nothing", True ) self.menu_music_button = Menu_music_button( "menu/music.png" ) self.menu_chunk_button = Menu_music_button( "menu/chunk.png", 1 ) self.menu_exit_log = Menu_exit_log() self.menu_author_log = Menu_author_log() self.menu_game_log = Menu_link_button( "menu/game.png", "nothing", True ) self.menu_settings_log = Menu_link_button( "menu/settings.png", "nothing", True ) self.menu_score_log = Menu_score_log() self.menu_music = Menu_music( "menu/Rayman Legends OST - Moving Ground.mp3" ) self.wall = Wall() self.hero = Hero() self.menu_log = Menu_log() self.map = Map()
def __init__(self, game_opts): # part of the borg pattern self.__dict__ = self.__shared_state ## the game scenes/levels self.scenes = FSM() # initialise a sample level # TODO: find a way of applying lazy initialisation # on level creation - a level should be created only # right before executed # flev = LevelFactory().create_level( # constants.SCENES['level_one'], # game_opts) flev = LevelFactory().create_level(constants.SCENES['level_one']) # set and group the scenes scenes = (Intro(game_opts), Menu(game_opts), flev) # add the scenes to the state machine for s in scenes: self.scenes.add_state(s) # enable the default state self.scenes.active_state = scenes[0]
def __init__(self): if not pygame.font: print 'Warning, fonts disabled' if not pygame.mixer: print 'Warning, sound disabled' """this function is called when the program starts. it initializes everything it needs, then runs in a loop until the function returns.""" #Initialize Everything pygame.init() #self.screen = pygame.display.set_mode((640, 480), pygame.FULLSCREEN | pygame.DOUBLEBUF) self.screen = pygame.display.set_mode((640, 480), pygame.HWSURFACE) pygame.display.set_caption('VacuumFire') #pygame.display.toggle_fullscreen() pygame.mouse.set_visible(0) #icon icon, foo = utils.load_image('icon.png') pygame.display.set_icon(icon) intro = Intro(self.screen) vacuum = False self.clock = pygame.time.Clock() #Load musics self.music = {} self.music['game'] = utils.load_sound('level_1.ogg') self.music_game_playing = False self.music['intro'] = utils.load_sound('intro.ogg') self.music['intro'].play() #Loop intro or game depending on intro's state while 1: self.clock.tick(50) if intro.menu_finished == False: intro.loop() else: self.music['intro'].stop() if self.music_game_playing == False: self.music['game'].play() self.music_game_playing = True if vacuum == False: vacuum = Vacuum(self.screen) if vacuum.scene_finished == True: intro = Intro(self.screen) vacuum = False else: vacuum.loop() pygame.display.flip()
def main(): #pygame init pygame.mixer.pre_init(SAMPLE_RATE, BIT, CHANNELS, BUFFER_SIZE) pygame.init() pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('PyTone') #make background background = Gradient((WIDTH, HEIGHT), GRAD_START, GRAD_END) #path to medias path = 'media/' pygame.display.set_icon(pygame.image.load(path + 'petrol.png')) #intro duration in milliseconds duration = 4000 #states intro = Intro(background, path, duration) menu = Menu(background, path) game = Game(background, path) instructions = Instructions(background, path) intro.run() #storing return value from menu running = True while running: option = menu.run() if option == NEW_GAME: option = game.run() elif option == INSTRUCTIONS: instructions.run() elif option == PRACTICE: #intro.run() game.set_practise(True) game.run() game.set_practise(False) #no elif here to make different states be able to quit as well if option == pygame.locals.QUIT: pygame.quit() running = False
def intro(status): """ Introduction Scene :param status: A boolean ready to capture User Event :return: Updated Status Param """ current = Intro() if current.status: status = current.status return status
def __init__(self): pygame.init() self.settings = Settings() self.settings.reset() self.screen = pygame.display.set_mode((self.settings.screen_width, self.settings.screen_height)) self.intro = Intro(self.screen, self.settings) self.menu = Menu(self.screen, self.settings) pygame.display.set_caption("Pacman Portal") self.maze = Maze(self.screen, mazefile='pacmap.txt') self.pacman = Pacman(self.screen) self.dashboard = Dashboard(self.screen) self.portal_enter = Portal("Enter", self.screen, self.settings) self.portal_exit = Portal("Exit", self.screen, self.settings) scoresheet = open('scoresheet.txt', 'r') self.settings.score_high = int(scoresheet.read())
def showIntro(self): myintro = Intro() mytextlist = ['Welcome to PyDF', 'd + mouse for digging', 'h + mouse for channeling', 'i + mouse to designate item dump', 'o + mouse selects items for dumping', 'k + arrows to inspect tile content', 's to save or l to load map from disk', 'arrow keys to move the viewport around', 'shift + < or > goes UP and DOWN Z levels', 'shift + arrow keys to move 10 tiles at a time', 'spacebar unpauses the game or pauses', 'Esc quits', '', 'Press any key to continue'] hoffset = self.tw voffset = self.tw * 2 for item in mytextlist: myintro.drawText(item, self.screen, hoffset, voffset) voffset += self.tw * 2 pygame.display.update() myintro.waitForKey() self.intro = False
def run(self): menu = Menu(self.screen) hs_screen = HighScoreScreen(self.screen, self.score_keeper) intro_seq = Intro(self.screen) e_loop = EventLoop( loop_running=True, actions={pygame.MOUSEBUTTONDOWN: menu.check_buttons}) while e_loop.loop_running: self.clock.tick(60) # 60 fps limit e_loop.check_events() self.screen.fill(PacManPortalGame.BLACK_BG) if not menu.hs_screen: intro_seq.update() # display intro/menu intro_seq.blit() menu.update() menu.blit() else: hs_screen.blit() # display highs score screen hs_screen.check_done() if menu.ready_to_play: pygame.mixer.music.stop() # stop menu music self.play_game() # player selected play, so run game for g in self.ghosts: g.reset_speed() menu.ready_to_play = False self.score_keeper.save_high_scores( ) # save high scores only on complete play hs_screen.prep_images() # update high scores page hs_screen.position() elif not pygame.mixer.music.get_busy(): pygame.mixer.music.play(-1) # music loop pygame.display.flip()
def showIntro(self): intro = Intro() text_list = [ "Welcome to PyDF", "d + mouse for digging", "h + mouse for channeling", "i + mouse to designate item dump", "o + mouse selects items for dumping", "k + arrows to inspect tile content", "s to save or l to load map from disk", "arrow keys to move the viewport around", "shift + < or > goes UP and DOWN Z levels", "shift + arrow keys to move 10 tiles at a time", "spacebar unpauses the game or pauses", "Esc quits", "", "Press any key to continue", ] hoffset = self.tw voffset = self.tw * 2 for item in text_list: intro.drawText(item, self.screen, hoffset, voffset) voffset += self.tw * 2 pygame.display.update() intro.waitForKey() self.intro = False
def play(self): menu = Menu(self.screen) hs_screen = HighScoreScreen(self.screen, self.score_keeper) intro_seq = Intro(self.screen) loop = Events(runs=True, actions={pygame.MOUSEBUTTONDOWN: menu.check}) while loop.runs: self.clock.tick(60) loop.check_events() self.screen.fill((0, 0, 0)) if not menu.hs_screen: intro_seq.update() intro_seq.blit() menu.update() menu.blit() else: hs_screen.blit() hs_screen.check_done() if menu.ready_to_play: pygame.mixer.music.stop() pygame.mixer.music.load('sounds/waka.wav') pygame.mixer.music.play() self.play_game() menu.ready_to_play = False self.score_keeper.save_high_scores() hs_screen.prep_images() hs_screen.position() elif not pygame.mixer.music.get_busy(): pygame.mixer.music.play(-1) pygame.display.flip()
def submit(self, action): if action == "startgame": self.next = Intro() self.pause() self.quit() elif action == "continue": self.next = ContMapSelect() self.pause() self.quit() elif action == "custom": self.next = MapSelect("custom_maps") self.pause() self.quit() elif action == "editor": self.next = Editor() self.pause() self.quit() elif action == "exit": self.quit()
def __init__(self): smach.StateMachine.__init__(self, outcomes=['finished', 'failed']) with self: smach.StateMachine.add('SELECT_SCENARIO', SelectScenario(), transitions={ 'pause': 'SELECT_SCENARIO', 'intro': 'INTRO', 'roses': 'ROSES', 'ball': 'BALL', 'failed': 'failed' }) smach.StateMachine.add('SELECT_PAUSE', SelectPause(), transitions={ 'succeeded': 'SELECT_SCENARIO', 'failed': 'failed' }) smach.StateMachine.add('INTRO', Intro(), transitions={ 'finished': 'SELECT_PAUSE', 'failed': 'failed' }) smach.StateMachine.add('ROSES', Roses(), transitions={ 'finished': 'SELECT_SCENARIO', 'failed': 'failed' }) smach.StateMachine.add('BALL', BallHandling(), transitions={ 'finished': 'SELECT_SCENARIO', 'failed': 'failed' })
def handle_event(self, event): if event.type == KEYDOWN and event.key == K_ESCAPE: self.game.change_scene(Intro(self.game, True)) elif event.type == KEYDOWN and event.key == K_F10: self.levelFinished() elif event.type is MOUSEMOTION: pass elif event.type is MOUSEBUTTONDOWN: if event.button <> 1: return self.picker.set_position(event.pos) self.root_node.accept(self.picker) if len(self.picker.hits) > 0: for hit in self.picker.hits: return else: h = rectaHandler(self) npos = self.worldPosFromMouse(event.pos) if self.isValid(npos): self.push_handler(h(npos))
def __init__(self, game_opts): super(GameManager, self).__init__() self.scenes = FSM() # TODO: find a way of applying lazy initialisation # on level creation - a level should be created only # right before executed # flev = LevelFactory().create_level( # constants.SCENES['level_one'], # game_opts) flev = LevelFactory().create_level(constants.SCENES['level_one']) # set and group the scenes scenes = (Intro(game_opts), Menu(game_opts), flev) # add the scenes to the state machine for s in scenes: self.scenes.add_state(s) # enable the default state self.scenes.active_state = scenes[0]
class ScreamingBird(object): def __init__(self): self.screen = pygame.display.set_mode((SCREENWIDTH, SCREENHEIGHT)) pygame.display.set_caption('Screaming Bird') self.pipegap = 120 self.intro = Intro(self.screen) self.highScore = HighScore(self.screen) self.settings = Setting(self.screen) def run(self): playing = True mode = 'intro' count = 0 while playing: # print(self.pipegap) if mode == 'intro' or mode[0] == 'intro': if count > 0: self.__init__() if mode != 'intro': print(mode[1]) self.pipegap = mode[1] mode = self.intro.run() elif mode == 'game': self.game = Game(self.screen, self.pipegap) print(self.pipegap) mode = self.game.run() elif mode == 'highscore': mode = self.highScore.run() elif mode[0] == 'gameover': count += 1 self.scoreAppend = True self.gameOver = GameOver(self.screen, mode[1]) mode = self.gameOver.run() elif mode == 'settings': mode = self.settings.run() elif mode == 'quit': playing = False pygame.quit()
def startup_screen(config, game_stats, screen): """Display an introductory startup screen for the game, return False if the user wishes to quit, True if the user is ready to play""" title_screen = Intro(config, game_stats, screen) title_screen.prep_image() button = Button(config, screen, 'Play') intro = True while intro: for event in pygame.event.get(): if event.type == pygame.QUIT: return False elif event.type == pygame.MOUSEBUTTONDOWN: click_x, click_y = pygame.mouse.get_pos() game_stats.game_active = button.check_button(click_x, click_y) intro = not game_stats.game_active screen.fill(config.bg_color) title_screen.show_menu() button.draw_button() pygame.display.flip() return True
class Engine: #------------------------------------------------------------------------------------------------------- def __init__( self ): self.core = Core( 60, 1024, 768, "Ninja" ) self.intro = Intro() self.menu_background = Texture( "menu/background.png" ) self.menu_title = Menu_title() self.menu_play_button = Menu_play_button() self.menu_git_button = Menu_link_button( "menu/git.png", "https://github.com/Adriqun" ) self.menu_google_button = Menu_link_button( "menu/google.png", "https://en.wikipedia.org/wiki/Ninja" ) self.menu_facebook_button = Menu_link_button( "menu/facebook.png", "nothing", True ) self.menu_twitter_button = Menu_link_button( "menu/twitter.png", "nothing", True ) self.menu_music_button = Menu_music_button( "menu/music.png" ) self.menu_chunk_button = Menu_music_button( "menu/chunk.png", 1 ) self.menu_exit_log = Menu_exit_log() self.menu_author_log = Menu_author_log() self.menu_game_log = Menu_link_button( "menu/game.png", "nothing", True ) self.menu_settings_log = Menu_link_button( "menu/settings.png", "nothing", True ) self.menu_score_log = Menu_score_log() self.menu_music = Menu_music( "menu/Rayman Legends OST - Moving Ground.mp3" ) self.wall = Wall() self.hero = Hero() self.menu_log = Menu_log() self.map = Map() #------------------------------------------------------------------------------------------------------- def load( self ): self.core.setState( -1 ) self.intro.load( self.core.getWidth(), self.core.getHeight() ) self.menu_title.load( self.core.getWidth() ) self.menu_play_button.load( self.core.getWidth(), self.core.getHeight() ) self.menu_git_button.load( self.core.getWidth(), 10 ) self.menu_google_button.load( self.core.getWidth(), self.menu_git_button.getBot() ) self.menu_facebook_button.load( self.core.getWidth(), self.menu_google_button.getBot() ) self.menu_twitter_button.load( self.core.getWidth(), self.menu_facebook_button.getBot() ) self.menu_music_button.load( 10 ) self.menu_chunk_button.load( self.menu_music_button.getBot() ) self.menu_exit_log.load( self.core.getWidth(), self.core.getHeight() ) self.menu_author_log.load( self.menu_play_button.getLeft()+5, self.core.getWidth(), self.menu_title.getBot() +150, self.menu_play_button.getBot() ) self.menu_game_log.load( self.menu_author_log.getRight(), self.menu_play_button.getBot() +10, True ) self.menu_settings_log.load( self.menu_game_log.getRight(), self.menu_play_button.getBot() +10, True ) self.menu_score_log.load( self.menu_settings_log.getRight(), self.core.getWidth(), self.menu_title.getBot() +150, self.menu_play_button.getBot() ) self.wall.load() self.hero.load( self.core.getWidth(), self.core.getHeight() ) self.menu_log.load( self.core.getWidth(), self.core.getHeight() ) self.map.load() #------------------------------------------------------------------------------------------------------- def handle( self ): for event in pygame.event.get(): if event.type == pygame.QUIT: self.core.setQuit() #------------------------------------------------------------------------------------------------------- if self.core.getState() == 0: if self.menu_play_button.getState() == 0: self.menu_exit_log.handle( event ) #HANDLE IF AUTHOR BUTTON == OFF AND SCORE BUTTON == OFF if self.menu_author_log.getState() == 0 and self.menu_score_log.getState() == 0: self.menu_play_button.handle( event ) self.menu_git_button.handle( event ) self.menu_google_button.handle( event ) self.menu_music_button.handle( event ) self.menu_chunk_button.handle( event ) if self.menu_score_log.getState() == 0: self.menu_author_log.handle( event ) if self.menu_author_log.getState() == 0: self.menu_score_log.handle( event ) #------------------------------------------------------------------------------------------------------- if self.core.getState() == 1: self.menu_log.handle( event ) #HANDLE IF MENU_LOG == OFF if self.menu_log.getState() == 0: self.hero.handle( event ) #------------------------------------------------------------------------------------------------------- def states( self ): #-------------------------------------------------------------------------------------------------------STATE -1 if self.core.getState() == -1: self.intro.draw( self.core.getWindow() ) if self.intro.getQuit(): self.intro.free() del self.intro self.menu_music.play()#MENU MUSIC self.core.setState( 0 ) #-------------------------------------------------------------------------------------------------------STATE 0 if self.core.getState() == 0: #FADE IN if self.menu_play_button.getState() != 1 and self.menu_exit_log.getState() == 0: self.menu_background.fadein( 5 ) self.menu_title.fadein( 5 ) self.menu_play_button.fadein( 5 ) self.menu_git_button.fadein( 5 ) self.menu_google_button.fadein( 5 ) self.menu_facebook_button.fadein( 5 ) self.menu_twitter_button.fadein( 5 ) self.menu_music_button.fadein( 5 ) self.menu_chunk_button.fadein( 5 ) self.menu_author_log.fadein( 5 ) self.menu_game_log.fadein( 5 ) self.menu_settings_log.fadein( 5 ) self.menu_score_log.fadein( 5 ) self.menu_music.setVolume( 1.0 ) #DRAW ALWAYS IN MENU STATE self.menu_background.draw( self.core.getWindow() ) self.menu_title.draw( self.core.getWindow() ) self.menu_exit_log.draw( self.core.getWindow() ) #DRAW IF AUTHOR BUTTON == OFF AND SCORE BUTTON == OFF if self.menu_author_log.getState() == 0 and self.menu_score_log.getState() == 0: self.menu_git_button.draw( self.core.getWindow() ) self.menu_google_button.draw( self.core.getWindow() ) self.menu_facebook_button.draw( self.core.getWindow() ) self.menu_twitter_button.draw( self.core.getWindow() ) self.menu_play_button.draw( self.core.getWindow() ) self.menu_music_button.draw( self.core.getWindow() ) self.menu_chunk_button.draw( self.core.getWindow() ) self.menu_game_log.draw( self.core.getWindow() ) self.menu_settings_log.draw( self.core.getWindow() ) if self.menu_score_log.getState() == 0: self.menu_author_log.draw( self.core.getWindow() ) if self.menu_author_log.getState() == 0: self.menu_score_log.draw( self.core.getWindow() ) #IF USER TURN ON/OFF CHUNKS if self.menu_chunk_button.getState(): self.menu_play_button.setState() self.menu_git_button.setState() self.menu_google_button.setState() self.menu_music_button.setState() self.menu_chunk_button.setState() self.menu_author_log.setState() self.menu_score_log.setState() #IF USER TURN ON/OFF MUSIC if self.menu_music_button.getState(): self.menu_music.pause() #IF USER PRESS Q - EXIT if self.menu_exit_log.getState() == 1: self.menu_background.fadeout( 6, 120 ) self.menu_title.fadeout( 6, 120 ) self.menu_play_button.fadeout( 6, 120 ) self.menu_git_button.fadeout( 6, 120 ) self.menu_google_button.fadeout( 6, 120 ) self.menu_facebook_button.fadeout( 6, 120 ) self.menu_twitter_button.fadeout( 6, 120 ) self.menu_music_button.fadeout( 6, 120 ) self.menu_chunk_button.fadeout( 6, 120 ) self.menu_author_log.fadeout( 6, 120 ) self.menu_game_log.fadeout( 6, 120 ) self.menu_settings_log.fadeout( 6, 120 ) self.menu_score_log.fadeout( 6, 120 ) self.menu_music.setVolume( 0.3 ) elif self.menu_exit_log.getState() == 2: self.menu_background.fadeout( 6 ) self.menu_title.fadeout( 6 ) self.menu_play_button.fadeout( 6 ) self.menu_git_button.fadeout( 6 ) self.menu_google_button.fadeout( 6 ) self.menu_facebook_button.fadeout( 6 ) self.menu_twitter_button.fadeout( 6 ) self.menu_music_button.fadeout( 6 ) self.menu_chunk_button.fadeout( 6 ) self.menu_author_log.fadeout( 6 ) self.menu_game_log.fadeout( 6 ) self.menu_settings_log.fadeout( 6 ) self.menu_score_log.fadeout( 6 ) if self.menu_exit_log.getState() == 2 and self.menu_background.getAlpha() == 0: self.core.setQuit() #IF USER CLICK PLAY BUTTON if self.menu_play_button.getState() == 1: self.menu_background.fadeout( 6 ) self.menu_title.fadeout( 6 ) self.menu_play_button.fadeout( 6 ) self.menu_git_button.fadeout( 6 ) self.menu_google_button.fadeout( 6 ) self.menu_facebook_button.fadeout( 6 ) self.menu_twitter_button.fadeout( 6 ) self.menu_music_button.fadeout( 6 ) self.menu_chunk_button.fadeout( 6 ) self.menu_author_log.fadeout( 6 ) self.menu_game_log.fadeout( 6 ) self.menu_settings_log.fadeout( 6 ) self.menu_score_log.fadeout( 6 ) if self.menu_music.isPaused() == False: self.menu_music.fadeOut() if self.menu_play_button.getAlpha() == 0: self.menu_play_button.setNext( 0 ) self.core.setState( 1 ) #-------------------------------------------------------------------------------------------------------STATE 1 if self.core.getState() == 1: #FADE IN IF PAUSE BUTTON == OFF AND MENU_LOG == OFF if self.menu_log.getState() == 0: self.wall.fadein( 5 ) self.hero.fadein( 5 ) self.map.fadein( 5 ) elif self.menu_log.getState() == 1: self.wall.fadeout( 6, 130 ) self.hero.fadeout( 6, 130 ) self.map.fadeout( 6, 130 ) elif self.menu_log.getState() == 2: self.wall.fadeout( 6 ) self.hero.fadeout( 6 ) self.map.fadeout( 6 ) if self.wall.getAlpha() == 0: self.menu_log.setState( 0 ) if self.menu_music.isPaused() == False: self.menu_music.play() self.core.setState( 0 ) #Back to menu #DRAW self.wall.draw( self.core.getWindow() ) self.hero.draw( self.core.getWindow() ) self.menu_log.draw( self.core.getWindow() ) self.map.draw( self.core.getWindow() ) def loop( self ): while not self.core.isQuit(): self.handle() self.core.fillDisplay() self.states() self.core.tickClock() pygame.display.update() def quit( self ): pygame.quit()
def main(): Intro()
def update_event(self, event): if event.type == KEYDOWN and event.key == K_ESCAPE: self.game.change_scene(Intro(self.game, True)) elif event.type == KEYDOWN: self.game.change_scene(self.nextScene(self.game))
import sys from time import sleep from open_file import OpenFile import webbrowser from git_upload import Upload from create_file import CreateFile print(""" |||||||| |||| || |||||||| |||||||| || || || || || || || || |||||||| || || || || || || || || || || || || || || || |||||||| || |||| |||||||| |||||||| """) intro = Intro('https://api.jsonbin.io/b/5c26fbae412d482eae5706fc') intro.show_details() web_data = 'https://api.jsonbin.io/b/5c26bd046265442e46fe1f1c/3' app_data = 'https://api.jsonbin.io/b/5c2ea1c57b31f426f8508620/5' installer = Installer() upload = Upload() def endo(): command = input() command = command.lower() if (command[:14]) == 'create project': website_name = command[17:] upload.repository_name = website_name data = GetData(web_data) if hasattr(data, 'is_loaded') and data.is_loaded == True: installer.run_installer(data.json_data, website_name)
def input_listener(self): render_rate = 0 anim = True while True: start_time = time.time() key = None if terminal.has_input() or self.pause == True: key = terminal.read() ################### ## Mouse catcher ## need to catch all mouse input or pause doesn't work ################### if (key == terminal.TK_MOUSE_SCROLL): print('mouse') self.tile_size -= int(terminal.state(terminal.TK_MOUSE_WHEEL)) terminal.set(f"font: MegaFont.ttf, size={self.tile_size}") key = None continue if (key == terminal.TK_MOUSE_RIGHT): key = None continue if self.input_state == 'main': self.pause = True if (key == terminal.TK_MOUSE_LEFT): self.main_menu(0, terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y), True, False) if (key == terminal.TK_MOUSE_MOVE): self.main_menu(0, terminal.state(terminal.TK_MOUSE_X), terminal.state(terminal.TK_MOUSE_Y), False, False) key = None if (key == terminal.TK_UP or key == terminal.TK_KP_8): self.main_menu(-1, 0, 0, False, False) if (key == terminal.TK_DOWN or key == terminal.TK_KP_2): self.main_menu(1, 0, 0, False, False) if (key == terminal.TK_ENTER): self.main_menu(0, 0, 0, False, True) if (key == terminal.TK_ESCAPE) and self.coords != []: self.input_state = 'sector' key = None if self.input_state == 'intro': Intro.play_intro(self, 1) if (key == terminal.TK_ENTER) or (key == terminal.TK_ESCAPE) or ( key == terminal.TK_MOUSE_LEFT): self.main_menu(0, 0, 0, False, False) if self.input_state == 'sector loaded': print('loaded') if (key == terminal.TK_ENTER) or (key == terminal.TK_ESCAPE) or ( key == terminal.TK_MOUSE_LEFT): self.input_state = 'sector' terminal.clear() key = None if self.input_state == 'sector': if (key == terminal.TK_LEFT or key == terminal.TK_KP_4 or key == terminal.TK_KP_7 or key == terminal.TK_KP_1): self.move_character(0, -1, 0) if (key == terminal.TK_RIGHT or key == terminal.TK_KP_6 or key == terminal.TK_KP_3 or key == terminal.TK_KP_9): self.move_character(0, 1, 0) if (key == terminal.TK_UP or key == terminal.TK_KP_8 or key == terminal.TK_KP_9 or key == terminal.TK_KP_7): self.move_character(0, 0, -1) if (key == terminal.TK_DOWN or key == terminal.TK_KP_2 or key == terminal.TK_KP_1 or key == terminal.TK_KP_3): self.move_character(0, 0, 1) if (key == terminal.TK_W or key == terminal.TK_KP_MINUS): self.move_character(-1, 0, 0) if (key == terminal.TK_S or key == terminal.TK_KP_PLUS): self.move_character(1, 0, 0) if (key == terminal.TK_SPACE): self.pause = not self.pause if self.pause: self.dev_console("[color=yellow]PAUSED ", 0) else: self.dev_console("[color=dark red]realtime", 0) ######################## ## animation modifier ## ######################## render_rate += 1 if render_rate >= 15: render_rate = 0 anim = True render_starchart(self, anim) if (key == terminal.TK_ESCAPE): self.main_menu(0, 0, 0, False, False) # always active if (key == terminal.TK_CLOSE): break if (key == terminal.TK_RESIZED): print('hello') anim = False ########################## # mainloop frame counter # ########################## delta = int(time.time() * 1000 - start_time * 1000) target_framerate = 15 if delta < target_framerate: terminal.delay(target_framerate - delta) if self.input_state != 'intro' and self.input_state != 'main' and self.dev_mode == True: # main loop time in milliseconds self.dev_console("Loop: " + str(delta), 2) # current frames per second (not averaged) self.dev_console( "FPS: " + str(int(1.0 / (time.time() - start_time))), 3)
def update_event(self, event): if event.type == KEYDOWN or event.type == MOUSEBUTTONDOWN: self.game.change_scene(Intro(self.game, True))
def main(): # in a compiled exe this can be called. if "analyse_play.py" in sys.argv: import analyse_play analyse_play.main() return data.where_to = "" #print "Hello from your game's main()" #print data.load('sample.txt').read() #pygame.mixer.pre_init(44100,-16,2, 1024* 4) #pygame.mixer.pre_init(44100,-16,2, 1024* 4) pygame.init() pygame.fastevent.init() pygame.threads.init(4) analyse_thread.init() # start playing intro track, before the screen comes up. if 1: if 1: intro_track = os.path.join("data", "intro.ogg") intro_sound_big = pygame.mixer.Sound(open(intro_track, "rb")) intro_sound_big.play(-1) else: try: intro_track = os.path.join("data", "intro.ogg") pygame.mixer.music.load(intro_track) pygame.mixer.music.play(-1) except: print "failed playing music track: '%s'" % intro_track else: print "1 asdf" intro_track = os.path.join("data", "intro.ogg") print "2 asdf" intro_sound = pygame.mixer.Sound(open(intro_track, "rb")) print "3 asdf" intro_array = _array_samples(intro_sound, 1)[:705600/2] print "4 asdf" # assert len(intro_array) == 705600 for i in range(1): # 4 x longer intro_array = numpy.append(intro_array, intro_array, 0) print "5 asdf" intro_sound_big = pygame.sndarray.make_sound(intro_array) print "6 asdf" pygame.time.set_timer(constants.INTRO_FADEOUT, 31000) intro_sound_big.play() print "7 asdf" screen = pygame.display.set_mode(constants.SCREEN_SIZE) top = Top(name = "Eye stabs. Do you?") top.set_main() # Add the intro as a child Game to the top Game. intro = Intro(name ="eye stab intro") intro.loop_ogg = intro_sound_big top.video_intro = VideoPlayer() intro.games.append(top.video_intro) top.gig_select = GigSelect(screen.copy()) top.games.append(top.gig_select) top.gig_select.stop() #intro = top.gig_select # store the player object. #player.player = player.Player() top.eyefix = EyeFixResult() top.games.append(top.eyefix) top.eyefix.stop() #intro = top.eyefix top.doctors_surgery = DoctorsSurgery(screen.copy()) top.games.append(top.doctors_surgery) top.doctors_surgery.stop() top.games.append(intro) top.intro = intro note_guess = NoteGuess(name="Eye stabs. Note Guess") # stop the note_guess part, because we are not ready yet. note_guess.stop() top.games.append(note_guess) top.note_guess = note_guess import urdpyg.sounds data.sounds = urdpyg.sounds.SoundManager() data.sounds.Load(urdpyg.sounds.SOUND_LIST, os.path.join("data", "sounds")) clock = pygame.time.Clock() clock.tick() while top.going: elapsed_time = clock.get_time() if elapsed_time: elapsed_time = elapsed_time / 1000. # speed up time... #elapsed_time *= 4 events = pygame.fastevent.get() if [e for e in events if e.type == constants.INTRO_FADEOUT]: intro_sound_big.fadeout(1000) # intro_sound_big.stop() # we pass in the events so all of them can get the events. top.handle_events(events) # each part that uses time, for animation or otherwise # gets the same amount of elapsed time. This also reduces the # number of system calls (gettimeofday) to one per frame. top.update(elapsed_time) data.sounds.Update(elapsed_time) # the draw method retunrns a list of rects, # for where the screen needs to be updated. rects = top.draw(screen) # remove empty rects. rects = filter(lambda x: x != [], rects) #rects = filter(lambda x: type(x) not in map(type, [pygame.Rect, [], tuple([1,2])]) , rects) rects = filter(lambda x: type(x) not in map(type, [1]) , rects) # if not empty, then update the display. if rects != []: #print rects pygame.display.update(rects) #pygame.display.update(rects) # we ask the clock to try and stay at a FPS rate( eg 30fps). # It won't get exactly this, but it tries to get close. clock.tick(constants.FPS) #print clock.get_fps() # we try and clean up explicitly, and more nicely... # rather than hoping python will clean up correctly for us. pygame.quit() pygame.threads.quit() analyse_thread.quit()
from intro import Intro Intro.game_intro()
import smtplib from intro import Intro Intr = Intro() def send_mail(df, mail): port = 587 # For starttls # Create a secure SSL context s = smtplib.SMTP('smtp.gmail.com', port) # start TLS for security s.starttls() # Authentication s.login("email", "pass") # message to be sent message = df try: # sending the mail s.sendmail("*****@*****.**", mail, str(message)) except: Intr.Warnings(cmd=Intr.WRONG_EMAIL) finally: s.quit()
# создание поля gf.create_fleet_enemy(background, enemy_group, stats.level) gf.create_fleet(width_background, height_background, wall_group_up, wall_group_down, ground_group, ladder_group, door_group, end_group, traider_group, Wall(False).rect.h) for sprite in wall_group_up: nn = sprite.rect.y break player = Player(screen, screen_rect.centerx, nn) player_group.add(player) play_button = Button(screen, "Play", screen_rect.centerx - 100, screen_rect.centery, (100, 150, 50)) game_over_button = Button(screen, "New", screen_rect.centerx - 100, screen_rect.centery, (100, 150, 50)) quit_button = Button(screen, "quit", screen_rect.centerx - 100, screen_rect.centery + 70, (100, 150, 50)) return_intro_button = Button(screen, "return intro", screen_rect.centerx - 100, screen_rect.centery + 130, (100, 150, 50)) camera = Camera() intro = Intro(screen, stats) shop = Shop(screen, stats) help_image = gf.load_image('help.png') while stats.game_active: # действия с квавиатуры и мыши gf.key_evens(screen, player, bullets, ladder_group, door_group, play_button, game_over_button, camera, stats, intro, background, end_group, enemy_group, wall_group_down, wall_group_up, ground_group, quit_button, return_intro_button, traider_group, shop) if stats.game_intro: # интро игры intro.blit() else: if stats.game_return: # переход через интро gf.new_fleet(screen, background, end_group, enemy_group, wall_group_down, wall_group_up, ladder_group, ground_group, door_group, stats, player, camera, traider_group)
from images import Images from maps import* from intro import Intro from item import* import turtle import math import random import time import winsound for image in Images: turtle.register_shape(image) #intro screen #------------------------------ Intro() #main screen #------------------------------ wn = turtle.Screen() wn.bgcolor("black") wn.title("7 Dungeons Deep (7DD)") wn.setup(1900,930) wn.bgpic(".\\art\\background.gif") wn.tracer(0) particles = [] for i in range(15): particles.append(Particle("circle", "red", 0, 0))