` AI PROJECT==============
` By DARKDRAGON======================
` ===========================
 
rem 
 
sync on
make matrix 1,3000,3000,30,45 
 
make object cube 10,50
color object 10,RGB(0,255,0)
 
for fr=1 to 5
 
make object cube fr,40
color object fr,RGB(0,255,0)
randomize timer()
randomize timer()
randomize timer()
randomize timer()
randomize timer()
randomize timer()
randomize timer()
position object fr,Rnd(2000),Rnd(0),Rnd(2000)
 
next fr
 
ink RGB(255,0,0),RGB(255,0,0)
 
Do
 
Gosub _Player
Gosub _AI
 
sync
Loop
 
_Player:
 
if upkey()=1 then move object 10,10  
if downkey()=1 then move object 10,-10
if rightkey()=1 then inc a#,2
if leftkey()=1 then dec a#,2
 
 
a#=wrapvalue(a#)
x#=object position x(10)
z#=object position z(10)
y#=get ground height(1,x#,z#)+8+offy
position object 10,x#,y#,z#
 
 
yrotate object 10,a#
 
cx#=newxvalue(x#,wrapvalue(a#+180),+480)
cz#=newzvalue(z#,wrapvalue(a#+180),+480)
cy#=get ground height(1,cx#,cz#)+200.0
position camera cx#,cy#,cz#
point camera x#,y#,z#  
 
return
 
_AI:
 
for fr=1 to 5
Dist#=Sqrt((x# - object position x(fr))^2 + (y#+25 - object position y(fr))^2 + (z# - object position z(fr))^2)
If Dist#=<240 and Dist#=>80 
 set cursor object screen x(fr),object screen y(fr) 
 
if fr=1 then Print "What's Up?"  
if fr=2 then Print "What you looking at?" 
if fr=3 then Print "Hello."
 
if fr=4 and win=0
 
 
Print "Hey Big Bro! Where ya going?"
point object fr,x#,y#,z#
move object fr,1
 
endif
 
 if fr=5 then Print "Hi."  
 
endif
 
if fr=4 
 
If Dist#=<540 and Dist#=>80 
if win=0
 
 set cursor object screen x(fr),object screen y(fr) 
Print "Hey Big Bro! Where ya going?"
point object fr,x#,y#,z#
move object fr,3
 
endif
 
endif
 
 
endif
 
 
 
 
If Dist#=<100 
 set cursor object screen x(fr)-100,object screen y(fr)+15 
 if fr=1 then Print "Don't Get to close,man!" : point object fr,x#,0,z# 
 if fr=2 then set cursor object screen x(fr)-0,object screen y(fr)+15 : Print ".......Back off,Punk." : point object fr,x#,0,z#
 if fr=3 then Print "Hello....Uh..": point object fr,x#,0,z#
 if fr=4 and win=0 then Print "Wanna Play a Game?(Press z to Play)": point object fr,x#,0,z#: if inkey$()="z" then gosub _BroGame
 if fr=4 and win=1 then Print "Man! YOU CHEATED!!!...": point object fr,x#,0,z# 
 if fr=4 and win=2 then Print "HAH!!! I Beat You!!!HAHAHHA! ": point object fr,x#,0,z# 
 if fr=5 then Print "...."  : point object fr,x#,0,z#
endif
 
if fr=>3 and Dist#=>100
 
yrotate object fr,wrapvalue(object angle y(fr)+1)
move object fr,2
 
endif
 
next fr
 
 
return
 
_BroGame:
ink RGB(255,0,0),0
 
cls 
backdrop off
sync
 
Print "Okay,Big Bro! Tap the spacebar to run,z to jump!"
Print "First one to the finish line wins!(Press enter)"
sync
 
wait 1000
wait key
 
for q=1 to 10
if object exist(q)=1
hide object q
endif
next q
 
make object cube 100,40
make object cube 101,40
color object 100,Rgb(0,255,0)
color object 101,Rgb(0,255,0)
 
 
 
backdrop on
sync on
 
x#=object position x(101)
z#=object position z(101)
y#=get ground height(1,x#,z#)+8+offy
position object 100,x#,y#,z#
 
 
yrotate object 100,0
 
for speed=25 to 1 step -1 
 
x#=object position x(100)
z#=object position z(100)
a#=object angle y(100)
 
cx#=newxvalue(x#,wrapvalue(a#+0),+480)
cz#=newzvalue(z#,wrapvalue(a#+0),+480)
cy#=get ground height(1,cx#,cz#)+200.0
position camera cx#,cy#,cz#
point camera x#,y#,z#  
 
move object 100,speed 
 
sync
 
next speed
 
for an=0 to 270 step 4
 
 
cx#=newxvalue(x#,wrapvalue(a#+an),+480)
cz#=newzvalue(z#,wrapvalue(a#+an),+480)
cy#=get ground height(1,cx#,cz#)+200.0
position camera cx#,cy#,cz#
point camera x#,y#,z#  
 
sync
next an
 
sync on
 
x#=object position x(100)
z#=object position z(100)
 
for g=30 to 32 
randomize timer()
make object cube g,100
position object g,x#+g+Rnd(75)*80,-70,z#
if object collision(100,0)=g then delete object g 
next g
 
 
yrotate object 100,90
yrotate object 101,90
wait 500
set cursor 1,1
backdrop off
cls
Print "1..."
wait 100
sync
Print "2..."
wait 100
sync
Print "3...."
wait 100
sync
 
Print "GO!!"
wait 100
sync
sync on
backdrop on
do
 
if spacekey()=1 and tap=0 then tap=1 : inc speed,4
if spacekey()=0 then dec speed
if speed=>20 then speed =20
if speed=<0 then speed =0
 
set cursor 10,10
 
g=object collision(100,0)
if g=>1 and object collision(100,0)=g then delete object g :speed=0
 
Print object collision(100,0)
` if object collision(100,0)=>0 then speed=0
 
 
 
move object 100,speed
 
 
move object 101,10
 
 
x#=object position x(100)
z#=object position z(100)
if inkey$()="z" then jump=1
if jump=1 then inc offy,8
y#=get ground height(1,x#,z#)+offy
if offy=>60 then offy=60:jump=0
if offy=>1 and jump=0 then offy=offy-1
 
 
x2#=object position x(101)
z2#=object position z(101)
 
cx#=newxvalue(x#,wrapvalue(a#+an),+480)
cz#=newzvalue(z#,wrapvalue(a#+an),+480)
cy#=get ground height(1,cx#,cz#)+200.0
position camera cx#,cy#,cz#
position object 100,x#,y#,z#
point camera x#,y#,z#  
 
set cursor 1,1
Print Str$(x#)+","+Str$(z#)
if x#=>2100 then win=1:exit
if x2#=>2100 then win=2:exit
 
if spacekey()=0 and tap=1 then tap=0   
 
sync
loop
cls
backdrop off
sync
cls
if win=1 then cls: Print "YOU WIN!"
 
if win=2 then cls: Print "YOU LOSE!"
 
sync
 
wait 2000 
backdrop on
sync
for q=1 to 100
if object exist(q)=1
hide object q
endif
next q
for q=1 to 10
if object exist(q)=1
show object q
endif
next q
 
return