TGC Codebase Backup



PONG GAME ENGINE by Reign

14th Jul 2006 1:07
Summary

I'm new to this whole programming business, and i just finished my first game, a pong game, so here's the game engine for it.



Description

in order to use the engine PLAY must be set to 1 and you must either set pvsp(2players) or pvscpu(1player) to 1 and tmode(1 ball) or dsmode(2 balls) must be set to one.
and since it is just the engine, you will need to work on the rest of it to get it to work, i hope you enjoy and help me became a good programmer



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    rem left paddle variables
Lp=100
Tp=400
Rp=150
Bp=600
S=3
rem right paddle variables
LLp=1100
TTp=400
RRp=1150
BBp=600
SS=3
rem ball variables
X=630
Y=506
X2=630
Y2=518
RAD=10
SPEEDX=-3
SPEEDY=2
BORDER=20
SPEEDXX=3
SPEEDYY=-2
rem play variables
play=0
pvsp=0
pvscpu=0
tmode=0
dsmode=0


while play=1
scoring=1
cls
ink white,black
box Lp,Tp,Rp,Bp
box LLp,TTp,RRp,BBp
line 0,0,1279,0
line 0,0,0,1023
line 1279,0,1279,1023
line 0,1023,1279,1023
line 630,0,630,1024
rem left paddle movements

if shiftkey()=1
Tp=Tp-S
Bp=Bp-s
endif
if controlkey()=1
tp=tp+s
bp=bp+s
endif

rem right paddle movements
if PVSP=1
if upkey()=1
ttp=ttp-s
bbp=bbp-s
endif
if downkey()=1
ttp=ttp+s
bbp=bbp+s
endif
endif

rem paddle boundaries
remstart
if tp<5-s
tp=5-s
s=0
endif
if bp>1024-s
bp=1024-s
s=0
endif
remend


rem Regular Mode
if tmode=1 and scoring=1
circle X,Y,RAD
rem ball 1 movements
x=x+speedx
y=y+speedy
if x>1280-border
x=1280-border
speedx=speedx*-1
goall=goall+1
endif
if x<border
x=border
speedx=speedx*-1
goalr=goalr+1
endif
if y>1024-border
y=1024-border
speedy=speedy*-1
endif
if y<border
y=border
speedy=speedy*-1
endif

rem ball 1 hitting off left paddle movement
if x<rp and y>tp and y<bp
speedx=speedx*-1
endif
if x<lp and y>tp and y<bp
speedx=speedx*-1
endif

rem ball 1 hitting off right paddle movement
if x>llp and y>ttp and y<bbp
speedx=speedx*-1
endif
if x>rrp and y>ttp and y<bbp
speedx=speedx*-1
endif
endif

rem DSMode
if dsmode=1 and scoring=1
circle X,Y,RAD
circle X2,Y2,RAD
rem ball 1 movements
x=x+speedx
y=y+speedy
if x>1280-border
x=1280-border
speedx=speedx*-1
goall2=goall2+1
endif
if x<border
x=border
speedx=speedx*-1
goalr2=goalr2+1
endif
if y>1024-border
y=1024-border
speedy=speedy*-1
endif
if y<border
y=border
speedy=speedy*-1
endif

rem ball 2 movements
x2=x2+speedxx
y2=y2+speedyy
if x2>1280-border
x2=1280-border
speedxx=speedxx*-1
goall2=goall2+1
endif
if x2<border
x2=border
speedxx=speedxx*-1
goalr2=goalr2+1
endif
if y2>1024-border
y2=1024-border
speedyy=speedyy*-1
endif
if y2<border
y2=border
speedyy=speedyy*-1
endif

rem ball 1 hitting off left paddle movement
if x<rp and y>tp and y<bp
speedx=speedx*-1
endif
if x<lp and y>tp and y<bp
speedx=speedx*-1
endif

rem ball 1 hitting off right paddle movement
if x>llp and y>ttp and y<bbp
speedx=speedx*-1
endif
if x>rrp and y>ttp and y<bbp
speedx=speedx*-1
endif

rem ball 2 hitting off left paddle movement
if x2<rp and y2>tp and y2<bp
speedxx=speedxx*-1
endif
if x2<lp and y2>tp and y2<bp
speedxx=speedxx*-1
endif

rem ball 2 hitting off right paddle movement
if x2>llp and y2>ttp and y2<bbp
speedxx=speedxx*-1
endif
if x2>rrp and y2>ttp and y2<bbp
speedxx=speedxx*-1
endif
endif

rem right paddle AI for TMODE
if PVSCPU=1 and tmode=1
if y>ttp and x=<rrp
ttp=ttp+15
bbp=bbp+15
endif
if y=ttp
ttp=ttp+0
bbp=bbp+0
endif
if y<bbp and x=<rrp
bbp=bbp-15
ttp=ttp-15
endif
if y=bbp
bbp=bbp+0
ttp=ttp+0
endif
endif

rem right paddle AI for DSMODE
if PVSCPU=1 and dsmode=1
if y>ttp and x=<rrp and x>x2
ttp=ttp+15
bbp=bbp+15
endif
if y=ttp
ttp=ttp+0
bbp=bbp+0
endif
if y<bbp and x=<rrp and x>x2
bbp=bbp-15
ttp=ttp-15
endif
if y=bbp
bbp=bbp+0
ttp=ttp+0
endif
if y2>ttp and x2=<rrp and x<x2
ttp=ttp+15
bbp=bbp+15
endif
if y2=ttp
ttp=ttp+0
bbp=bbp+0
endif
if y2<bbp and x2=<rrp and x<x2
bbp=bbp-15
ttp=ttp-15
endif
if y2=bbp
bbp=bbp+0
ttp=ttp+0
endif
endif
endwhile