generated from mwc/project_game
In this milestone I created necessary files such as Starfall, starfall_spawner, person, and questioner. I used smaple codes from Retro and adjusted them to suit my purposes. I am proud of the Questioner file. I was intimidated that I would drop the ball on the dialogue spawn but after frustrating few tries, I manges to make it look and spawn as I wanted it to. I am now worried about how to make the starfall_spawner launch and abort as intended (start after answers then pause once player collects 200 points.) I learned new skills with how to accept input answers. I was reading up on ways to sort the answers and I learned about strip and upper functions that help remove spaces and lowercase specifications!
23 lines
788 B
Python
23 lines
788 B
Python
class Person:
|
|
name = "Person"
|
|
character = '^'
|
|
|
|
def __init__(self, board_size):
|
|
board_width, board_height = board_size
|
|
self.position = (board_width // 2, board_height - 1)
|
|
|
|
def handle_keystroke(self, keystroke, game):
|
|
x, y = self.position
|
|
if keystroke.name == "KEY_LEFT":
|
|
new_position = (x - 1, y)
|
|
elif keystroke.name == "KEY_RIGHT":
|
|
new_position = (x + 1, y)
|
|
elif keystroke.name == "KEY_UP":
|
|
new_position = (x, y - 1)
|
|
elif keystroke.name == "KEY_DOWN":
|
|
new_position = (x, y + 1)
|
|
else:
|
|
return
|
|
|
|
if game.on_board(new_position) and game.is_empty(new_position):
|
|
self.position = new_position |