Forum Archive

Breakout Clone

Sebastian

Here's what I've been working on these past few days. The collision handling is kind of buggy though. If anyone have any suggestions on how to handle the "ball -> block" collision let me know :)
PS: Only tested on iPad

https://gist.github.com/SebastianJarsve/5305895

Cubbarooney104

How about naming this one Drillball? The reason is if you manage to hit the boxes in just the right way, your ball becomes a drill and plows through the entire column!

Here is a little diagram:

###  ###                           ()
#  #  #  #                            |
###  ###                            
###  ###
#  #  #  #     --->   
###  ###
###  ###
#  #  #  #
###  ###
      ()
       |

Related is the following problem:

###  ###                         ###
#  #  #  #                         #  #
###  ###           --->        ###       ()
###  ### ()                     ###      /
#  #  #  #   \                    #  #
###  ###                        ###

To sum it all up, if the border in between two boxes is hit, both boxes are hit. Also, if the ball is traveling vertically (and I assume horizontally) the ball will not bounce off.

I think this a glitch report :D
Cubbarooney

Sebastian

I believe I fixed it :) Before, I always reversed the ball's velocity when the ball hit the block and if the ball was hitting two blocks at the same time it leveled out and went strait through. The change I did was that if the ball hits the bottom of the rect for instance, the y-velocity will change to

-abs(velocity.y)
If it hits the top then the y-velocity will be
abs(velocity.y)

eliskan175

Very nice. I did however notice my ball keeps getting lost off screen.

edit: nevermind I think that was because when I copied the raw code from gisthub it had a couple glitches and I thought they were == and I guess they were <= ... that fixed the problem. My bad haha

Not sure why iPad has such a hard time copying the data from gisthub raw.. shows up fine on my PC: https://gist.github.com/SebastianJarsve/5305895/raw/774772b56e810362d7a331587b1d0b352a38187a/Breakout_Clone.py

Sebastian

I've also had problems copying raw code from a gist. Especially if it has any ">" or "<" in it. Glad you got it working ;)

Cubbarooney104

XD Just noticed that the formatting on my other post was a little... off. Woops, but I think you got the idea.

Cubbarooney

eliskan175

Breakout is fun, and I love how you used gravity for the player, now you need to set up a new twist! Like special physics for the ball, powerups, or maybe the blocks could fight back or move, etc.

Sebastian

I've already created solid blocks, but I just haven't used them in any of the levels yet :P Maybe I'll add some more levels with some of the solid blocks, and add some powerups later on :)