Computer Science Canada Blockout Game Help |
Author: | mike200015 [ Mon Apr 25, 2005 10:11 pm ] | ||||
Post subject: | Blockout Game Help | ||||
Ok, so im making a blockout game, and i still cant get the collision detection perfect, i got alot of it to work, but still, when the ball hits the blocks in certain spots, the blocks dont dissapear, can someone please help!! Heres the code for the whole game:
And this is the particular code that is the collision detection, which makes the blocks dissapear, which is the part i need help with:
|
Author: | mike200015 [ Tue Apr 26, 2005 4:47 pm ] |
Post subject: | |
anyone |
Author: | jamonathin [ Tue Apr 26, 2005 5:34 pm ] | ||
Post subject: | |||
Here yas go mayte
Your if statements were a little off, and you were making the ymod's and xmods change at the wrong time, therefore the ball would just plow through everything. What I changed was, I put the detection of the ball hitting the side of a block in one if statement (both sides of block), and the top and bottom hit dection in another if statement. When those blocks were hit, it was then that I changed the direction of the ball, and told the program not to draw those balls again. I also put another if statement around that, so that it would only check detection if the block (i).hits not=1. If you need any more explanation, juss ask away. |
Author: | mike200015 [ Tue Apr 26, 2005 7:35 pm ] |
Post subject: | |
wow!! thnx so much! i was workin on that part for soo long and couldnt get it right. +5 Bits for your help! Can you just explain the collision part that u changed, like which part is for the side detection and which part is for the top/bottom, and how it works sorta. |
Author: | jamonathin [ Tue Apr 26, 2005 7:49 pm ] | ||||||
Post subject: | |||||||
This is all i used for dection, I got rid of everything else.
Now this is for the horizontal checking:
The first chunk (before the or) checks if the left side of the ball hits. Now, you only want to check that tip of the ball, nothing else, so thats why i check with bally, not bally +10 or -10 Now this is for the vertical checking:
Same concept with this. I'm only checking the tip of the ball, and the very bottom. Ex. I'm Checking these parts of the ball (where the points are) _. -- [ I know this is really ugly ] _' However, this method can be faulty. For example, if the ball were to hit a corner, the tip, nor the side would hit first, this is where you can do some extra coding, or using whatdotcolor. This is a good start though. |
Author: | mike200015 [ Tue Apr 26, 2005 8:07 pm ] |
Post subject: | |
when you say that it only cheks the tips of the ball, do you mean just the top, bottom, right , and left tips of the ball are being checked? And not the parts in between the top/bottom tips and side tips? And also, how do you do that turing code thing, so it says turing instead of just Code? |
Author: | jamonathin [ Tue Apr 26, 2005 8:32 pm ] | ||
Post subject: | |||
I juss learned it from wtd.
And yeah, i mean juss those tips, not inbetween, just where those ticks were, not the _'s. That's why the method isn't perfect. |
Author: | mike200015 [ Wed Apr 27, 2005 4:12 pm ] | ||
Post subject: | |||
k i added sum new stuff to my blockout game, and i need some help with it. I made a ball collision with the paddle, and also added money that falls from certain blocks when you hit them, and if you get the money you get 1 point, and its all randmonly generated. These are the problems im having: 1. Sometimes when the paddle is moving and ball hits it, it slides with it, or gets stuck. 2. When you it more blocks then the game runs faster and faster the more blocks that are gone. Please, if anyone can help i'd appreciate it! Thanx!! Heres the new code:
|
Author: | jamonathin [ Thu Apr 28, 2005 8:12 am ] | ||
Post subject: | |||
The reason your game speeds up is because your program is used to drawing a lot of boxes, now it only has to draw a couple, so it's going to do so faster. What you can do, is when you check if the block is hit (that's where you decide whether or not to draw it) you can then draw that block, only in white, or whatever color your background is. Or better yet, you can cheat. Lets say you have some picture you want to import, so redrawing the hit blocks wont work, have the program draw the block at like (5000,5000) or something, you'll never see it, and the speed wont change. And this is all you need for the paddle. There's no real point and making xmod*=-1 because if the ball does hit the side of the paddle, it still goin down and theres nothing you can do about it.
P.S. I was playin ur game, and one of the times that i got a money thing, my score kept goin, and i got like 7765 score, look into that |
Author: | mike200015 [ Thu Apr 28, 2005 1:41 pm ] |
Post subject: | |
haha lol.. yea i know... sum1 else told me that 2.. ill chek that out.. thanx for your help tho |
Author: | mike200015 [ Thu Apr 28, 2005 9:23 pm ] | ||
Post subject: | |||
ok.. im adding another new part to my blockout game, im adding a shooting part. You start off with 5 bullets, and then when money falls and you get it you can buy more. I have no clue how to make the shooting part though. I want it so that when you press space, a bullet comes from the middle of wherever the paddle is, and if they hit a block, the blok and bullet dissapear. And when a bullet shoots, it takes 1 off your amo level, and when you hav 0 then you cant shoot. And also, I want it so you can shoot many bullets at a time, with a delay inbetween. I made the money falling and store to buy bullets, i just need help making bullets shoot from the paddle and the rapid fire etc. If anyone can help me get started with this part id appreciate it, im working on it in a new file to make it easier, so this is the basic blocks, and paddle part:
|
Author: | mike200015 [ Fri May 06, 2005 3:25 pm ] |
Post subject: | |
this topic was from sort of a while ago.. but.. i figured out that now i need to check more than just those four points from before, how would i check more than just the 4 points on the ball? |
Author: | Cervantes [ Fri May 06, 2005 4:02 pm ] |
Post subject: | |
Equation of a circle? Didn't I mention that elsewhere? jamonathin wrote: The reason your game speeds up is because your program is used to drawing a lot of boxes, now it only has to draw a couple, so it's going to do so faster. What you can do, is when you check if the block is hit (that's where you decide whether or not to draw it) you can then draw that block, only in white, or whatever color your background is. Or better yet, you can cheat. Lets say you have some picture you want to import, so redrawing the hit blocks wont work, have the program draw the block at like (5000,5000) or something, you'll never see it, and the speed wont change. Why don't we just set a FPS... |
Author: | jamonathin [ Fri May 06, 2005 8:35 pm ] |
Post subject: | |
meh, whatever works |
Author: | mike200015 [ Sat May 07, 2005 3:47 pm ] |
Post subject: | |
Yea u mentioned that, but i dont really understand how i would use that equation to chek the circle and block collision Also, wats a FPS? |
Author: | [Gandalf] [ Sat May 07, 2005 8:25 pm ] |
Post subject: | |
FPS - Frames Per Second... that you program is showing. |
Author: | mike200015 [ Sun May 08, 2005 3:17 pm ] |
Post subject: | |
how do you set a FPS, and also how would i use the equation of a circle to chek ball and blok collision? |
Author: | [Gandalf] [ Sun May 08, 2005 6:51 pm ] |
Post subject: | |
If the radius of the circle and the dimensions of the block overlap, then you know you have a collision. For setting a fps limit, you just use a variable, and check if the current fps is above it. I am pretty sure there is a tutorial on it, or this is covered in some tutorial, check that out. |