Created
March 14, 2013 04:41
-
-
Save gulnara/5158857 to your computer and use it in GitHub Desktop.
eat the boy in the princess game
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target_el = GAME_BOARD.get_el(self.x, self.y) | |
if target_el == PLAYER: | |
global GAME_OVER | |
GAME_OVER = True | |
GAME_BOARD.draw_msg("You've been eaten! Ha Ha Ha!") | |
self.board.set_el(self.x, self.y, self) | |
_____ | |
def keyboard_handler(): | |
if GAME_OVER == True: | |
return | |
direction = None | |
if KEYBOARD[key.UP]: | |
direction = "UP" | |
elif KEYBOARD[key.DOWN]: | |
direction = "DOWN" | |
elif KEYBOARD[key.LEFT]: | |
direction = "LEFT" | |
elif KEYBOARD[key.RIGHT]: | |
direction = "RIGHT" | |
if direction: | |
next_location = PLAYER.next_pos(direction) | |
next_x = next_location[0] | |
next_y = next_location[1] | |
if next_x > GAME_WIDTH - 2 or next_x < 1: | |
return | |
if next_y > GAME_HEIGHT - 2 or next_y < 1: | |
return | |
existing_el = GAME_BOARD.get_el(next_x, next_y) | |
if existing_el: | |
existing_el.interact(PLAYER) | |
if existing_el is None or not existing_el.SOLID: | |
GAME_BOARD.del_el(PLAYER.x, PLAYER.y) | |
GAME_BOARD.set_el(next_x, next_y, PLAYER) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment