def update(frame_time): global logo_time logo_time += frame_time if (logo_time > 1.0): logo_time = 0 GameFramework.push_state(State_Title)
def handle_events(frame_time): global arrowlist, gagelist, mouse_x, mouse_y, gage events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() elif event.type != SDL_QUIT: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): close_canvas() open_canvas() GameFramework.change_state(State_Main) elif (event.type) == SDL_MOUSEMOTION: mouse_x = event.x mouse_y = 750 - event.y elif event.type == SDL_MOUSEBUTTONDOWN: if event.button == SDL_BUTTON_LEFT: gage = Gage(mouse_x, mouse_y) gagelist.append(gage) elif event.type == SDL_MOUSEBUTTONUP: if event.button == SDL_BUTTON_LEFT: arrow = Arrow(gage.level) arrowlist.append(arrow) arrow.firearrow() gagelist.remove(gagelist[-1])
def update(): global elapsed elapsed += GameFramework.delta_time if (elapsed >= 1.0): GameFramework.change(TitleState)
def handle_event(event): global running if (event.type == SDL_QUIT): GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.quit()
def handle_event(event): if (event.type == SDL_QUIT): GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.pop() global STAGE_LEVEL if event.type == SDL_KEYDOWN: if event.key == SDLK_1: mario.pos = (100, 200) STAGE_LEVEL = 1 GameWorld.curr_objects = GameWorld.stage1_objects elif event.key == SDLK_2: mario.pos = (100, 200) STAGE_LEVEL = 2 GameWorld.curr_objects = GameWorld.stage2_objects elif event.key == SDLK_3: mario.pos = (750, 200) STAGE_LEVEL = 3 GameWorld.curr_objects = GameWorld.stage3_objects elif event.key == SDLK_4: mario.pos = (100, 200) STAGE_LEVEL = 4 GameWorld.curr_objects = GameWorld.stage4_objects elif event.key == SDLK_5: mario.pos = (100, 200) STAGE_LEVEL = 5 GameWorld.curr_objects = GameWorld.stage5_objects mario.handle_event(event)
def Update(self): if PCharacter.Player.move_x >= 500: self.mid_x -= PCharacter.Player.move_size if PCharacter.Player.move_x >= self.mid_x: Exit_door.Exit_flag = True if Exit_door.Show_once == False: Exit_door.Show_once = True Exit_door.change_theme = True PCharacter.Player.move_size = 0 if Exit_door.Exit_flag == True: if Exit_door.change_theme == True: #self.bgm = load_music('ending_theme.mp3') #self.bgm.set_volume(60) #self.bgm.repeat_play() Exit_door.change_theme = False self.change_scene_cnt += 1 if self.change_scene_cnt >= 120: self.change_scene_cnt = 0 GameFramework.change_state(ranking_state)
def handle_event(event): global running if (event.type == SDL_QUIT): GameFramework.quit() if (handle_mouse(event)): return
def update(frame_time): global sel_song sel_song.update() if (Song.coll_with_mouse): Song.coll_with_mouse = False Song.mouse_x, Song.mouse_y = 0, 0 GameFramework.change_state(FirstSongScene)
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: # Window X botton GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): # ESC pressed GameFramework.quit()
def handle_event(self, event): pair = (event.type, event.button) if (self.mouse_point == None): if (pair == LBUTTON_DOWN): if (GameObject.point_in_rect(GameObject.get_pico2d_pos(event), self.get_bb())): self.mouse_point = GameObject.get_pico2d_pos(event) if (self.menu == EXIT): self.left = 400 else: self.left = 300 return self if (event.type == SDL_MOUSEMOTION): mouse_pos = GameObject.get_pico2d_pos(event) in_rect = GameObject.point_in_rect(mouse_pos, self.get_bb()) if (in_rect): if (self.menu == EXIT): self.left = 400 else: self.left = 300 Button.SELECT_WAV.play() else: if (self.menu == EXIT): self.left = 100 else: self.left = 0 self.src_rect = (self.left, self.bottom, self.width, self.height) return False if (pair == LBUTTON_UP): self.mouse_point = None mouse_pos = GameObject.get_pico2d_pos(event) in_rect = GameObject.point_in_rect(mouse_pos, self.get_bb()) if (in_rect): if (self.menu == GAME_START): GameFramework.push(GameState) elif (self.menu == DESCRIPTION): pass elif (self.menu == EXIT): GameFramework.quit() return False if (event.type == SDL_MOUSEMOTION): mouse_pos = GameObject.get_pico2d_pos(event) in_rect = GameObject.point_in_rect(mouse_pos, self.get_bb()) if (in_rect): if (self.menu == EXIT): self.left = 400 else: self.left = 300 self.src_rect = (self.left, self.bottom, self.width, self.height) return False
def update(frame_time): global logo_time global opacify_state if logo_time > 2.0: logo_time = 0 GameFramework.push_state(title_state) #title_state opacify_state -= 0.005 logo_time += frame_time
def update(frame_time): global logo_time global opacify_state if logo_time > 2.0: logo_time = 0 GameFramework.push_state(main_state) opacify_state -= 0.0008 logo_time += frame_time
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() else: if (event.type, event.key) == ( SDL_KEYDOWN, SDLK_SPACE): #게임종료씬에서 SPACE를 누를경우 랭킹스테이트로 넘어감 GameFramework.change_state(ranking_state) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): close_canvas()
def handle_event(event): if (event.type == SDL_QUIT): GameFramework.quit() if (Button.IS_DES_DRAW): if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): Button.IS_DES_DRAW = False Button.DES_OFF_WAV.play() else: if (handle_mouse(event)): return
def handle_events(frame_time): events = get_events() global x, y for event in events: if event.type == SDL_QUIT: GameFramework.quit() elif (event.type, event.button) == (SDL_MOUSEBUTTONDOWN, SDL_BUTTON_LEFT): Song.mouse_x, Song.mouse_y = event.x, 900 - event.y else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.quit()
def Handle_Events(): events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.Quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.Quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_SPACE): GameFramework.Change_State(Scene_Stage1) pass
def Handle_Events(): events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.Quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.Quit() ObjectMgr.Handle_Events() pass
def update(frame_time): global cupid, obstaclehills, life, target global arrowlist, gagelist, fire_possible_flag, camera, backgroundbig, cloudlist backgroundbig.update(frame_time) cupid.update(frame_time) for arrow in arrowlist: arrow.update(frame_time) camera.get_arrowposition(arrow) backgroundbig.set_camera(camera) if (arrow.position_Y < 100): arrowlist.remove(arrow) camera.mapcamera_flag = True fire_possible_flag = True for cloud in cloudlist: cloud.update(frame_time) if life.lifepoint == 0: GameFramework.change_state(State_GameOver) for obstaclehill in obstaclehills: for arrow in arrowlist: if collide(arrow, obstaclehill): arrow.hit() arrowlist.remove(arrow) camera.mapcamera_flag = True fire_possible_flag = True life.decrease() elif collide(target, arrow): GameFramework.change_state(State_Clear) elif (arrow.position_Y < 0): arrowlist.remove(arrow) for cloud in cloudlist: for arrow in arrowlist: if collide(arrow, cloud): arrow.hit() arrowlist.remove(arrow) camera.mapcamera_flag = True fire_possible_flag = True life.decrease() for gage in gagelist: gage.update(frame_time)
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_F1): #랭킹스테이트에서 F1클릭시 메인스테이트로 넘어감 if PCharacter.Player.Player_Die == False: GameFramework.change_state(main_state) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): close_canvas()
def enter(): global background global character global stage_object global meso global font global sound global pinkbin_bar global sky_bar global flying_object_bar global stop_station global user_ui global button global combo global tile global obstacle global exit_door global exit_effect global ranking ranking = ranking_state.Ranking_state() background = PBackground.Background() character = PCharacter.Player() stage_object = PObject.StageObject() if main_lobby.Song.number == 2: stage_tile_cnt = 51 tile = PTile.Brick(stage_tile_cnt) meso = PObject.Point_meso() obstacle = PObstacle.Obstacle() pinkbin_bar = PUpBar.Pinkbinbar() sky_bar = PUpBar.Skybar() flying_object_bar = PUpBar.FlyingObject() stop_station = PUpBar.Stop_station() user_ui = Player_UI.User_UI() button = Button.Button_beat() combo = Combo.Combo() exit_door = PObject.Exit_door() exit_effect = PObject.Exit_effect() # 발판 생성자 다수생성 -> 임시값 #PTile.temp = [PTile.Brick() for i in range(50)] font = load_font('ENCR10B.TTF', 20) GameFramework.reset_time()
def handle_events(frame_time): global arrowlist, gagelist, mouse_x, mouse_y, gage global camera, fire_possible_flag events = get_events() for event in events: if event.type == SDL_QUIT: # 종 료 GameFramework.quit() if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): # 메인화면으로 close_canvas() open_canvas() GameFramework.change_state(State_Main) if event.type == SDL_KEYDOWN: if event.key == SDLK_LEFT or event.key == SDLK_RIGHT: camera.handle_event_camera(event) if event.type == SDL_KEYUP: if event.key == SDLK_LEFT or event.key == SDLK_RIGHT: camera.handle_event_camera(event) if (event.type) == SDL_MOUSEMOTION: # 마우스 좌표 취득 mouse_x = event.x mouse_y = 750 - event.y ################ 마우스 핸들 이벤트 ############################# if event.type == SDL_MOUSEBUTTONDOWN: if event.button == SDL_BUTTON_LEFT: camera.move_stop() camera.mapcamera_flag = False if camera.ballcamera_flag == True and fire_possible_flag == True: # 볼 카메라 활성화 준비되었고, 공이 발사 중이 아니면 gage = Gage(mouse_x, mouse_y) gagelist.append(gage) elif event.type == SDL_MOUSEBUTTONUP: if event.button == SDL_BUTTON_LEFT: if camera.ballcamera_flag == True and fire_possible_flag == True: camera.reset_camera() arrow = Arrow(gage.level) arrow.set_background(backgroundbig) arrowlist.append(arrow) arrow.firearrow() if gagelist != []: gagelist.remove(gagelist[-1]) fire_possible_flag = False
def handle_events(frame_time): global key_count events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): #종료 GameFramework.change_state(title_state) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_SPACE): if PCharacter.Player.CollwithTile == True: PCharacter.Player.jump_state = True elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_F1): #랭킹스테이터스로 넘어감 GameFramework.change_state(ranking_state) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_F2): #타이틀화면으로 넘어감 GameFramework.change_state(title_state) elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_a): key_count = 0 Button.Button_beat.a_button = True Button.Button_beat.s_button = False Button.Button_beat.d_button = False Button.Button_beat.f_button = False Button.Button_beat.b_button = False elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_s): key_count = 0 Button.Button_beat.a_button = False Button.Button_beat.s_button = True Button.Button_beat.d_button = False Button.Button_beat.f_button = False Button.Button_beat.b_button = False elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_d): key_count = 0 Button.Button_beat.a_button = False Button.Button_beat.s_button = False Button.Button_beat.d_button = True Button.Button_beat.f_button = False Button.Button_beat.b_button = False elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_f): key_count = 0 Button.Button_beat.a_button = False Button.Button_beat.s_button = False Button.Button_beat.d_button = False Button.Button_beat.f_button = True Button.Button_beat.b_button = False elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_b): key_count = 0 Button.Button_beat.a_button = False Button.Button_beat.s_button = False Button.Button_beat.d_button = False Button.Button_beat.f_button = False Button.Button_beat.b_button = True
def Update(): global Event global ObjLst for List in ObjLst: # num = len(List) # print(num) for GameObj in List: Event = GameObj.Update() # 게임 오브젝트 사망시 제거. if Event == -1: List.remove(GameObj) del GameObj # CollisionMgr global LstPlayer global LstMonster global LstPlayerBullet global LstItem CollisionMgr.Collision_Monster_PLBullet(LstMonster, LstPlayerBullet, LstPlayer[0]) CollisionMgr.Collision_Monster_PLLaser(LstMonster, LstPlayerLaser, LstPlayer[0]) CollisionMgr.Collision_Player_Item(LstPlayer, LstItem) global bIsCollision if bIsCollision: if CollisionMgr.Collision_Monster_Player(LstMonster, LstPlayer): GameFramework.Change_State(Scene_Score) return if CollisionMgr.Collision_Monster_Player(LstMonsterBullet, LstPlayer): GameFramework.Change_State(Scene_Score) return if Scene_Stage1.IsDead_BossStage2: GameFramework.Change_State(Scene_Score) return pass
def handle_event(self, event): pair = (event.type, event.button) if (self.mouse_point == None): if (pair == LBUTTON_DOWN): if (GameObject.point_in_rect(GameObject.get_pico2d_pos(event), self.get_bb())): self.mouse_point = GameObject.get_pico2d_pos(event) self.rect = Button.ON_IMAGE_RECT[self.menu] return self if (event.type == SDL_MOUSEMOTION): mouse_pos = GameObject.get_pico2d_pos(event) in_rect = GameObject.point_in_rect(mouse_pos, self.get_bb()) if (in_rect): self.rect = Button.ON_IMAGE_RECT[self.menu] Button.SELECT_WAV.play() else: self.rect = Button.OFF_IMAGE_RECT[self.menu] return False if (pair == LBUTTON_UP): self.mouse_point = None mouse_pos = GameObject.get_pico2d_pos(event) in_rect = GameObject.point_in_rect(mouse_pos, self.get_bb()) if (in_rect): if (self.menu == GAME_START): GameFramework.push(GameState) elif (self.menu == DESCRIPTION): Button.IS_DES_DRAW = True Button.DES_ON_WAV.play() elif (self.menu == EXIT): GameFramework.quit() return False
def update(frame_time): global cupid, arrowlist, gagelist, obstaclehills, life cupid.update(frame_time) for arrow in arrowlist: arrow.update(frame_time) for gage in gagelist: gage.update(frame_time) if life.lifepoint == 0: GameFramework.change_state(State_GameOver) for obstaclehill in obstaclehills: for arrow in arrowlist: if collide(arrow, obstaclehill): arrow.hit() arrowlist.remove(arrow) life.decrease() elif collide(arrow, target): GameFramework.change_state(State_Clear) elif (arrow.position_Y < 80): arrowlist.remove(arrow)
def handle_events(frame_time): events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_SPACE): GameFramework.change_state(State_Main)
def handle_events(frame_time): global mouse_X, mouse_Y, mouse, button_normal, button_hard events = get_events() for event in events: if event.type == SDL_QUIT: GameFramework.quit() else: if (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.push_state(State_Title) if (collide(button_normal, mouse)): if event.type == SDL_MOUSEBUTTONDOWN: if event.button == SDL_BUTTON_LEFT: GameFramework.change_state(Difficulty_normal) if (collide(button_hard, mouse)): if event.type == SDL_MOUSEBUTTONDOWN: if event.button == SDL_BUTTON_LEFT: GameFramework.change_state(Difficulty_hard) ### 버튼과 마우스 좌표 ### if event.type == SDL_MOUSEMOTION: mouse_X = event.x mouse_Y = 600 - event.y mouse.get_mouse_position(mouse_X, mouse_Y)
def handle_event(event): if (event.type == SDL_QUIT): GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.pop() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_UP): if (GameSprite.Door.OPENS and is_with_door): GameFramework.push(EndingState) # 각 스테이지 디버그 #global STAGE_LEVEL #if event.type == SDL_KEYDOWN: # if event.key == SDLK_1: # STAGE_LEVEL = 1 # mario.pos = (100, 200) # background.set_stage_level(STAGE_LEVEL) # GameWorld.curr_objects = GameWorld.stage1_objects # elif event.key == SDLK_2: # STAGE_LEVEL = 2 # mario.pos = (100, 200) # background.set_stage_level(STAGE_LEVEL) # GameWorld.curr_objects = GameWorld.stage2_objects # elif event.key == SDLK_3: # mario.pos = (750, 200) # STAGE_LEVEL = 3 # background.set_stage_level(STAGE_LEVEL) # GameWorld.curr_objects = GameWorld.stage3_objects # elif event.key == SDLK_4: # STAGE_LEVEL = 4 # mario.pos = (100, 200) # background.set_stage_level(STAGE_LEVEL) # GameWorld.curr_objects = GameWorld.stage4_objects # elif event.key == SDLK_5: # STAGE_LEVEL = 5 # mario.pos = (100, 200) # background.set_stage_level(STAGE_LEVEL - 2) # GameWorld.curr_objects = GameWorld.stage5_objects mario.handle_event(event)
def enter(): close_canvas() GameFramework.reset_time() open_canvas(1500, 750) create_world()
def draw(): background.draw(400, 300) def handle_event(event): global running if (event.type == SDL_QUIT): GameFramework.quit() elif (event.type, event.key) == (SDL_KEYDOWN, SDLK_ESCAPE): GameFramework.quit() def exit(): global background del background def pause(): pass def resume(): pass if (__name__ == "__main__"): GameFramework.run_main()