def handle_event(e): global player global TileSetMode global isPaused global pauseMenu if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: pause_state() if not isPaused: player.handle_event(e) else: if e.type == SDL_KEYDOWN: if e.key == SDLK_DOWN and pauseMenu < 2: pauseMenu += 1 elif e.key == SDLK_UP and pauseMenu > 0: pauseMenu -= 1 elif e.key == SDLK_RETURN: if pauseMenu == 0: isPaused = False elif pauseMenu == 1: save_pickle() elif pauseMenu == 2: gfw.pop()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): gfw.push(game_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.change(title_state) elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_p): gfw.pop()
def handle_event(self, e): if e.type == SDL_QUIT: gfw.quit() if e.type == SDL_KEYDOWN: if e.key == SDLK_LEFT: self.keydown += 1 self.direction = 0 self.fidy = 3 self.dx -= 1 if e.key == SDLK_RIGHT: self.keydown += 1 self.direction = 1 self.fidy = 8 self.dx += 1 if e.key == SDLK_DOWN: self.keydown += 1 if self.direction == 1: self.fidy = 8 elif self.direction == 0: self.fidy = 3 self.dy -= 1 if e.key == SDLK_UP: self.keydown += 1 if self.direction == 1: self.fidy = 8 elif self.direction == 0: self.fidy = 3 self.dy += 1 if e.type == SDL_KEYUP: self.keydown -= 1 if e.key == SDLK_LEFT: if self.keydown == 0: self.fidy = 4 self.dx += 1 if e.key == SDLK_RIGHT: if self.keydown == 0: self.fidy = 9 self.dx -= 1 if e.key == SDLK_DOWN: if self.keydown == 0: if self.direction == 1: self.fidy = 9 elif self.direction == 0: self.fidy = 4 self.dy += 1 if e.key == SDLK_UP: if self.keydown == 0: if self.direction == 1: self.fidy = 9 elif self.direction == 0: self.fidy = 4 self.dy -= 1 elif e.type == SDL_MOUSEBUTTONDOWN and self.delay_attack == 0: self.delay_attack = 30 if self.attackcount == 0: self.at_sound1.play() self.attack((e.x, get_canvas_height() - e.y - 1)) self.state = 1
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() # print('ms.he()', e.type, e) if handle_mouse(e): return
def handle_event(e): global player, set_tile # prev_dx = boy.dx if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_SPACE: f = open(FILE_NAME, "wb") pickle.dump(data_tile, f) f.close() elif e.key == SDLK_a: set_tile += 1 if set_tile > 3: set_tile = 0 if e.key == SDLK_ESCAPE: gfw.pop() player.handle_event(e) if e.type == SDL_MOUSEBUTTONDOWN: mouse_pos = bg.translate((e.x, get_canvas_height() - 1 - e.y)) player_xindex = (int)(mouse_pos[0] // 68) player_yindex = (int)(mouse_pos[1] // 82) if e.button == SDL_BUTTON_LEFT: data_tile[player_yindex][player_xindex].tile = set_tile data_tile[player_yindex][player_xindex].pos = (player_xindex, player_yindex) data_tile[player_yindex][player_xindex].col = True elif e.button == SDL_BUTTON_RIGHT: data_tile[player_yindex][player_xindex].tile = 0 data_tile[player_yindex][player_xindex].pos = (0, 0) data_tile[player_yindex][player_xindex].col = False
def handle_event(e): global idx1, idx2, idx3, idx4, cursorPos, pick, pickX, pickY, ch_pick if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_LEFT): if cursorPos > 0: cursorPos -= 1 elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_RIGHT): if cursorPos < 3: cursorPos += 1 if (e.type, e.key) == (SDL_KEYDOWN, SDLK_a): if cursorPos == 0: pick = True pickX = 120 elif cursorPos == 1: pick = True pickX = 300 elif cursorPos == 2: pick = True pickX = 480 elif cursorPos == 3: sound.play() pick = True pickX = 660
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): gfw.change(select_state)
def handle_event(e): global player if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.pop() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): boy.fire()
def handle_event(e): # prev_dx = boy.dx if e.type == SDL_QUIT: gfw.quit() return elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: Scene_Result.set_score(score) gfw.change(Scene_Result, player.select) return elif e.key == SDLK_RETURN: effect_s.play(1) elif e.key == SDLK_SPACE: effect_j.play(1) elif e.key == SDLK_a: # player.pos = 150,650 # for x, y in [(100,400),(400,300),(650,250),(900,200)]: for i in range(10): x = random.randint(100, 900) y = random.randint(200, 400) pf = Platform(Platform.T_3x1, x, y) gfw.world.add(gfw.layer.platform, pf) elif e.key == SDLK_p: global paused paused = not paused if player.handle_event(e): return
def handle_event(e): global running if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.pop() cookie.handle_event(e)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() return elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop() return elif e.key == SDLK_p: global paused paused = not paused elif e.key == SDLK_RETURN: if not paused: return global prito_cooldown prito_cooldown = random.uniform(5, 10) paused = False bgm.repeat_play() elif e.key == SDLK_s: gfw.change(score_state) score_state.set_attempt(player.n_die) elif e.key == SDLK_d: global disabled disabled = not disabled player.handle_event(e) if not prito.handle_event(e): player.die()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() if handle_mouse(e): return
def update(): global alpha, cli delta_time = gfw.delta_time ALPHA_SIZE = 510 * delta_time / time if cli == False: if alpha < 255: alpha += ALPHA_SIZE if alpha >= 255: cli = True alpha = 255 elif cli == True: alpha -= ALPHA_SIZE if alpha <= 0: cli = False alpha = 0 global elapsed elapsed += delta_time global image global logo01 if logo01 == False: if elapsed >= time: gfw.image.unload(resource + 'logo01.png') image = gfw.image.load(resource + 'logo02.png') elapsed = 0.0 logo01 = True gfw.quit()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() if e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop() player.handle_event(e)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_x: wav_select.play() gfw.push(select_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_x: wav_entermain.play() gfw.push(main_state)
def draw(self): global health global weapon global pistol_ammo global shotgun_ammo x = 0 hp1d = health % 10 hp2d = health // 10 hp3d = health // 100 ammo1d = pistol_ammo % 10 ammo2d = pistol_ammo // 10 ammo3d = pistol_ammo // 100 shell1d = shotgun_ammo % 10 shell2d = shotgun_ammo // 10 shell3d = shotgun_ammo // 100 if health >= 80: x = 0 elif health >= 50: x = 1 elif health >= 20: x = 2 elif health > 0: x = 3 else: x = 4 x = x * 200 #print(health) self.image_bar.draw(400, 33) self.image_hud.clip_draw(x, 0, 200, 200, 400, 30) self.image_num.clip_draw(hp1d * 200, 0, 200, 200, 255, 33) self.image_num.clip_draw(hp2d * 200, 0, 200, 200, 230, 33) self.image_num.clip_draw(hp3d * 200, 0, 200, 200, 205, 33) if weapon == 1: self.image_num.clip_draw(ammo1d * 200, 0, 200, 200, 150, 33) self.image_num.clip_draw(ammo2d * 200, 0, 200, 200, 125, 33) self.image_num.clip_draw(ammo3d * 200, 0, 200, 200, 100, 33) elif weapon == 2: self.image_num.clip_draw(shell1d * 200, 0, 200, 200, 150, 33) self.image_num.clip_draw(shell2d * 200, 0, 200, 200, 125, 33) self.image_num.clip_draw(shell3d * 200, 0, 200, 200, 100, 33) self.image_numsmall.clip_draw(ammo1d * 100, 0, 100, 100, 650, 48) self.image_numsmall.clip_draw(ammo2d * 100, 0, 100, 100, 640, 48) self.image_numsmall.clip_draw(ammo3d * 100, 0, 100, 100, 630, 48) self.image_numsmall.clip_draw(shell1d * 100, 0, 100, 100, 650, 38) self.image_numsmall.clip_draw(shell2d * 100, 0, 100, 100, 640, 38) self.image_numsmall.clip_draw(shell3d * 100, 0, 100, 100, 630, 38) if health <= 0: self.death.play(1) delay(2) gfw.quit()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() global player player.handle_event(e)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif e.type == SDL_KEYDOWN: music_title.stop() gfw.push(game_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key in [SDLK_ESCAPE, SDLK_q]: gfw.quit() elif e.key in [SDLK_RETURN, SDLK_KP_ENTER]: gfw.push(main)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_RETURN): music.stop() gfw.push(game_state, 1, 100)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop() if e.key == SDLK_RETURN or e.key == SDLK_KP_ENTER: gfw.change(main_state)
def handle_event(e): global image, state if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() if e.type == SDL_MOUSEBUTTONDOWN: gfw.change(logo_state)
def handle_event(e): global player if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.change(main_state) player.handle_event(e)
def handle_event(e): global unit # prev_dx = boy.dx if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if e.key == SDLK_ESCAPE: gfw.pop()
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif(e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif(e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): music_bg.stop() gfw.push(main_state)
def handle_mouse(e): global press_1, press_2, select_3, select_2, select_1, menu_press if e.type == SDL_MOUSEMOTION: mx = e.x my = get_canvas_height() - 1 - e.y if menu_press == False: if mx > get_canvas_width() // 2 - 193 and mx < get_canvas_width( ) // 2 + 193 and my > 250 and my < 350: if press_1 == False: flip_wav.play() press_1 = True else: press_1 = False if mx > get_canvas_width() // 2 - 193 and mx < get_canvas_width( ) // 2 + 193 and my > 150 and my < 250: if press_2 == False: flip_wav.play() press_2 = True else: press_2 = False elif menu_press == True: if mx > get_canvas_width() // 2 - 110 and mx < get_canvas_width( ) // 2 + 110 and my > 350 and my < 450: if select_1 == False: flip_wav.play() select_1 = True else: select_1 = False if mx > get_canvas_width() // 2 - 110 and mx < get_canvas_width( ) // 2 + 110 and my > 250 and my < 350: if select_2 == False: flip_wav.play() select_2 = True else: select_2 = False if mx > get_canvas_width() // 2 - 130 and mx < get_canvas_width( ) // 2 + 130 and my > 150 and my < 250: if select_3 == False: flip_wav.play() select_3 = True else: select_3 = False if e.type == SDL_MOUSEBUTTONDOWN: if press_1 == True: menu_press = True if press_2 == True: gfw.quit() if select_1 == True: enemy_gen.difficulty = 0 gfw.push(help_state) if select_2 == True: enemy_gen.difficulty = 1 gfw.push(help_state) if select_3 == True: enemy_gen.difficulty = 2 gfw.push(help_state)
def handle_event(e): if e.type == SDL_QUIT: gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_ESCAPE): gfw.quit() elif (e.type, e.key) == (SDL_KEYDOWN, SDLK_SPACE): global titlemusic titlemusic.set_volume(0) gfw.push(game_state)