Skip to content

Commit

Permalink
gitignore venv, fix last few bugs in practice template
Browse files Browse the repository at this point in the history
  • Loading branch information
chrehall68 committed Dec 16, 2021
1 parent a6c9c13 commit d7b840c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode/
*.xml
*.iml
venv/
17 changes: 14 additions & 3 deletions games/chapter4/practice/hockey.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,20 @@ def __init__(self):
"""
self.speed = {"x": 0, "y": 0}
self.rect = Rect
self.prev_rect = Rect

def move(self):
"""
This should move self.rect according to self.speed
This should first set self.prev_rect equal to self.rect.
Then, it should move self.rect according to self.speed
by using self.rect's move method as demonstrated in OOP_game.py.
"""
pass # your code here

def move_to(self, coordinate):
"""
This should move self.rect so that its top left lies at
This should first set self.prev_rect equal to self.rect.
Then, it should move self.rect so that its top left lies at
the provided coordinate.
"""
pass # your code here
Expand Down Expand Up @@ -203,6 +206,8 @@ def collide_line(self, other):
"""
Checks if the ball has hit a line.
If it did, update the speed accordingly
(if it collided with top or bottom, self.speed['y'] will be negative self.speed['y']
if it collided with right or left, self.speed['x'] will be negative self.speed['x'])
Arguments:
other (BoundingLine or Goal) - the line to check for a collision with
Expand Down Expand Up @@ -379,13 +384,19 @@ def __init__(self, parameters):
the starting coordinate of the line
the ending coordinate of the line
the line's name (which should either be
'up', 'down', 'left', or 'right')
'top', 'bottom', 'left', or 'right')
(optional) default_size - the size of the line. If not provided,
use DEFAULT_SIZE
This should create the rectangle that stretches from the start
coordinate to the end coordinate with a width or height
(depending on its orientation) of default_size
(or DEFAULT_SIZE if default_size isn't provided)
Make sure to:
if it is the bottom line: move it DEFAULT_SIZE units up
if it is the right line: move it DEFAULT_SIZE units left
*This is a workaround so that these will show on screen and not
be off-screen
"""

def draw(self, screen: pygame.Surface, color):
Expand Down

0 comments on commit d7b840c

Please sign in to comment.