Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2de033a
Create main game class
vivienyuwenchen Oct 18, 2017
7d4d56a
Jumping Dot That Moves Side To Side
hthomas60 Oct 19, 2017
7881c09
Add player and keyboard control
vivienyuwenchen Oct 19, 2017
a72aed8
Merge branch 'master' of https://github.com/vivienyuwenchen/Interacti…
vivienyuwenchen Oct 19, 2017
ae5ded3
Add player class, collision detection, and game over
vivienyuwenchen Oct 21, 2017
035bf5d
Added player summuned obsticals
Oct 22, 2017
860cf7c
Add stamina bar
vivienyuwenchen Oct 23, 2017
dd67c71
player two spawns obsticals at different hights
Oct 23, 2017
9f2156e
merged
Oct 23, 2017
a98883f
Ad project writeup and reflection
vivienyuwenchen Oct 24, 2017
41fc448
added player 2 stamia bar
Oct 24, 2017
757dba6
Merge branch 'master' of https://github.com/vivienyuwenchen/Interacti…
Oct 24, 2017
7bab5b1
Fix isCollide to work at different heights
vivienyuwenchen Oct 25, 2017
0ede561
Change restart game key to space bar
vivienyuwenchen Oct 26, 2017
3d5ef9d
Add docstrings and comments
vivienyuwenchen Oct 26, 2017
6b22ee8
Fixed stamina bar regeneration
Oct 28, 2017
d55ede1
Added score and changed endgame scene
Oct 29, 2017
a4057a2
Update project writeup and reflection
vivienyuwenchen Oct 29, 2017
c6a297c
Add screenshots of game
vivienyuwenchen Oct 30, 2017
522df62
Add screenshots of game
vivienyuwenchen Oct 30, 2017
ea85407
Update README.md
vivienyuwenchen Oct 30, 2017
734db7c
Update project writeup and reflection
vivienyuwenchen Oct 30, 2017
4edcbf7
Merge branch 'master' of https://github.com/vivienyuwenchen/Interacti…
vivienyuwenchen Oct 30, 2017
58d7c1b
Added Captions To figures
hthomas60 Oct 30, 2017
af2ed11
Fixed Caption Spacing
hthomas60 Oct 30, 2017
0f26809
Update inline comments
vivienyuwenchen Oct 30, 2017
c66f558
Merge branch 'master' of https://github.com/vivienyuwenchen/Interacti…
vivienyuwenchen Oct 30, 2017
dd5ea39
Replace Barleft with Bar
vivienyuwenchen Oct 30, 2017
f877988
Added Player reviews
hthomas60 Oct 30, 2017
a896506
Added Player reviews
hthomas60 Oct 30, 2017
20ba136
Added Player reviews
hthomas60 Oct 30, 2017
d33d9c2
Added Player reviews
hthomas60 Oct 30, 2017
4441f05
Added Player reviews
hthomas60 Oct 30, 2017
6a55531
Added Player reviews
hthomas60 Oct 30, 2017
5fb8cc9
Added Player reviews
hthomas60 Oct 30, 2017
ce5b8eb
Same
hthomas60 Oct 30, 2017
886ec96
Add UML diagram
vivienyuwenchen Oct 30, 2017
a8bfe17
Merge branch 'master' of https://github.com/vivienyuwenchen/Interacti…
vivienyuwenchen Oct 30, 2017
eea96f3
Add UML diagram
vivienyuwenchen Oct 30, 2017
b97a0c0
Update project writeup and reflection
vivienyuwenchen Oct 30, 2017
cea81cc
Revised for MP5 with suggestions from feedback and start menu
vivienyuwenchen Dec 10, 2017
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
Prev Previous commit
Next Next commit
Replace Barleft with Bar
  • Loading branch information
vivienyuwenchen committed Oct 30, 2017
commit dd5ea39e99761e7fe413e81f71e2cb0b812426d1
8 changes: 4 additions & 4 deletions Game4.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def mainLoop(self):
# up to jump
if pressed[pygame.K_UP] and P1_stamina_bar.bars >= player.jumpcost:
if player.play_y == (360 - player.play_len):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

360 is a “magic number”. Replace it by a constant, or an attribute that is initialized next to wherever this value is coming from.

P1_stamina_bar.decreaseBarleft(player.jumpcost)
P1_stamina_bar.decreaseBar(player.jumpcost)
player.jump()
P1_stamina_bar.draw()
# left to move left
Expand Down Expand Up @@ -108,7 +108,7 @@ def mainLoop(self):
# generate obstacle player's obstacle at appropriate height
if (new_obstical == True and P2_stamina_bar.bars >= 33):
new_obstical = False
P2_stamina_bar.decreaseBarleft(33)
P2_stamina_bar.decreaseBar(33)
obstacles.append(Obstacle(obs_x, obstical_height, obs_len, self.screen,'RED'))

# move each obstacle forward
Expand All @@ -121,8 +121,8 @@ def mainLoop(self):
obstacles = [obstacle for obstacle in obstacles if not obstacle.isGone()]

# update stamina bars
P1_stamina_bar.increaseBarleft()
P2_stamina_bar.increaseBarleft(1.5)
P1_stamina_bar.increaseBar()
P2_stamina_bar.increaseBar(1.5)
P1_stamina_bar.draw()
P2_stamina_bar.draw()

Expand Down
5 changes: 3 additions & 2 deletions misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, play_x, play_y, play_len, screen):
self.m = 2.5 # "mass" for jump
self.floor = play_y # location of player before jump, used for comparison
self.jumpcost = 30

def draw(self):
"""Draw player based on top left hand coordinate and length."""
pygame.draw.rect(self.screen, colors['WHITE'], [self.play_x, self.play_y, self.play_len, self.play_len])
Expand Down Expand Up @@ -117,11 +118,11 @@ def draw(self):
"""Draw stamina bar based on color, starting location, and number of health bars."""
pygame.draw.rect(self.screen, colors[self.color], [self.start, 20, self.bars, 10])

def decreaseBarleft(self, num_bars):
def decreaseBar(self, num_bars):
"""Decrease health bar by num_bars."""
self.bars -= num_bars

def increaseBarleft(self, speed = 1):
def increaseBar(self, speed = 1):
"""Increase health bar continuously if number of bars is lower than 100."""
if self.bars < 100:
self.bars += 1 * speed