Skip to content
Open
Show file tree
Hide file tree
Changes from 66 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
94ec920
refactor: update snake part management to use SnakePartRepository
dmccoystephenson Jun 7, 2025
8f75c33
feat: implement EnvironmentRepository for managing game environment
dmccoystephenson Jun 7, 2025
6b3cc21
refactor: remove unused direction methods from ophidian.py
dmccoystephenson Jun 7, 2025
d8df4da
feat: implement key down event handling in a separate class
dmccoystephenson Jun 7, 2025
7eb9c2d
fix: ensure proper return values in key down event handling
dmccoystephenson Jun 7, 2025
bc43e1f
refactor: streamline entity location management in EnvironmentRepository
dmccoystephenson Jun 7, 2025
ef92111
feat: enhance EnvironmentRepository with snake part and food spawning…
dmccoystephenson Jun 7, 2025
b8be551
feat: add entity movement and collision handling in EnvironmentReposi…
dmccoystephenson Jun 7, 2025
81ae09e
refactor: rename moveEntity method and related variables for consistency
dmccoystephenson Jun 7, 2025
f5ffba8
Merge branch 'data/environmentRepository' into input/key-down-event-h…
dmccoystephenson Jun 7, 2025
38179da
refactor: remove duplicate imports in ophidian.py for cleaner code
dmccoystephenson Jun 7, 2025
8171ec8
refactor: standardize variable naming conventions in config, environm…
dmccoystephenson Jun 7, 2025
4cf3971
Merge pull request #56 from Preponderous-Software/data/snake-part-rep…
dmccoystephenson Jun 7, 2025
cabff25
Merge pull request #57 from Preponderous-Software/data/environmentRep…
dmccoystephenson Jun 7, 2025
9100858
Merge pull request #58 from Preponderous-Software/input/key-down-even…
dmccoystephenson Jun 7, 2025
f9cc5ad
feat: implement Renderer class for improved location drawing and colo…
dmccoystephenson Jun 7, 2025
6348fe8
feat: enhance Renderer to manage environment drawing and initialize l…
dmccoystephenson Jun 7, 2025
bf1b46e
fix: update event handling to use renderer for initializing location …
dmccoystephenson Jun 7, 2025
e7cbc02
feat: refactor Renderer to handle drawing and progress bar management
dmccoystephenson Jun 7, 2025
2eae935
refactor: streamline Renderer initialization and game display setup i…
dmccoystephenson Jun 7, 2025
4056f62
fix: improve error handling for entity movement direction in environm…
dmccoystephenson Jun 8, 2025
1c9111b
fix: update game display initialization to use renderer method
dmccoystephenson Jun 8, 2025
96317df
fix: raise error for invalid location value in get_color_of_location …
dmccoystephenson Jun 8, 2025
1a67d94
refactor: simplify move_entity method and enhance level progress hand…
dmccoystephenson Jun 8, 2025
6012120
feat: add reinitialize method to EnvironmentRepository for dynamic gr…
dmccoystephenson Jun 8, 2025
f3b2c61
Merge pull request #60 from Preponderous-Software/graphics/renderer
dmccoystephenson Jun 8, 2025
832671f
feat: implement PyEnvLibEnvironmentRepository and refactor Environmen…
dmccoystephenson Jun 15, 2025
923d75e
refactor: add type annotations, streamline method definitions, and im…
dmccoystephenson Jun 15, 2025
a1b6399
refactor: rename variables for consistent naming convention in PyEnvL…
dmccoystephenson Jun 15, 2025
7ac48db
refactor: update type annotations and improve imports in PyEnvLibEnvi…
dmccoystephenson Jun 15, 2025
86f0125
refactor: apply snake_case naming convention to method parameters in …
dmccoystephenson Jun 15, 2025
2dc2481
refactor: remove duplicate abstract method add_entity_to_location in …
dmccoystephenson Jun 15, 2025
9d70921
refactor: rename PyEnvLibEnvironmentRepository to PyEnvLibEnvironment…
dmccoystephenson Jun 15, 2025
ef9c08d
Merge pull request #61 from Preponderous-Software/refactor/environmen…
dmccoystephenson Jun 15, 2025
749a90e
refactor: adjust level progression threshold to 25% in config
dmccoystephenson Jul 4, 2025
d035957
refactor: extract score calculation and display logic into GameScore …
dmccoystephenson Jul 4, 2025
bd99f71
test: add unit tests for GameScore class
dmccoystephenson Jul 4, 2025
1c18893
Merge pull request #62 from Preponderous-Software/refactor/environmen…
dmccoystephenson Jul 4, 2025
61f3e5b
Merge pull request #63 from Preponderous-Software/refactor/game-score…
dmccoystephenson Jul 5, 2025
3223391
test: add unit tests for KeyDownEventHandler class
dmccoystephenson Jul 5, 2025
bca5dbe
refactor: update import paths for consistency and project structure, …
dmccoystephenson Jul 5, 2025
d760142
test: add unit tests for SnakePartRepository class
dmccoystephenson Jul 5, 2025
000c99a
test: add Arrange-Act-Assert comments to unit tests for better readab…
dmccoystephenson Jul 5, 2025
5d7ef25
test: add unit tests for PyEnvLibEnvironmentRepositoryImpl class
dmccoystephenson Jul 5, 2025
1d0e070
Merge pull request #64 from Preponderous-Software/testing/expand-unit…
dmccoystephenson Jul 5, 2025
8bd6dbb
refactor: remove outdated run.sh and test.sh scripts
dmccoystephenson Jul 5, 2025
22dc095
docs: update README with execution steps, and test instructions
dmccoystephenson Jul 5, 2025
172ad90
Merge pull request #65 from Preponderous-Software/refactor/cleanup-files
dmccoystephenson Jul 5, 2025
5dcce33
chore: bump version to 0.2.0-SNAPSHOT
dmccoystephenson Jul 5, 2025
0aec034
refactor: improve GameScore logic and integrate cumulative point trac…
dmccoystephenson Jul 5, 2025
8787d09
feat: add score display in the game renderer
dmccoystephenson Jul 5, 2025
11f8885
test: expand GameScore unit tests to cover new cumulative score logic
dmccoystephenson Jul 5, 2025
b9acca3
feat: add game state save/load functionality
dmccoystephenson Jul 5, 2025
3685eff
refactor: replace print statements with logging across the codebase
dmccoystephenson Jul 5, 2025
29f5bd8
feat: update score rendering to display current and cumulative points
dmccoystephenson Jul 12, 2025
2c2977e
chore: remove unnecessary comment
dmccoystephenson Jul 12, 2025
f4db0a8
chore: remove unnecessary newline
dmccoystephenson Jul 12, 2025
946b605
chore: remove misleading comment
dmccoystephenson Jul 12, 2025
3dcc617
Merge pull request #66 from Preponderous-Software/feat/cumulative-score
dmccoystephenson Jul 12, 2025
28aee2b
Merge branch 'develop' into feat/persist-level-and-score
dmccoystephenson Jul 12, 2025
493204f
feat: refactor grid size handling and reinitialize method in environm…
dmccoystephenson Jul 12, 2025
f42eff1
feat: simplify game state management by removing high score and games…
dmccoystephenson Jul 12, 2025
6995075
Merge remote-tracking branch 'origin/feat/persist-level-and-score' in…
dmccoystephenson Jul 26, 2025
b58ad45
Merge pull request #68 from Preponderous-Software/logging/use-logger
dmccoystephenson Jul 26, 2025
2ed7aa0
chore: move log statement
dmccoystephenson Jul 26, 2025
9783b19
Merge pull request #67 from Preponderous-Software/feat/persist-level-…
dmccoystephenson Jul 26, 2025
897c059
Update tests/snake/test_snakePartRepository.py
dmccoystephenson Sep 21, 2025
fc1c462
Update src/graphics/renderer.py
dmccoystephenson Sep 21, 2025
e474e04
Update src/environment/pyEnvLibEnvironmentRepositoryImpl.py
dmccoystephenson Sep 21, 2025
6803f95
Update src/environment/pyEnvLibEnvironmentRepositoryImpl.py
dmccoystephenson Sep 21, 2025
3e36de5
Initial plan
Copilot Sep 21, 2025
3eb1760
Initial plan
Copilot Sep 21, 2025
f747bca
Implement varying shades of green for snake colors - core functionali…
Copilot Sep 21, 2025
612dc47
Fix constructor argument order in ophidian.py - task complete
Copilot Sep 21, 2025
e825827
Changes before error encountered
Copilot Sep 21, 2025
0a69f51
Complete main menu system implementation with working navigation
Copilot Sep 23, 2025
d00e04c
Add comprehensive unit tests and CI pipeline for menu system
Copilot Sep 25, 2025
857a106
Refactor: Move green color generation to dedicated SnakeColorGenerato…
Copilot Sep 26, 2025
5218cea
Merge pull request #83 from Preponderous-Software/copilot/fix-d78d4d0…
dmccoystephenson Sep 26, 2025
893d2e7
Merge branch 'develop' into copilot/fix-c6c21d90-9f38-4bba-8121-42d7e…
dmccoystephenson Sep 26, 2025
fcfc876
Merge pull request #82 from Preponderous-Software/copilot/fix-c6c21d9…
dmccoystephenson Sep 26, 2025
f5b614f
Initial plan
Copilot Sep 26, 2025
589e6d9
Implement proportional scaling and centering on window resize
Copilot Sep 26, 2025
ef7b121
Add comprehensive edge case tests for scaling functionality
Copilot Sep 26, 2025
dc9d14b
Add visual boundary to make game area clearly visible
Copilot Sep 26, 2025
6e598a3
Implement dynamic menu scaling and window size persistence
Copilot Sep 26, 2025
ee8d119
Fix window size reset when transitioning from menu to game state
Copilot Sep 26, 2025
24a0697
Merge pull request #85 from Preponderous-Software/copilot/fix-8368392…
dmccoystephenson Sep 26, 2025
b0a7ed3
Initial plan
Copilot Sep 26, 2025
39df152
Implement functional options menu with settings persistence
Copilot Sep 26, 2025
1a839e8
Add key bindings configuration to options menu
Copilot Sep 26, 2025
ffccee5
Implement dynamic responsive UI layout for options menu
Copilot Sep 26, 2025
8f49de2
Fix text collision and implement settings impact on game mechanics
Copilot Sep 26, 2025
8d24a07
Add enhanced button feedback and fix navigation issues
Copilot Sep 26, 2025
63611e6
Fix back button navigation by correcting double callback execution bug
Copilot Sep 26, 2025
c6ac12e
Remove back button from options menu, use ESC key for navigation
Copilot Sep 26, 2025
d15e7c0
Merge pull request #87 from Preponderous-Software/copilot/fix-23cdbfd…
dmccoystephenson Sep 26, 2025
80f0ccd
Initial plan
Copilot Oct 15, 2025
fc3c250
Add text-based UI support with renderer and command-line option
Copilot Oct 15, 2025
a0e3f3d
Add tests for text UI renderer and update documentation
Copilot Oct 15, 2025
4a93ce1
Fix snake_parts access method in text renderer
Copilot Oct 15, 2025
82dde75
Add get_all method to SnakePartRepository for better encapsulation
Copilot Oct 15, 2025
45e0101
Fix get_all method to return copy for proper encapsulation
Copilot Oct 15, 2025
c59b8e1
Fix directional controls: swap left/right mappings
Copilot Oct 15, 2025
c2b9afa
Refactor: Abstract UI from gameplay logic with clean architecture
Copilot Oct 16, 2025
4b58006
Clean up: Remove backup file
Copilot Oct 16, 2025
adb546b
Fix: Add Enter key handling for text UI menu selection
Copilot Oct 16, 2025
b5b7192
Add comprehensive unit tests for game-breaking change detection
Copilot Oct 16, 2025
3e75827
Fix failing unit tests - add missing mock attributes
Copilot Oct 16, 2025
8e799cd
Fix: Remove duplicate entity spawning on game restart
Copilot Oct 16, 2025
8d834cc
Fix: Resolve KeyError on pygame UI restart by recreating renderer
Copilot Oct 19, 2025
072f1d8
Add GitHub Action workflow for Text UI gameplay verification
Copilot Oct 19, 2025
c1573ac
Fix: Handle CI environment without TTY in text UI tests
Copilot Oct 19, 2025
2ef8245
Implement text UI performance improvements with framerate limiting
Copilot Oct 20, 2025
84923cb
Merge pull request #95 from Preponderous-Software/copilot/add-text-ba…
dmccoystephenson Oct 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
output.txt
output.txt
*.json
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
# Ophidian
This game allows you to control an ever-increasingly growing ophidian in a virtual environment.

