I'm going through Chris K's Pong tutorial right now and I'm at the point now of getting the ball moving. From the tutorial, the newxvalue and newzvalues control the ball's movements, but I don't think I'm understanding how the new_value commands work because my ball is moving off at an unexpected angle. I thought that by giving the newxvalue and newyvalue a current x/y value and the same angle that I would get a new x/y value along that angle, but my ball seems to ignore the angle value, or is calculating a new one somehow. In the example code below, I have a starting angle value of 90 which I provide for both the newxvalue and newyvalue commands, but my ball seems to be shooting off at a 135 degree angle. Can anyone help explain to me why this is?
rem Pong...Regurgitated
set display mode 800,600,32
set window on : set text transparent
color backdrop rgb(0,0,0)
hide mouse
sync on : sync rate 60
make object box 1,5,30,5
make object box 2,5,30,5
make object sphere 3,5,50,50
hide object 3
xposplay1#=0
yposplay1#=55
zposplay1#=0
xposplay2#=148
yposplay2#=55
zposplay2#=0
xposball#=74
yposball#=55
zposball#=0
floor#=0
ceiling#=110
ballang#=90
ballspd#=1
position object 1,xposplay1#,yposplay1#,zposplay1#
position object 2,xposplay2#,yposplay2#,zposplay2#
position object 3,xposball#,yposball#,zposball#
position camera 74,55,-100
point camera 74,55,0
color object 1, rgb(255,0,0)
color object 2, rgb(0,0,255)
` Main game loop
`
set text font "Comic Sans MS"
set text size 32
sync
center text 400,285,"Ready?"
sync
wait 1000
center text 400,285,"Go!"
sync
wait 1000
cls
set text font "Arial"
set text size 14
show object 3
rem main game loop
do
rem set move values for player
if upkey()=1 then if (yposplay2# + 15)>=110 then yposplay2# = yposplay2# else yposplay2# = yposplay2# + 3
if downkey()=1 then if (yposplay2# - 15)<=0 then yposplay2# = yposplay2# else yposplay2# = yposplay2# - 3
rem set move values for ball
xposball# = newxvalue(xposball#,ballang#,ballspd#)
yposball# = newyvalue(yposball#,ballang#,ballspd#)
rem move objects
position object 1,xposplay1#,yposplay1#,zposplay1#
position object 2,xposplay2#,yposplay2#,zposplay2#
position object 3,xposball#,yposball#,zposball#
if escapekey()=1 then exit
sync
loop
'Just one game,' they said, and started to play. That was yesterday.
Dual Athlon 2.0/1GB RAM/GeForce Ti4200-128/Win2000 Pro