I just finished making my first game (pong using this tut
http://forum.thegamecreators.com/?m=forum_view&t=22030&b=7)
and am now trying to make a break-out game. I need the ball to bounce off the top of the stage. I am doing this by checking if the z coordinants are more than 15. Here is my code:
rem Create the paddle and ball then color them
make object box 1,3,1,1:color object 1,rgb(255,200,0)
make object sphere 2,1:color object 2,rgb(150,0,0)
rem Position the camera
position camera 0,25,0:point camera 0,0,5
rem Turn on manual syncing
sync on
rem Set begining ball direction and position
balla#=0
ballz#=1.5
rem Start the main loop
do
rem Move the paddle
position object 1,padx#,0,0
rem Move the ball
position object 2,ballx#,0,ballz#
rem Move the paddle left
if leftkey()=1 and padx#>-10 then padx#=padx#-0.5
rem Move the paddle right
if rightkey()=1 and padx#<10 then padx#=padx#+0.5
rem Get the new ball x and z coordinants
ballx#=newxvalue(ballx#,balla#,0.5)
ballz#=newzvalue(ballz#,balla#,0.5)
rem Make the ball bounce if the ball is at the top of the screen
if ballz#>=15 then balla#=360-balla#
rem Wrap the "balla" value
balla#=wrapvalue(balla#)
rem Print vars (for de-bugging)
set cursor 0,0
print ballz#
set cursor 0,15
print balla#
rem Sync
sync
rem End the main loop
loop
What is wrong? I have the angle wraping and the z detection right (I think...) Thank you,
Tim
Timothy Sassone