@chris need helo wuth health

This commit is contained in:
cramsey
2026-01-14 09:47:19 -05:00
parent e01d866eaa
commit 885f3de38f
8 changed files with 163 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
# -----------------------------------------------------------------
@chris I kind of need help with the health (still figuring out how this would work), rings (somehow all over the map and the player can pick them up to gain speed: running into an obstacle looses you 10 rings - game is still playable with zero rings <-- possibly subject to change), also i was wondering if it would be possible to have the character's colours switch when jumping or ducking so the user knows it happened (colour gets lighter for jump and darker for ducking), also is there a way to make it so the obstacles are randomly selected? will there be individual menu screens for each game and will we be coding them to look how we want? I'm not sure how to code most of this so help would be greatly appreciated, thank you.
-----------------------------------------------------------------
# Write your entire commit message above this line.
#
# The first line should be a quick description of your latest progress.

3
game.py Normal file
View File

@@ -0,0 +1,3 @@
from retro.game import retro
from runner import Runner
from scene import Scene

22
obstacle.py Normal file
View File

@@ -0,0 +1,22 @@
import retro
(update)
class Scene:
character A:'===='
character B:'M'
def __init__(self, position):
self.position -= position
def play_turn(self, game):
if game.turn_number % 2 == 0:
x, y = self.position
if y == HEIGHT - 1:
game.remove_agent_by_name(self.name)
else:
runner = game.get_agent_by_name('ship')
new_position = (x, y + 1)
if new_position == runner.position:
game.end()
else:
self.position = new_position

13
obstacle_spawner.py Normal file
View File

@@ -0,0 +1,13 @@
from random import randint
from scene import Scene
class SceneSpawner:
#display = false ?
def __init__(self, board_size):
width, height = board_size
self.board_width = width
def play_turn(self, game):
game.state['score'] += 1

23
point_system.py Normal file
View File

@@ -0,0 +1,23 @@
(update)
score = 100
player_rect = pygame.Rect(50, 50, 40, 40)
obstacle_rect = pygame.Rect(200, 50, 40, 40)
if player_rect.colliderect(obstacle_rect):
score -= 10
can_lose_points = True
cooldowm_time = 1000 #miliseconds
last_hit_time = 0
current_time = pygame.time.get.ticks()
if player_rect.colliderect(obstacle_rect) and can_lose_points:
score -= 10
can_lose_points = False
last_hit_time = current_time
if not can_lose_points and current_time - last_hit_time > cooldown_time:
can_lose_points = True

13
proposal.md Normal file
View File

@@ -0,0 +1,13 @@
Team -- individual project
Game Overview -- [name is a wip]
1. the game will heavily inspired off of sonic forces, the character(s) can switch lanes and jump. The reason I choose this type of game is because I love sonic forces and the sonic franchise in general. I also think I can learn more on how to code and coding tactics by taking on this project.
2. The game will be designed as the basic sonic setting, with three lanes for the player(s) to move in. There will be obstacles the player(s) need to jump or duck/slide over occasionally in the path.
3. the player or players will play the game by using the joystick to select the character they want and switch lanes, the buttons will allow the player to jump, duck/slide, and also works as another way to switch lanes.
Core Mechanics -- collecting rings, getting over obstacless, not dying
Milestone -- I can implement features from other coding I've done and also create characters for different sonic characters
Challenges -- uh I kind of don't even know how to start coding my game nor how to code running, jumping etc.

View File

@@ -5,17 +5,20 @@ description = ""
authors = [
{name = "Chris Proctor",email = "chris@chrisproctor.net"}
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.10,<4.0"
requires-python = ">=3.10, <4.0"
dependencies = [
"retro-games (>=1.1.0,<2.0.0)"
"retro-games>=1.0.0",
]
[project.scripts]
play = "game:play"
[tool.retro]
author = ""
description = ""
instructions = ""
result_file = "result.json"
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
package-mode = false
requires = ["poetry-core>=2.0.0, <3.0.0"]
build-backend = "poetry.core.masonry.api"

75
runner.py Normal file
View File

@@ -0,0 +1,75 @@
import retro
(update)
class Runner:
name = "[selected characters name]"
character = '0'
characters = ["Sonic", "Tails", "Knuckles", "Amy", "Shadow", "Silver", "Surge", "Rouge", "Jet"]
print("Choose a character:")
for i, char in enumerate(characters):
print(f"{i+1}, {char}")
choice = int(input("Enter number: "))
selected_character = character[choice - 1]
print("You chose:", selected_character)
character_colors = {
#find the numbers needed for the colours + feel free to add more characters
"Sonic": (0, 0, 255), #blue
"Tails": (225, 255, 0), #yellow
"Knuckles": (255, 0, 0), #red
"Amy": (255, 192, 203), #pink
"Shadow": (0, 0, 0), #black
"Silver": (211, 211, 211), #light grey
"Surge": (144, 238, 144), #light green
"Rouge": (255, 255, 255), #white
"Jet": (0, 128, 0), #green
"Cream": (245, 245, 220), #creamy beige (use '240, 230, 200' if this colour doesn't work)
"Super Sonic": (255, 255, 224) #light yellow
"Super Shadow": (255, 255, 240) #pale yellow
}
selected_character = ""
player_color = character_colors{selected_character}
def __init__(self):
self.y = 450
self.width = 40
self.height = 60
self.lanes = [250, 400, 550]
self.current_lane = 1
self.x = self.lanes[self.current_lane]
self.forward_speed = 5
self.lane_switch_speed = 10
def move_left(self):
if self.current_lane > 0:
self.current_lane -= 1
def move_right(self):
if self.current_lane < len(self.lanes) - 1:
self.current_lane += 1
def update(self):
self.y -= self.forward_speed
target_x = self.lanes[self.current_lane]
if self.x < target_x:
self.x += self.lane_switch_speed
if self.x > target_x:
self.x = target_x
elif self.x > target_x:
self.x -= self.lane_switch_speed
if self.x < target_x:
self.x = target_x
def draw(self, screen):
retro.draw.rect(
screen, (0, 200, 255), (self.x, self.y, self.width, self.height))