Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Breakout help

Author
Message
Gloinchin 11
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 16th Mar 2004 02:47 Edited at: 16th Mar 2004 02:48
Can somebody plz help me make the ball bounce from the paddle and the blocks? And how do you do angles? Also I would like to kno how to make the blocks disappear when the ball hits the blocks. Thx.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 16th Mar 2004 03:33 Edited at: 16th Mar 2004 03:33
the way I did my breakout was the ball is object 1, the blocks are objects 10 to 163 Then you test collision between object 1 and any with:


intBlockHit gets the number of the collided object, then if it's between 10 and 163 we know its a block and the object is deleted.

as far as toggling the ball movement on the y and x axises I can tell you that multiplying your ball travel speed value (whether it is neg or pos) by -1 will keep its same value but flip flop the neg/pos portion...

5 * -1 = -5
-5 * -1 = 5

hope this helps


"What the... Moooooooo!"
Gloinchin 11
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 16th Mar 2004 03:47
Thx, that kinda helped but could you or someone else help me with the bouncing part cuz i won't be able to test the intBlockHit without the ball bouncing.
One Common Ruin
20
Years of Service
User Offline
Joined: 19th Jan 2004
Location: United States
Posted: 16th Mar 2004 04:04
You should check Chris Knotts Pong tutorial. That should explain how to get the ball bouncing.
Gloinchin 11
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 16th Mar 2004 04:07
Yes, I've seen it before. It worked well for my Pong game but for some reason the same code used in it won't work in this game. If someone could solve my problem I would really appreciate it. Thx.

Here's the main loop:

rem MAIN LOOP
player1pos#=0
sync on:do
for a=1 to 75
if object position y(77)=object position y(a) and object position x(77)=object position x(a) then delete object a
a=a+1
next a
rem BALL MOVEMENT
position object 77,ballx#,0,ballz#:yrotate object 77,balla#
ballx#=newxvalue(ballx#,balla#,0.2)
ballz#=newzvalue(ballz#,balla#,0.2)
rem PADDLE MOVEMENT
if rightkey()=1 then player1pos#=player1pos#+1
if leftkey()=1 then player1pos#=player1pos#-1
position object 76,player1pos#,5,-13
rem BOUNCING
if ballz#<-13 and ABS(player1pos#-ballz#)<0.5 then balla#=360-balla#
if ballz#<-13 then balla#=180-balla#
if ballz#>1.4 then balla#=180-balla#
rem ANGLING THE BALL
if leftkey()=1 and ballx#<-13 then balla#=balla#+20
if rightkey()=1 and ballx#<-13 then balla#=balla#-20
sync on:loop
Gloinchin 11
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 16th Mar 2004 23:22
can someone plz help me?

Login to post a reply

Server time is: 2024-09-22 03:04:16
Your offset time is: 2024-09-22 03:04:16