REM Project: birdofprey1
REM Created: 9/7/2007 4:30:10 PM
REM By: Virtual Nomad
REM ***** Main Source File *****
REM
 
set display mode 800,600,32 : sync on : sync rate 60
autocam off : set camera range 0.1,5000 : color backdrop rgb(255,255,192)
fog on : fog distance 4000 : fog color rgb(168,148,109) : randomize timer()
ink rgb(0,0,0),rgb(255,255,255)
 
make matrix 1,5000.0,5000.0,50,50
position matrix 1,-2500.0,0.0,-2500.0
randomize matrix 1,20.0
set matrix wireframe off 1
update matrix 1
 
rem body
make object box 1,10.0,10.0,30.0
 
rem rightwing
make object triangle 2,0.0,0.0,20.0,70.0,00.0,20.0,0.0,0.0,0.0
make mesh from object 1,2
add limb 1,1,1
 
delete mesh 1
delete object 2
 
rem leftwing
make object triangle 2,0.0,0.0,20.0,-70.0,0.0,20.0,0.0,0.0,0.0
make mesh from object 1,2
add limb 1,2,1
 
delete mesh 1
delete object 2
 
rem attach wings
offset limb 1,1,5.0,5.0,-5.0
offset limb 1,2,-5.0,5.0,-5.0
 
rem head
make object cube 2,10.0
make mesh from object 1,2
add limb 1,3,1
offset limb 1,3,0.0,0.0,20.0
set limb smoothing 1,3,100 `eh?
 
delete mesh 1
delete object 2
 
color object 1,rgb(143,105,45)
 
 
remstart
camy# = 0.0
camx# = 0.0
camz# = -200.0
 
 
position camera 0,0,0
point camera 0,0,100.0
remend
 
position object 1,0.0,1000.0,-200.0
set object cull 1,0
 
toggle = 1
stage = 1
wingza# = 0.0
accel# = 1.0
 
rem critter
make object sphere 10,100.0
color object 10,rgb(128,128,0)
 
 
do
 
gosub _critter
 
gosub _move:
gosub _flap:
gosub _look:
gosub _gravity:
 
gosub _kill:
 
set cursor 0,0
print screen fps()
print "speed: ",speed#
print "altitude: ", object position y(1)
print "xa#: ",object angle x(1)
sync
loop
 
_flap:
 
if mouseclick() = 1 `flap
   if lastflap + 5 < timer()
     rotate limb 1,1,0.0,0.0,(wingza#)
     rotate limb 1,2,0.0,0.0,(wingza#*-1.0)
     lastflap = timer()
     wingza# = wingza# + (toggle*5.0)
     if abs(wingza#) => 45.0
         toggle = toggle * -1
     endif
 
   endif
else `glide
   if wingza# <> 0.0
      if wingza# < 0.0
         toggle = 1
      else
         toggle = -1
      endif
 
      if lastflap + 10 < timer()
         wingza# = wingza# + (toggle * 5.0)
         rotate limb 1,1,0.0,0.0,wingza#
         rotate limb 1,2,0.0,0.0,(wingza#*-1.0)
         lastflap = timer()
      endif
   endif
endif
 
 
return
 
_look:
 
headya# = headya# + (mousemovex()/4.0)
headxa# = headxa# + (mousemovey()/4.0)
if headya# < -45.0 then headya# = -45.0
if headya# > 45.0 then headya# = 45.0
if headxa# < -45.0 then headxa# = -45.0
if headxa# > 45.0 then headxa# = 45.0
 
rotate limb 1,3,headxa#,headya#,0.0
 
 
px# = object position x(1) : py# = object position y(1) : pz# = object position z(1)
pya# = object angle y(1) : pxa# = object angle z(1) : pza# = object angle z(1)
 
if controlkey() = 1 `lock camera for swoop
   camya# = pya#
   camxa# = pxa#+40.0
   camza# = pza#
else
camya# = wrapvalue(pya# + headya#) : camxa# = wrapvalue(pxa# + headxa#)
camza# = pza#
endif
 
position camera px#,py#,pz#
 
rotate camera camxa#,camya#,camza# : move camera -200.0
return
 
_move:
 
if mouseclick() = 1 then accel# = 2.0 else accel# = 1.0
 
if upkey() = 1 and lastkey + 10 < timer()
   xrotate object 1,(object angle x(1) + (1.0*accel#))
   if object angle x(1) > 80.0 then xrotate object 1,80.0
   lastkey = timer()
endif
 
if downkey() = 1 and lastkey + 10 < timer()
   xrotate object 1,(object angle x(1) - (1.0*accel#))
   if object angle x(1) < -80.0 then xrotate object 1,-80.0
   lastkey = timer()
endif
 
if leftkey() and lastkey + 10 < timer()
   yrotate object 1,wrapvalue(object angle y(1) - (1.0))
   lastkey = timer()
endif
 
if rightkey() and lastkey + 10 < timer()
   yrotate object 1,wrapvalue(object angle y(1) + (1.0))
   lastkey = timer()
endif
 
 
 
speed# = abs(object angle x(1)/10.0)*accel#
if speed# < 1.0 then speed# = 1.0*accel#
 
move object 1,speed#
 
 
return
 
_gravity:
vel# = abs(object angle x(1))*0.1
position object 1,object position x(1),object position y(1)-vel#,object position z(1)
return
 
_critter:
critspeed# = 10.0
tcrit = rnd(500) + 500
if lastcritmove + tcrit < timer()
   yrotate object 10,wrapvalue(rnd(90)-45.0)
   scurry = rnd(4)
   if scurry < 4
      move object 10,critspeed#
      color object 10,rgb(255,255,0)
   else
      color object 10,rgb(255,255,255)
   endif
   lastcritmove = timer()
endif
 
vy# = get ground height (1,object position x(10),object position z(10))
position object 10,object position x(10),vy#+50.0,object position z(10)
 
return
 
_kill:
 
kpx# = object position x(1) : kpy# = object position y(1) : kpz# = object position z(1)
cpx# = object position x(10) : cpy# = object position y(10) : cpz# = object position z(10)
 
if abs(kpx#-cpx#) < 51.0 and abs(kpy#-cpy#) < 51.0 and abs(kpz#-cpz#) < 51.0
   color object 10,rgb(255,0,0)
endif
return