Computer Science Canada Help w/ collisions in my breakout/arkanoid game. |
Author: | s_climax [ Sat May 15, 2004 6:44 pm ] | ||
Post subject: | Help w/ collisions in my breakout/arkanoid game. | ||
For some reasons its not really working at all any more. It seems to be a problem with the collisions of the ball with the bricks.
|
Author: | SuperGenius [ Sat May 15, 2004 9:48 pm ] |
Post subject: | |
when I ran your code the ball just hovers in the middle of the screen, fluctuating within a range of a couple pixels. |
Author: | Dan [ Sat May 15, 2004 11:05 pm ] | ||
Post subject: | |||
the problem is with your colsione dection with the bricks and the ball: 1. you need to uses and not or 2. both the y and x ifs have to be the same if not 2 diffrent ones 3. you mixed up the > and < singes. the if should look somting like this: if x >= xx and x <= xx + xsize and y >= yy and y <= yy + ysize then combinding the ifs and making thous chages will almost make the progame work right. there is still a bug in the way u are dertming witch brick was hit. insted of usning a one dimetion arae for the bircks why not uses a 2d one? this makes it alot easer to keep track of the boxs withc are on vs off. tho this make u have to chage alot of the closione code. here is what i did with it:
it is not perfitck but it will get you on the right track. |
Author: | s_climax [ Sun May 16, 2004 12:03 am ] | ||
Post subject: | |||
Thanks, but how would I get the balls to bounce off the bricks in the right direction? That is the only thing I can't figure out. I've managed to add the ability to lose, lives, make room around the edges, and add colors. I simply cannot figure out how to make the balls bounce off the bricks correctly. Any help?
|
Author: | s_climax [ Mon May 17, 2004 6:21 pm ] | ||
Post subject: | |||
This is my problem. The way the if statement works, it only checks that the ball has hit the brick. What I need is a way to check which side of the brick it hit. Once I can figure out that code, I can get it. |
Author: | Paul [ Mon May 17, 2004 6:32 pm ] |
Post subject: | |
you can check which direction the ball is moving in when it hits something, then move it in the appropriate direction. |
Author: | LiquidDragon [ Mon May 17, 2004 6:44 pm ] |
Post subject: | |
Yes. so if the ball is going up to the right and it hits the wall then u just switch the movement of the y. It's really that simple |
Author: | s_climax [ Mon May 17, 2004 8:04 pm ] |
Post subject: | |
Quote: Yes. so if the ball is going up to the right and it hits the wall then u just switch the movement of the y. It's really that simple It's more complicated than that. Of course that works with walls, but not a four-sided object. I may be able to use direction though. I will try that, thanks. EDIT: After some thinking, I realized that I could determine which side of the brick the ball hit (top vs bottom or left vs right) but not whether it was the horizontal or vertical. Therefore, it seems that direction won't help me. |
Author: | s_climax [ Wed May 19, 2004 4:27 pm ] | ||
Post subject: | |||
The only thing that kind of works is if I check if the rounded value of the left sdie of the brick is equal to the rounded value of the ball's x. THe problem with this is that it does not allow me to increase the ball's speed. How would I make it possible to make the ball's speed greater? One other problem is that sometimes the collisions will get backwards on the paddle, so that if you hit the ball on the left side of the paddle it will change its direction and make it go right. Most of the time this is not the case though.
|
Author: | Cervantes [ Wed May 19, 2004 4:46 pm ] |
Post subject: | |
heheh you could use whatdotcolour and colour the brinks in a unique way. |
Author: | MyPistolsIn3D [ Wed May 19, 2004 4:49 pm ] |
Post subject: | |
Do you not just have to make the xchange in the opposite direction? Like when it is going up and to the right, change it down and to the left? |
Author: | Cervantes [ Wed May 19, 2004 5:32 pm ] |
Post subject: | |
no because if its going up and to the right and you hit the bottom of a brick it should go down and to the right, not down and to the left. |
Author: | s_climax [ Thu May 20, 2004 9:23 pm ] | ||
Post subject: | |||
As you can tell, the game is too easy since the ball is too slow. But when I make the ball speed up it doesn't work. Any other ideas for making my collision detection work with different speeds? I'm not so sure that whatdotcolor would work. |
Author: | SuperGenius [ Thu May 20, 2004 10:31 pm ] |
Post subject: | |
i will post my version of super breakout after i've handed it in for my summative, but how it works is there are two variables which are the rise and run of the slope of the ball's path. These are added to the ball's coords at the start of each execution of the loop. I used whatdotcolour for the bricks but the walls have coordinate detection. What i did was have two variables for the low range and high range of a random intiger which would be used to give the ball a random path, so if you increase the value of the upper and lower ranges of the random intiger, you can make the game speed up and it doesnt affect the game really unless you set it to a speed which would be too fast to play on anyways. |
Author: | s_climax [ Sun May 23, 2004 11:51 am ] |
Post subject: | |
That does not help me really. My game speed is already at its highest. My issue is not making the ball go faster either. I have that done too. |
Author: | SuperGenius [ Sun May 23, 2004 8:59 pm ] |
Post subject: | |
i suggest cutting down the code inside your main loop. I would eliminate the music because it gets annoying pretty fast. that would help reduce the chopiness whenever there is a collision. |
Author: | s_climax [ Sun May 23, 2004 9:36 pm ] | ||
Post subject: | |||
|
Author: | SuperGenius [ Sun May 23, 2004 10:10 pm ] |
Post subject: | |
i don't know what you could do to cut it down because i can't understand your code, but in the version that you posted before i was able to turn the music off... |
Author: | s_climax [ Mon May 24, 2004 10:52 am ] |
Post subject: | |
I edited my post to include comments so that maybe you can understand it. |
Author: | SuperGenius [ Mon May 24, 2004 1:27 pm ] |
Post subject: | |
I see the problem. WHen the music is engaged every time there's a collision the program stops for a fraction of a second while the note is playing, and then resumes. If you are bent on having music i supposed you could try to put it into a process but I would just drop it altogether. Also a concern with the gameplay is how the ball just jumps downwards at the start of the game, and you can't predict where it is going to go so sometimes you would lose lives right at the start. As well I noticed that the slope of the ball's path would sometimes be very close to ablolutely vertical or horizontal, which is "wrong", as it does not happen in superbreakout/ araknoid. |
Author: | s_climax [ Mon May 24, 2004 2:07 pm ] |
Post subject: | |
I fixed the problem with the music. I found another function, Music.Sound this way it doesn't stop the game when it palys. I updated my post with it. I don't think I would be able to solve the other thing you mentioned though. |
Author: | SuperGenius [ Mon May 24, 2004 5:49 pm ] |
Post subject: | |
another thing which you might find interesting is this editor prog i made. It facilitates the creation of levels for this type of game. It won't work for you without tweaking but i thought that you might be interested. To use it you enter the name of the output file (dont worry about extensions because it tacks on ".txt" automatically. Then you put a colour number and click/drag on the stage. When you want to switch colours click in the bottom 100px of the screen, and when you're finished put -1 for the colour. The output file will be in the same directory as the editor prog. To use the text file just tell your game to draw a box in the normal place, and read the number for what colour to make it from the text file. |