From 885f3de38fef5351b3b9ad98b6357ffec2306fd7 Mon Sep 17 00:00:00 2001 From: cramsey Date: Wed, 14 Jan 2026 09:47:19 -0500 Subject: [PATCH] @chris need helo wuth health --- .commit_template | 4 +-- game.py | 3 ++ obstacle.py | 22 +++++++++++++ obstacle_spawner.py | 13 ++++++++ point_system.py | 23 ++++++++++++++ proposal.md | 13 ++++++++ pyproject.toml | 21 +++++++------ runner.py | 75 +++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 game.py create mode 100644 obstacle.py create mode 100644 obstacle_spawner.py create mode 100644 point_system.py create mode 100644 proposal.md create mode 100644 runner.py diff --git a/.commit_template b/.commit_template index 8985799..6869d03 100644 --- a/.commit_template +++ b/.commit_template @@ -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. diff --git a/game.py b/game.py new file mode 100644 index 0000000..9706a38 --- /dev/null +++ b/game.py @@ -0,0 +1,3 @@ +from retro.game import retro +from runner import Runner +from scene import Scene \ No newline at end of file diff --git a/obstacle.py b/obstacle.py new file mode 100644 index 0000000..5fdd098 --- /dev/null +++ b/obstacle.py @@ -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 diff --git a/obstacle_spawner.py b/obstacle_spawner.py new file mode 100644 index 0000000..afa12fa --- /dev/null +++ b/obstacle_spawner.py @@ -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 + \ No newline at end of file diff --git a/point_system.py b/point_system.py new file mode 100644 index 0000000..1bb1f22 --- /dev/null +++ b/point_system.py @@ -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 \ No newline at end of file diff --git a/proposal.md b/proposal.md new file mode 100644 index 0000000..3bb8e6b --- /dev/null +++ b/proposal.md @@ -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. \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7ce89ea..ad6297d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" \ No newline at end of file diff --git a/runner.py b/runner.py new file mode 100644 index 0000000..f30c0ca --- /dev/null +++ b/runner.py @@ -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)) + + \ No newline at end of file