Rem Project: Zombie Command Squad
Rem Created: Saturday, February 05, 2011
Rem ***** Main Source File *****
REMSTART
Not your typical zombie game. Zombies are not a force of ignorant
monsters without a direction. They are a force of ignorant monsters
being led by you! Control your swarm to attack the surivors and
build your army! Along the way you will aquire various mutants
and monsters as you destroy the human population.
remend
sync on: sync rate 60
autocam off
//Zombie type
type Zombie
obj as integer
tex as integer
speed as integer
damage as integer
health as integer
endtype
AI Start
AI Set Radius 2.5
//Set up
gosub LoadCity
gosub SetupCamera
gosub SetupCharacters
//
//MAIN LOOP
//
DO
gosub Camera
AnimateMobZombie(Test.obj)
AI Update
sync
LOOP
///
///SUBS
///
LoadCity:
city = b3d load object("Media/City/testcity.x")
AI Add Obstacle From Level city,10,10,10
AI Complete Obstacles
return
Setupcamera:
cx#=0
cy#=350.0
cz#=0
cspeed#=6
return
SetupCharacters:
Test as zombie
Test.obj=b3d load object("Media/Zombies/mobzombie1.x")
Test.tex= IMG load image("Media/Zombies/mobzombie1_D2.dds")
texture object Test.obj,Test.tex
position object Test.obj,0,0,0
rotate object Test.obj,0,180,0
Fix Object Pivot Test.obj
AI Add Friendly Test.obj
AI set entity can roam Test.obj,1
AI Set Entity Speed Test.obj,20
Return
Camera:
if upkey() then inc cz#,cspeed#
if downkey() then dec cz#,cspeed#
if rightkey() then inc cx#,cspeed#
if leftkey() then dec cx#,cspeed#
if scancode()=30 then inc cy#,1
if scancode()=44 then dec cy#,1
if cy#>700 then cy#=700
if cy#<200 then cy#=200
offsetx# = cx#
offsety# = 0
offsetz# = cz#+200
position camera cx#,cy#,cz#
point camera offsetx#,offsety#,offsetz#
return
Function AnimateMobZombie(obj)
text 0,0,AI get entity action$(obj)
endfunction
Unless you have the Zombie Apocalypse pack for FPSC you'll have to modify it to run it.
My problem. If you look under the sub SetupCharacters you'll see I have created a zombie named Test based on the zombie type I declared near the beginning of the program. Now if I go and use AnimateMobZombie(Test.obj) in the main DO LOOP part of my program the compile shoots back an error saying Test doesn't exist. BUT if I copy the code from the SetupCharacters routine and place it right before the DO LOOP it'll work just fine. Any insight on this? Am I simply missing a syntax rule here?
EDIT
It was something simple. I'm guessing you have to create the member of the type outside of a sub in order for it to work. Once it's created you can still do whatever to it. It's really weird though...
Go ahead. Walk into Mordor.
Ball State University - Biology Major