Skip to content

Instantly share code, notes, and snippets.

@galdosd
Last active December 7, 2015 23:24
Show Gist options
  • Save galdosd/dbf67860880f9f399a35 to your computer and use it in GitHub Desktop.
Save galdosd/dbf67860880f9f399a35 to your computer and use it in GitHub Desktop.
@game_predicate
def emergency(world):
# forgive the nasty
if world.alarm return True
if world.on_fire return True
if some other shit return True
return False
@game_predicate
def mario_riding_yoshi(world):
return nearby_each_other(world.mario, world.yoshi, max_distance=1)
@game_predicate
def player_alive(world):
return world.player_health > 0
@on_input(KEY_Y_DOWN)
@only_when(player_alive)
@only_when(mario_riding_yoshi)
def handle_tongue_lick(world):
tongue = world.create(Tongue, world.yoshi)
tongue.momentum = world.yoshi.momentum + INITIAL_TONGUE_MOMENTUM
# Tongue class automatically inherits from Simple Spring and obeys kx^2 type shit, but disappears entirely when it returns past its origin point?
@on_input(KEY_Y_DOWN)
@never_when(player_alive)
def handle_menu_cancel(world):
# if the player is not alive we are on a menu... we want to deal with menu cancel button in lots of other situations in menus so let's fire a recursive event
world.fire_event(KEY_MENU_CANCEL)
@on_input(KEY_MENU_CANCEL)
@only_when(current_menu_is(AUDIO_MENU))
def handle_cancel_music(world):
music_on = False
# all the npcs smoke a cigarette every game tick, if nothing crazy is going on
@on_input(TICK)
@never_when(emergency)
def handle_npcs_smoke(world):
world.npcs.forEach(npc -> npc.fire_event(SMOKE))
@on_input(PULL_ALARM)
def handle_pull_alarm(world)
world.alarm = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment