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.

DarkBASIC Discussion / Collision Help

Author
Message
Flaming Ghost
20
Years of Service
User Offline
Joined: 29th Apr 2005
Location: Um...Right here
Posted: 24th May 2005 09:48
I'm making a game where you bounce a ball, and try to hit these blocks on the top of the screen. When you hit the blocks, the blocks disapear, and you bounce away. I would like to make it so that when you hit the side of the blocks, you bounce sideways, and when you hit the bottom, you bounce down. Please ask if you don't understand

Am I dead yet?
Underworld 1020
21
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 24th May 2005 23:51
If you post some of your code I should be able to help you .

Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 25th May 2005 13:43
like gravity ball

NARUTO IS THE NINJA.......not really
Flaming Ghost
20
Years of Service
User Offline
Joined: 29th Apr 2005
Location: Um...Right here
Posted: 26th May 2005 08:23
Oh, sorry, here's my code.
Sorry, I don't know how to make a code snippet,

`STARTING STUFF
Sync On
Autocam Off
Hide Mouse
Position Camera 0,28,-50

`BALL & YOU
Make Object Cube 2,10
Scale Object 2,100,20,10
Position Object 2,0,0,0
make object collision box 2,-5,-2,-2,5,2,2,0
Make Object Sphere 1,3
Position Object 1,0,10,0
make object collision box 1,-1.5,-1.5,-1.5,1.5,1.5,1.5,0

`MAKE BLOCKS!
Make Object Cube 50,5
Position Object 50,0,35,0
Color Object 50,rgb(200,10,10)
make object collision box 50,-2.5,-2.5,-2.5,2.5,2.5,2.5,0

`SET VARIABLES
px#=0
x#=0
y#=10
h_speed#=0.4
v_speed#=0.6

`MAIN GAME LOOP
Do

`BALL PHYSICS
inc x#,h_speed#
inc y#,v_Speed#
If x#<-34 or x#>34 then h_speed#=h_speed#*-1
If y#>56 then v_speed#=v_speed#*-1
Position Object 1,x#,y#,0

If Object Collision(1,2)>0
v_speed#=.2
h_speed#=h_speed#+speed#
If h_speed#>4 then h_speed#=4
If h_speed#<-4 then h_speed#=-4
endif

`MOVING BOTTOM PADDLE
If px#<-34 then px#=-34
If px#>34 then px#=34
Position object 2,px#,0,0

If leftkey()=1
px#=px#-0.7
speed#=0.5
else
speed#=0
endif
If rightkey()=1
px#=px#+0.7
speed#=0.5
else
speed#=0
endif

`Busting Brick
If Object Collision(1,50)>0
h_speed#=h_speed#*-1
Delete Object 50
endif

`LOSING
If y#<-5 : Set Cursor 10,5 : Print "OHHHHHHHH" : endif
If y#<-20
wait 200
h_speed#=Rnd(1)+.1
v_speed#=.6
x#=0
y#=10
cls
endif

`END OF MAIN GAME LOOP
Sync
Loop

Am I dead yet?

Login to post a reply

Server time is: 2025-05-23 00:17:49
Your offset time is: 2025-05-23 00:17:49