Ok guys- sorry for posting a new topic the last one wasnt supposed to be sent! Yeah so this time, i have resized a playing board of my pong game - and altered my two paddles and their movement limits appropriatly leaving just the balls collision detection to be sorted - i have given this a bash but simply havent found out how to do it. Im sure it has to do with the
\"rem the balls bouncing movement if it hits the paddles
if ballx#>4 and ballx#<4.5 and ABS(player1pos#-ballz#)<1.5 then balla#=360-balla#
if ballx#<-4 and ballx#>-4.5 and ABS(player2pos#-ballz#)<1.5 then balla#=360-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#\"
Bit but i simply cannot no matter what i change thoose numbers to work out, how to stop the ball at the new paddles locations, the ball just kiks about in the middle of the field where the old paddle locations were. If some pro would help me out i would be very very appreciative a
nd explain what i am doing wrong so i learn and thus are able to not only program better but also teach others.
This is the whole code :
set display mode 1024,768,32
rem hides the mouse
hide mouse
rem makes the refresh rate 40
sync rate 40
rem makes both the paddles - the ball and the table
make object box 1,1,2,3:color object 1,rgb(255,0,0)
make object box 2,1,2,3:color object 2,rgb(0,255,0)
make object sphere 3,1:color object 3,rgb(0,0,50)
make object box 4,60,0.1,35:position object 4,0,-0.55,0
rem makes the starting angle of the ball at 70 degrees
balla#=70
rem starts the main loop and insures vsync is on
sync on:do
rem the scoring code if the ball is past the bat then its +1 to the score and the creation of the scoreboard
if ballx#>29 then player2score#=player2score#+1:ballx#=0:ballz#=0:balla#=270
if ballx#<-29 then player1score#=player1score#+1:ballx#=0:ballz#=0:balla#=90
set cursor 300,50:print player2score#
set cursor 320,50:print \"-\"
set cursor 340,50:print player1score#
rem making the ball move forwards all the time at the angle is travelling at
ballx#=newxvalue(ballx#,balla#,0.3):ballz#=newzvalue(ballz#,balla#,0.3)
rem paddle 1 movement - up and down keys - whilst limiting its area of movement
IF upkey()=1 and player1pos#<15.9 then player1pos#=player1pos# +0.5
IF downkey()=1 and player1pos#>-15.9 then player1pos#=player1pos# -0.5
if upkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#+8
if downkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#-8
rem paddle 2 movement - up and down keys - whilst limiting its area of movement
IF keystate(17)=1 and player2pos#<15.9 then player2pos#=player2pos#+0.5
IF keystate(31)=1 and player2pos#>-15.9 then player2pos#=player2pos#-0.5
if keystate(17)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#+8
if keystate(31)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#-8
rem the balls bouncing movement if it hits the paddles
if ballx#>4 and ballx#<4.5 and ABS(player1pos#-ballz#)<1.5 then balla#=360-balla#
if ballx#<-4 and ballx#>-4.5 and ABS(player2pos#-ballz#)<1.5 then balla#=360-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#
rem verification that the angle of the ball is between 0 and 360 or problems arise
balla#=wrapvalue(balla#)
rem the positioning of all the objects - player 1 paddle, player 2 paddle, the ball, and finally the camera
position object 1,29,0,player1pos#:position object 2,-29,0,player2pos#
position object 3,ballx#,0,ballz#:yrotate object 3,balla#
position camera 0,50,-10:point camera 0,0,0
rem verification that vsync is still running and the code for the end of a loop
sync:loop
Many thanks in advance, Andy
NO KEYBOARD DETECED - PRESS F11 TO CONTINUE - FOOKED BIOS