## Running the Game
To run the game:
```
python run.py
```

## Running Tests
To run the test suite:
```
python -m pytest tests
```

## Controls
Key | Action
------------ | -------------
w | move up
a | move left
s | move down
d | move right
f11 | fullscreen
l | toggle tick speed limit
r | restart
q | quit
| Key | Action |
|-----|-------------------------|
| w | move up |
| a | move left |
| s | move down |
| d | move right |
| f11 | fullscreen |
| l | toggle tick speed limit |
| r | restart |
| q | quit |

## Support
You can find the support discord server [here](https://discord.gg/49J4RHQxhy).

## Authors and acknowledgement
### Developers
Name | Main Contributions
------------ | -------------
Daniel Stephenson | Creator
| Name | Main Contributions |
|-------------------|--------------------|
| Daniel Stephenson | Creator |

## Libraries
This project makes use of [graphik](https://github.com/Preponderous-Software/graphik) and [py_env_lib](https://github.com/Preponderous-Software/py_env_lib).
This project makes use of [graphik](https://github.com/Preponderous-Software/graphik) and [py_env_lib](https://github.com/Preponderous-Software/py_env_lib).
11 changes: 11 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys
import os

# Add the project root directory to Python path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from src.ophidian import Ophidian

if __name__ == "__main__":
ophidian = Ophidian()
ophidian.run()
60 changes: 0 additions & 60 deletions run.sh

This file was deleted.

18 changes: 8 additions & 10 deletions src/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@
class Config:
def __init__(self):
# display
self.displayWidth = 500
self.displayHeight = 500
self.display_width = 500
self.display_height = 500
self.fullscreen = False
self.black = (0, 0, 0)
self.white = (255, 255, 255)
self.green = (0, 255, 0)
self.red = (255, 0, 0)
self.yellow = (255, 255, 0)
self.textSize = 50
self.text_size = 50

# grid size
self.gridSize = 5
self.minGridSize = 5
self.maxGridSize = 12
self.initial_grid_size = 5

# tick speed
self.limitTickSpeed = True
self.tickSpeed = 0.1
self.limit_tick_speed = True
self.tick_speed = 0.1

# misc
self.debug = False
self.restartUponCollision = True
self.levelProgressPercentageRequired = 0.5
self.restart_upon_collision = True
self.level_progress_percentage_required = 0.25
107 changes: 107 additions & 0 deletions src/environment/environmentRepository.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
from abc import ABC, abstractmethod
from typing import Optional, Any


class EnvironmentRepository(ABC):
"""Interface defining environment operations for the game"""

@abstractmethod
def get_rows(self) -> int:
"""Returns the number of rows in the environment grid"""
pass

@abstractmethod
def get_columns(self) -> int:
"""Returns the number of columns in the environment grid"""
pass

@abstractmethod
def get_locations(self) -> list:
"""Returns all locations in the environment"""
pass

@abstractmethod
def get_location(self, x: int, y: int) -> Any:
"""Returns location at the specified coordinates"""
pass

@abstractmethod
def get_num_locations(self):
pass

@abstractmethod
def get_location_of_entity(self, entity) -> Optional[Any]:
"""Returns the location of the specified entity"""
pass

@abstractmethod
def get_location_above_entity(self, entity):
pass

@abstractmethod
def get_location_left_of_entity(self, entity):
pass

@abstractmethod
def get_location_below_entity(self, entity):
pass

@abstractmethod
def get_location_right_of_entity(self, entity):
pass

@abstractmethod
def get_location_in_random_direction(self, location):
pass

@abstractmethod
def get_location_in_direction_of_entity(self, param, snakePart):
pass

@abstractmethod
def get_random_location(self) -> Any:
"""Returns a random location in the environment"""
pass

@abstractmethod
def add_entity_to_random_location(self, selectedSnakePart):
pass

@abstractmethod
def add_entity_to_location(self, entity, location: Any) -> None:
"""Adds an entity to the specified location"""
pass

@abstractmethod
def remove_entity_from_location(self, entity) -> None:
"""Removes an entity from its current location"""
pass

@abstractmethod
def get_location_by_id(self, locationId):
pass


@abstractmethod
def spawn_snake_part(self, snake_part, color):
pass

@abstractmethod
def spawn_food(self):
pass

@abstractmethod
def move_entity(self, entity, direction):
pass

@abstractmethod
def move_previous_snake_part(self, snake_part):
pass

@abstractmethod
def clear(self):
pass

@abstractmethod
def reinitialize(self, level: int) -> None:
pass
Loading