From 10b4df07ffb7acd6ab89f2d23446ed58579631ed Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 13 Jul 2018 09:37:13 -0700 Subject: [PATCH 1/8] chore: add .DS_Store in .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 894a44c..bae3c35 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# Mac specific +.DS_Store \ No newline at end of file From 364b7b690b3319848ae6aea25ab76faab6a20af5 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 13 Jul 2018 10:55:09 -0700 Subject: [PATCH 2/8] fix: increase ball velocity to fixed (8, 8) --- src/draw.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/draw.py b/src/draw.py index 14ff036..bee452a 100644 --- a/src/draw.py +++ b/src/draw.py @@ -5,20 +5,25 @@ from ball import * from block import * +# from paddle import * -SCREEN_SIZE = [640, 480] +SCREEN_SIZE = [400, 800] BACKGROUND_COLOR = [255, 255, 255] def debug_create_objects(object_list): kinetic = GameBall(1, object_list, SCREEN_SIZE, Vector2(random.randint(20, SCREEN_SIZE[0] - 20), random.randint(20, SCREEN_SIZE[1] - 20)), - Vector2(4*random.random() - 2, 4*random.random() - 2), + #Vector2(10*random.random() - 2, 10*random.random() - 2), + Vector2(8, 8), [255, 10, 0], 20) object_list.append(kinetic) block = KineticBlock(Vector2(200,200), 100, 100, [0, 0, 255]) object_list.append(block) - + + # paddle = Paddle(Vector2(320,400), 100, 50, [0, 255, 255]) + # object_list.append(paddle) + def main(): pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE) From 573d7508f37be44f66246e8e5dec29d6d76a962c Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 13 Jul 2018 11:03:01 -0700 Subject: [PATCH 3/8] feat: add fixed paddle object --- src/block.py | 4 +++- src/draw.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/block.py b/src/block.py index f7966e2..1a8dc8d 100644 --- a/src/block.py +++ b/src/block.py @@ -34,4 +34,6 @@ class KineticBlock(Block): # KineticBall will handle the collison pass - +class PaddleBlock(KineticBlock): + #def __init__(self, position, width, height, color, movement) + pass diff --git a/src/draw.py b/src/draw.py index bee452a..2a457d9 100644 --- a/src/draw.py +++ b/src/draw.py @@ -21,6 +21,9 @@ def debug_create_objects(object_list): block = KineticBlock(Vector2(200,200), 100, 100, [0, 0, 255]) object_list.append(block) + paddle = PaddleBlock(Vector2(200,700), 100, 30, [255, 0, 0]) + object_list.append(paddle) + # paddle = Paddle(Vector2(320,400), 100, 50, [0, 255, 255]) # object_list.append(paddle) From 174c48d4368177777988e348114733c6e104ead8 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Fri, 13 Jul 2018 11:04:19 -0700 Subject: [PATCH 4/8] chore: add .vscode folder to .gitignore --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bae3c35..ce28ccc 100644 --- a/.gitignore +++ b/.gitignore @@ -104,4 +104,7 @@ venv.bak/ .mypy_cache/ # Mac specific -.DS_Store \ No newline at end of file +.DS_Store + +# VS Code specific +.vscode/ \ No newline at end of file From f0f3f9992c5a2e520b2ced5dd39a64f12f393730 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Mon, 27 Aug 2018 22:24:25 -0700 Subject: [PATCH 5/8] feat: moving paddle - paddle is added as a kinetic block - moves with arrow key left & right - bug: paddle moves out of left and right boundaries of game screen --- src/block.py | 21 +++++++++++++++++++-- src/draw.py | 5 +---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/block.py b/src/block.py index 1a8dc8d..c383601 100644 --- a/src/block.py +++ b/src/block.py @@ -35,5 +35,22 @@ class KineticBlock(Block): pass class PaddleBlock(KineticBlock): - #def __init__(self, position, width, height, color, movement) - pass + + + + def update(self, **kwargs): + left = kwargs['left'] + right = kwargs['right'] + + if left: + self.position.x -= 7 + + if right: + self.position.x += 7 + + self.rectangle = pygame.Rect( + self.position.x - (self.rectangle.width/2), + self.position.y - (self.rectangle.height/2), + self.rectangle.width, + self.rectangle.height, + ) \ No newline at end of file diff --git a/src/draw.py b/src/draw.py index 2a457d9..f962fec 100644 --- a/src/draw.py +++ b/src/draw.py @@ -24,9 +24,6 @@ def debug_create_objects(object_list): paddle = PaddleBlock(Vector2(200,700), 100, 30, [255, 0, 0]) object_list.append(paddle) - # paddle = Paddle(Vector2(320,400), 100, 50, [0, 255, 255]) - # object_list.append(paddle) - def main(): pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE) @@ -52,7 +49,7 @@ def main(): if keys[pygame.K_RIGHT]: right = True for object in object_list: - object.update() + object.update(left = left, right = right) # move paddle object.check_collision() # Draw Updates From c676985a28b5b7fb745913d9ca54fb2ddd64d53e Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Mon, 27 Aug 2018 22:42:51 -0700 Subject: [PATCH 6/8] feat: creating target blocks - SingleBounceBlock will disappear after the ball touch it - MultibleBounceBlock will chage colors each time the ball touch it - And will disappear after 4th hit --- src/block.py | 17 ++++++++++++----- src/draw.py | 7 +++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/block.py b/src/block.py index c383601..f362130 100644 --- a/src/block.py +++ b/src/block.py @@ -36,21 +36,28 @@ class KineticBlock(Block): class PaddleBlock(KineticBlock): - - def update(self, **kwargs): left = kwargs['left'] right = kwargs['right'] if left: - self.position.x -= 7 + self.position.x -= 10 if right: - self.position.x += 7 + self.position.x += 10 self.rectangle = pygame.Rect( self.position.x - (self.rectangle.width/2), self.position.y - (self.rectangle.height/2), self.rectangle.width, self.rectangle.height, - ) \ No newline at end of file + ) + +class MultipleBounceBlock(KineticBlock): + # This block will chage colors each time the ball touch it + # And will disappear after 4th hit + pass + +class SingleBounceBlock(KineticBlock): + # This block will disappear after the ball touch it + pass \ No newline at end of file diff --git a/src/draw.py b/src/draw.py index f962fec..84f50e9 100644 --- a/src/draw.py +++ b/src/draw.py @@ -24,6 +24,13 @@ def debug_create_objects(object_list): paddle = PaddleBlock(Vector2(200,700), 100, 30, [255, 0, 0]) object_list.append(paddle) + multipleBounceBlock = MultipleBounceBlock(Vector2(200,300), 50, 50, [0, 0, 255]) + object_list.append(multipleBounceBlock) + + singleBounceBlock = SingleBounceBlock(Vector2(200,400), 50, 50, [0, 0, 255]) + object_list.append(singleBounceBlock) + + def main(): pygame.init() screen = pygame.display.set_mode(SCREEN_SIZE) From 415c3ac43297faad8c511ab1a5ea7b5a7ded5c8a Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Mon, 27 Aug 2018 23:07:09 -0700 Subject: [PATCH 7/8] feat: trying SingleBounceBlock - the block displays but exits game when the ball touch the block --- src/block.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/block.py b/src/block.py index f362130..ad0048c 100644 --- a/src/block.py +++ b/src/block.py @@ -56,8 +56,13 @@ def update(self, **kwargs): class MultipleBounceBlock(KineticBlock): # This block will chage colors each time the ball touch it # And will disappear after 4th hit - pass + pass + + + class SingleBounceBlock(KineticBlock): # This block will disappear after the ball touch it - pass \ No newline at end of file + def update(self, **kwargs): + if self.touched_by_ball: + self.object_list.remove(self) From aaeedda6ee6d28e2cc87832a59917d3d5f93dce9 Mon Sep 17 00:00:00 2001 From: Ilho Kim Date: Tue, 28 Aug 2018 01:18:10 -0700 Subject: [PATCH 8/8] feat: deploying single bounce blocks - Not very successful yet --- src/draw.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/draw.py b/src/draw.py index 84f50e9..84628ab 100644 --- a/src/draw.py +++ b/src/draw.py @@ -18,8 +18,12 @@ def debug_create_objects(object_list): [255, 10, 0], 20) object_list.append(kinetic) - block = KineticBlock(Vector2(200,200), 100, 100, [0, 0, 255]) - object_list.append(block) + for i in range(10): + singleBounceBlock = SingleBounceBlock(Vector2(40*i,400), 39, 39, [0, 0, 255]) + object_list.append(singleBounceBlock) + + # block = KineticBlock(Vector2(200,200), 100, 100, [0, 0, 255]) + # object_list.append(block) paddle = PaddleBlock(Vector2(200,700), 100, 30, [255, 0, 0]) object_list.append(paddle) @@ -27,8 +31,6 @@ def debug_create_objects(object_list): multipleBounceBlock = MultipleBounceBlock(Vector2(200,300), 50, 50, [0, 0, 255]) object_list.append(multipleBounceBlock) - singleBounceBlock = SingleBounceBlock(Vector2(200,400), 50, 50, [0, 0, 255]) - object_list.append(singleBounceBlock) def main():