The new source code
Rem Project: pong
Rem Created: 2005-03-04 22:28:44
Rem ***** Main Source File *****
rem settings
settings()
rem load level
make_lvl()
rem load ball, players and settings
load_players()
rem included variabels
included_variabels()
do
rem player movvement code
players_movement()
rem ball movement code
ball_movement()
sync
loop
rem functions
function settings()
sync on
sync rate 70
hide mouse
make camera 1 : position camera 1,0,0,-50 : color backdrop 1,RGB(0,0,0)
endfunction
function make_lvl()
load object "media/models/tak.3ds",4 : position object 4,0,25,0 : color object 4,RGB(0,0,255) : scale object 4,20,20,20 : rotate object 4,0,90,0
load object "media/models/tak.3ds",5 : position object 5,0,-25,0 : color object 5,RGB(0,0,255) : scale object 5,20,20,20 : rotate object 5,180,90,0
make object box 6,2,46.5,6
position object 6,0,0,0
ghost object on 6
color object 6,RGB(0,128,255)
endfunction
function load_players()
load object "media/models/hover.3ds",1 : color object 1,RGB(0,0,255) : position object 1,-32,0,0 : scale object 1,20,20,20 : rotate object 1,160,0,90
load object "media/models/hover.3ds",2 : color object 2,RGB(0,0,255) : position object 2,32,0,0 : scale object 2,20,20,20 : rotate object 2,340,180,90
make object sphere 3,1.5
endfunction
function included_variabels()
inc p1mvu
inc p1mvd
inc p2mvu
inc p2mvd
rem variabels that makes the players stay on screen
inc p1y+stop
inc p1y-stop
inc p2y+stop
inc p2y-stop
endfunction
function players_movement()
p1mvu=0
p1mvd=0
p2mvu=0
p2mvd=0
p1yustop=0
p1ydstop=0
p2yustop=0
p2ydstop=0
if upkey()=1 and p2yustop=0 then p2mvu=1
if downkey()=1 and p2ydstop=0 then p2mvd=1
if keystate(17)=1 and p1yustop=0 then p1mvu=1
if keystate(31)=1 and p2ydstop=0 then p1mvd=1
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
x2#=object position x(2)
y2#=object position y(2)
z2#=object position z(2)
if p1mvu=1
y#=y#+0.5
endif
if p1mvd=1
y#=y#-0.5
endif
if p2mvu=1
y2#=y2#+0.5
endif
if p2mvd=1
y2#=y2#-0.5
endif
` Below is the bit stopping the player leaving the arena `
if y#>25 then y#=25
if y#<-25 then y#=-25
if y2#>25 then y2#=25
if y2#<-25 then y2#=-25
position object 1,x#,y#,z#
position object 2,x2#,y2#,z2#
rem make the players stay on screen
if object position y(1)>15 then p1yustop=1
if object position y(1)<15 then p1ydstop=1
if object position y(2)>15 then p2yustop=1
if object position y(2)<15 then p2ydstop=1
endfunction
function ball_movement()
endfunction