Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Deleting the brick when the ball hits its
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Velocity




PostPosted: Mon Jan 09, 2012 8:29 am   Post subject: RE:Deleting the brick when the ball hits its

but i only used 1 variabloe... here this is what i did.

proc Bricks (len, wid, col, xbound, ybound, spacex, spacey : int)
var displacex : int := len + spacex
var displacey : int := wid + spacey

var bricksx : int := round (xbound / displacex)
var bricksy : int := round (ybound / displacey)

var ar_len : int := bricksx * bricksy - 1

var cur_x : int := 35
var cur_y : int := maxy + 40

for i : 0 .. ar_len
drawfillbox (cur_x, cur_y - wid, cur_x + len, cur_y, col)
cur_x := cur_x + displacex

if cur_x + len > xbound then
cur_x := 35
cur_y := cur_y - displacey
end if
delay (0)
end for
end Bricks

thats the code i have for my bricks.
Sponsor
Sponsor
Sponsor
sponsor
Dreadnought




PostPosted: Mon Jan 09, 2012 12:14 pm   Post subject: Re: Deleting the brick when the ball hits its

Well why not just draw a white box over the brick. Then it is "erased".

Alternately you can add to your procedure (if statements might be of use to you) to have it function in a way that resembles Aange10's example.
Velocity




PostPosted: Mon Jan 09, 2012 3:32 pm   Post subject: RE:Deleting the brick when the ball hits its

omg... im so fucking retarded now... i actually never thought of that... wow i think too far away from the actual problem, too deep into it, thank you so much dreadnought. you saved my life!
Velocity




PostPosted: Mon Jan 09, 2012 3:34 pm   Post subject: RE:Deleting the brick when the ball hits its

i implemented my brick collision and everything but since i half so many bricks made of one variable when i hit a brick they all disappear... how do i make the collision to delete the brick so that only one disappears (the one that i hit) ?
Dreadnought




PostPosted: Mon Jan 09, 2012 4:06 pm   Post subject: Re: Deleting the brick when the ball hits its

Well, your procedure draws all the bricks at once. So either you draw them all at the beginning and erase them one at a time by drawing white boxes over them, or you modify your procedure to only draw the bricks that should be shown. It is useful (and, depending on your approach, essential) to use some data structure (like an array) to keep track of which bricks are "alive" and which ones are "dead", so you might need more than a single variable.
Velocity




PostPosted: Mon Jan 09, 2012 4:39 pm   Post subject: RE:Deleting the brick when the ball hits its

yea i see what your saying, but how do i tell the ball that it just hit the brick? im not asking to be rerouted to the popular brick to circular collision detection i just want a simple detour of how to do this.
Aange10




PostPosted: Mon Jan 09, 2012 5:35 pm   Post subject: RE:Deleting the brick when the ball hits its

Quote:
i just want a simple detour of how to do this.


There are many. You've read the collision tutorial. It shows you how to do it. Whatdotcolor shows another way. The 60BILLION submissions of pong in the submissions forum have collision. The tons of people asking the exact same question in the last few months have your answer.

If you want simple, then here it is:

Check to see if any parts of the objects are touching.

If that's not good enough, do some reading, instead of specifically asking us not to link you anything, and instead give you a 'simple detour'.
Velocity




PostPosted: Mon Jan 09, 2012 7:42 pm   Post subject: RE:Deleting the brick when the ball hits its

well your fun...
Sponsor
Sponsor
Sponsor
sponsor
Aange10




PostPosted: Mon Jan 09, 2012 7:48 pm   Post subject: Re: RE:Deleting the brick when the ball hits its

Velocity @ 9/1/2012, 6:42 pm wrote:
well your fun...


Elaborate?
Dreadnought




PostPosted: Mon Jan 09, 2012 9:39 pm   Post subject: Re: Deleting the brick when the ball hits its

You may not appreciate this question, but, could you show us what you have tried?
Velocity




PostPosted: Tue Jan 10, 2012 12:16 am   Post subject: RE:Deleting the brick when the ball hits its

aange :

I dont what it is but all of your text originated posts have made me laugh hard, to date. I dont mean to be rude, not at all, i just find it funny, and the strange part of have no friggin clue of why...

Dreadnought :

I completely appreciate your question, you reminded me of what i needed to do. I will most certainly add my code, just when i get to school tomorrow, cus right now im supposed to be sleeping but im on my phone, stuck to these forums Razz but yea... As soon as i get to class tomorrow i'll show you my code of what i ''tried''

*aside* darn it would be so awesome if i could program on my phone... Then i would never sleep xD
Aange10




PostPosted: Tue Jan 10, 2012 7:59 am   Post subject: RE:Deleting the brick when the ball hits its

Quote:

I dont what it is but all of your text originated posts have made me laugh hard, to date. I dont mean to be rude, not at all, i just find it funny, and the strange part of have no friggin clue of why...


I'm not sure why all of the posts make you laugh, but whatever floats your boat. Albiet your confusing post, I'll be ready to see your code.

However I'm surprised you didn't remember how to do collision:

Velocity @ 10/1/2012, 12:05 am wrote:

html is quite simple, i learned all the basics to make a simple website on my own and used w3schools to pick up the general skills, all round it took me about 30 mins to understand the main concept aside from my amazing memory...
Velocity




PostPosted: Tue Jan 10, 2012 8:33 am   Post subject: RE:Deleting the brick when the ball hits its

no no, i know how to do collision, i just seem to be having a problem with the code because sometimes it hits and destroys the blocks and sometimes it doesnt.... Its strange.
Aange10




PostPosted: Wed Jan 11, 2012 8:41 am   Post subject: RE:Deleting the brick when the ball hits its

Quote:

Its strange.


You [hopefully] coded it.

If you don't understand, look at one of the pong submissions.
Velocity




PostPosted: Wed Jan 11, 2012 8:43 am   Post subject: RE:Deleting the brick when the ball hits its

yea i got it figured out. Thanks
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 30 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: