generated from mwc/project_game
Compare commits
4 Commits
22a241fd75
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8769519960 | ||
|
|
ed8f4d7126 | ||
|
|
ceac611ad2 | ||
|
|
4a9bcf1d5d |
21
Proposal.md
Normal file
21
Proposal.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#Game Proposal
|
||||||
|
|
||||||
|
##Team
|
||||||
|
I am working individually on this project.
|
||||||
|
|
||||||
|
#Game Overview
|
||||||
|
Title: Dodge
|
||||||
|
Vision: Players dodge the circle's and more scores they get the more faster the circle's start falling making it fun to play.
|
||||||
|
Appearance: The game would be inside a rectangle shaped box with circles inside falling from the top.
|
||||||
|
Interaction: Players will use left and right arrows to avoid the falling circles.
|
||||||
|
|
||||||
|
#Core Mechanics
|
||||||
|
1. Left and right arrows
|
||||||
|
2. Circles falling from the top
|
||||||
|
3. If a circle hits the players, the game ends.
|
||||||
|
|
||||||
|
#Milestone
|
||||||
|
Create the rectangle board with a player that can move to dodge the falling circles.
|
||||||
|
|
||||||
|
#Challeneges
|
||||||
|
I think the most challenging part would be to increase the speed of the circles falling from the top.
|
||||||
BIN
__pycache__/circle.cpython-312.pyc
Normal file
BIN
__pycache__/circle.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/circle.cpython-313.pyc
Normal file
BIN
__pycache__/circle.cpython-313.pyc
Normal file
Binary file not shown.
BIN
__pycache__/player.cpython-312.pyc
Normal file
BIN
__pycache__/player.cpython-312.pyc
Normal file
Binary file not shown.
26
circle.py
Normal file
26
circle.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from random import randint
|
||||||
|
class Circle:
|
||||||
|
name= "circle"
|
||||||
|
character = 'O'
|
||||||
|
|
||||||
|
def __init__(self, position):
|
||||||
|
self.position = position
|
||||||
|
|
||||||
|
def play_turn(self, game):
|
||||||
|
width, height = game.board_size
|
||||||
|
fall_speed = game.state.get("fall_speed", 1)
|
||||||
|
|
||||||
|
x, y = self.position
|
||||||
|
player = game.get_agent_by_name('player')
|
||||||
|
new_position = (x, y + 1)
|
||||||
|
|
||||||
|
if new_position == player.position:
|
||||||
|
game.end()
|
||||||
|
return
|
||||||
|
if y >= height - 1:
|
||||||
|
game.state["score"] += 1
|
||||||
|
if game.state["fall_speed"] < 5:
|
||||||
|
game.state["fall_speed"] += 1
|
||||||
|
self.position = (randint(0, width - 1), 0)
|
||||||
|
else:
|
||||||
|
self.position = new_position
|
||||||
18
circle_spawner.py
Normal file
18
circle_spawner.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
from random import randint
|
||||||
|
from circle import Circle
|
||||||
|
|
||||||
|
class CircleSpawner:
|
||||||
|
display = False
|
||||||
|
|
||||||
|
def play_turn(self, game):
|
||||||
|
width, height = game.board_size
|
||||||
|
game.state['score'] += 1
|
||||||
|
if self.should_spawn_circle(game.turn_number):
|
||||||
|
x= randint(0, width - 1)
|
||||||
|
new_circle= Circle((x,0))
|
||||||
|
game.add_agent(new_circle)
|
||||||
|
|
||||||
|
def should_spawn_circle(self, turn_number):
|
||||||
|
return randint(0, 200) < turn_number
|
||||||
|
|
||||||
|
|
||||||
16
nav_game.py
Normal file
16
nav_game.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
from retro.game import Game
|
||||||
|
from player import Player
|
||||||
|
from circle import Circle
|
||||||
|
|
||||||
|
|
||||||
|
board_size = (100, 25)
|
||||||
|
player = Player(board_size)
|
||||||
|
circle= Circle ((board_size[0] // 2, 0))
|
||||||
|
|
||||||
|
def during_turn(game):
|
||||||
|
pass
|
||||||
|
|
||||||
|
game = Game([player, circle], {"score": 0, "fall_speed": 1}, board_size=board_size)
|
||||||
|
|
||||||
|
game.during_turn = during_turn
|
||||||
|
game.play()
|
||||||
25
player.py
Normal file
25
player.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
class Player:
|
||||||
|
name = "player"
|
||||||
|
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):
|
||||||
|
if game.is_empty(new_position):
|
||||||
|
self.position = new_position
|
||||||
|
else:
|
||||||
|
game.end()
|
||||||
Reference in New Issue
Block a user