Skip to content
This repository has been archived by the owner on Aug 24, 2018. It is now read-only.

Mathias Bakken #82

Open
wants to merge 3 commits into
base: master
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
41 changes: 25 additions & 16 deletions src/ball.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,32 @@ def draw(self, screen, pygame):
# cast x and y to int for drawing
pygame.draw.circle(screen, self.color, [int(self.position.x), int(self.position.y)], self.radius)

# class BouncingBall(???):
# """
# ball effected by gravity
# """
# # TODO:
class BouncingBall(Ball):
"""
ball effected by gravity
"""
gravity = 0.1

def update(self):
self.velocity.y += self.gravity
super().update()

# class RainbowBall(???):
# """
# Ball that changes colors
# """
# # TODO:
class RainbowBall(Ball):
"""
Ball that changes colors
"""
def update(self):
r = (self.color[0] + 1) % 256
g = (self.color[1] + 2) % 256
b = (self.color[2] - 3) % 256
self.color = [r, g, b]
super().update()

# class BouncingRainbow(???):
# """
# Ball that changes color and is affected by gravity
# """
# # TODO:
class BouncingRainbow(BouncingBall, RainbowBall):
"""
Ball that changes color and is affected by gravity
"""
pass

# class KineticBall(???):
# """
Expand All @@ -59,4 +68,4 @@ def draw(self, screen, pygame):
# class AllTheThings(???):
# """
# A ball that does everything!
# """
# """
12 changes: 12 additions & 0 deletions src/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,15 @@ def set_rectangle(self, position, width, height):

def draw(self, screen, pygame):
pygame.draw.rect(screen, self.color, self.rectangle)

class SecondBlock(Block):
pass

class RainbowBlock(SecondBlock):

def update(self):
r = (self.color[0] + 1) % 256
g = (self.color[1] + 2) % 256
b = (self.color[2] - 3) % 256
self.color = [r, g, b]
super().update()
14 changes: 12 additions & 2 deletions src/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ def debug_create_balls(object_list):
ball = Ball(SCREEN_SIZE, Vector2(50, 50), Vector2(3, 3), [255, 0, 0], 10)
object_list.append(ball)

# TODO: Create other ball types for testing
bouncing_ball = BouncingBall(SCREEN_SIZE, Vector2(125, 75), Vector2(1, 0), [0, 40, 255], 8)
object_list.append(bouncing_ball)

rainbow_ball = RainbowBall(SCREEN_SIZE, Vector2(400, 300), Vector2(2, -1), [0, 255, 0], 8)
object_list.append(rainbow_ball)

bouncing_rainbow = BouncingRainbow(SCREEN_SIZE, Vector2(100, 300), Vector2(3, -1), [46, 255, 0], 8)
object_list.append(bouncing_rainbow)

def debug_create_blocks(object_list):
block = Block(SCREEN_SIZE, Vector2(100,100), 20, 20, [0,255,0])
object_list.extend((block, ))
object_list.append(block)

rainbow_block = RainbowBlock(SCREEN_SIZE, Vector2(75, 75), 10, 10, [0, 255, 0])
object_list.append(rainbow_block)

def main():
pygame.init()
Expand Down