TGC Codebase Backup



Battle of the Cones by Alexander Altman

28th Jul 2009 18:19
Summary

an endless battle between cones



Description

Choose haw many cones to create on each side and whether or not you are detectable (boolean value), then watch as the Dark AI engine manuvers them all around.

must Must MUST have both eXtends and Dark AI to run from code; for those without both, the compile .exe file is attached



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: Battle of the Cones
Rem Created: 5/25/2009 5:53:20 PM

Rem ***** Main Source File *****

`initialization
ai start
void = ext initialized()
cls
randomize timer()

`initial conditions
playeron as boolean
input "# of enemies? ", n1
input "# of allies? ", n2
input "# of civilians? ", n0
input "Player included? ", playeron
sync on
sync rate 0

`make the arrays
dim enemy(n1)
dim ally(n2)
dim neutral(n0)

`load up the objects
for ce = 1 to n1
 enemy(ce) = b3d make object cone( 5 )
 color object enemy(ce), rgb(255,0,0)
 xrotate object enemy(ce), 90
 yrotate object enemy(ce), 45
 position object enemy(ce), (rnd(10)-5)*n1, 0, (rnd(10)-5)*n1
 set object cull enemy(ce), 0
 ai add enemy enemy(ce)
next ce

for ce = 1 to n2
 ally(ce) = b3d make object cone( 5 )
 xrotate object ally(ce), 90
 yrotate object ally(ce), 45
 color object ally(ce), rgb(0,0,255)
 position object ally(ce), (rnd(10)-5)*n2, 0, (rnd(10)-5)*n2
 set object cull ally(ce), 0
 ai add friendly ally(ce)
next ce

for ce = 1 to n0
 neutral(ce) = b3d make object cone( 5 )
 color object neutral(ce), rgb(0,255,0)
 xrotate object neutral(ce), 90
 yrotate object neutral(ce), 45
 position object neutral(ce), (rnd(10)-5)*n0, 0, (rnd(10)-5)*n0
 set object cull neutral(ce), 0
 ai add neutral neutral(ce)
next ce

color backdrop 0, rgb(0,0,0)
set ambient light 62
position camera 0, 0, 0
if playeron=1 then ai add player n0+n1+n2+1,0
ai update

`main loop
do
 control camera using arrowkeys 0, 0.00032*(n1+n2+n0), 0.0011*(n1+n2+n0)
 if playeron=1 then ai set player position camera position x(), camera position z()
 ai update
 sync
loop