Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morgan's branch #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added cycle/__pycache__/constants.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 19 additions & 8 deletions cycle/game/scripting/handle_collisions_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def execute(self, cast, script):
script (Script): The script of Actions in the game.
"""
if not self._is_game_over:
# self._handle_food_collision(cast)
self._handle_segment_collision(cast)
self._handle_game_over(cast)

Expand All @@ -36,14 +35,26 @@ def _handle_segment_collision(self, cast):
Args:
cast (Cast): The cast of Actors in the game.
"""
"""snake = cast.get_first_actor("snakes")
head = snake.get_segments()[0]
segments = snake.get_segments()[1:]
# snake = cast.get_first_actor("snakes")
# head = snake.get_segments()[0]
# segments = snake.get_segments()[1:]

cycles = cast.get_actors("cycles")
cycle1 = cycles[0]
cycle2 = cycles[1]
head1 = cycle1.get_segments()[0]
head2 = cycle2.get_segments()[0]
segments1 = cycle1.get_segments()[1:]
segments2 = cycle2.get_segments()[1:]

for segment in segments1:
if head2.get_position().equals(segment.get_position()):
self._is_game_over = True

for segment in segments2:
if head1.get_position().equals(segment.get_position()):
self._is_game_over = True

for segment in segments:
if head.get_position().equals(segment.get_position()):
self._is_game_over = True"""
pass

def _handle_game_over(self, cast):
"""Shows the 'game over' message and turns the snake and food white if the game is over.
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.