and if you just wanted to look at the code....
rem
rem AGK Application
rem
rem Landscape App
setvirtualresolution(1280,720)
setvsync(1)
//somewhere in your code you would want to load all your media
//here is some media
loadobject(100,"bunnywalk1_1.obj")
loadobject(101,"bunnywalk1_2.obj")
loadobject(102,"bunnywalk1_3.obj")
loadobject(103,"bunnywalk1_4.obj")
loadobject(104,"bunnywalk1_5.obj")
loadobject(105,"bunnywalk1_6.obj")
loadobject(106,"bunnywalk1_7.obj")
loadobject(107,"bunnywalk1_8.obj")
loadimage(100,"bunnywalk11.png")
for t=100 to 107 step 1
setobjectimage(t,100,0)
setobjectvisible(t,0)
next t
//settingup instanced bunnies
dim players#[100,20]
atplayer=1
for x=1 to 50 step 5
for y=1 to 50 step 5
if atplayer<101
players#[atplayer,0]=1 //entity type
players#[atplayer,1]=(x*20)
players#[atplayer,2]=0
players#[atplayer,3]=(y*20)
players#[atplayer,18]=random(1,155) //random color red
players#[atplayer,19]=random(1,155) //random color green
players#[atplayer,20]=random(1,155) //random color blue
atplayer=atplayer+1
endif
next y
next x
//ok there is now 100 bunnies that are going to animate randomly
//for this example they will move and animate
setcamerarange(1,1,5000)
do
print("100x bunnies animated and using the same")
print("original instanced 8 frames...")
updateentities()
setcameraposition(1,250,300,1400)
setcameralookat(1,250,0,500,0)
Sync()
loop
function updateentities()
for e=1 to 100 step 1
if players#[e,0]>0
//entity exists
if players#[e,0]=1 then bunny1(e) //entity type is a bunny
endif
next e
endfunction
function bunny1(enemy)
playerx#=players#[enemy,1]
playery#=players#[enemy,2]
playerz#=players#[enemy,3]
playeronground=players#[enemy,4]
gravity#=players#[enemy,5]
angley#=players#[enemy,8]
movex#=players#[enemy,9]
frame=players#[enemy,11]
framecnt#=players#[enemy,12]
//instance a frame if none exists
if getobjectexists(600+enemy)=0
//deleteobject(600+enemy)
instanceobject(600+enemy,100)
setobjectvisible(600+enemy,1)
endif
//adjust gravity
if playeronground=0
gravity#=gravity#-1.0
if gravity#<-20 then gravity#=-20
endif
if playery#<0
//ok its on the ground
gravity#=0.0
playery#=0.0
playeronground=1
endif
//give a minor hop or control gravity
playery#=playery#+gravity#
//random what is bunny doing
action=players#[enemy,6]
timedaction=players#[enemy,7]
if timedaction>0 then timedaction=timedaction-1
// a simple control system
if timedaction=0
action=random(1,3)
if action=3 then timedaction=random(50,100) //ok im gunna stand around
if action=1 or action=2 then timedaction=random(100,200) //ok hes gunna go for a run
endif
if action=1
//move bunny left
movex#=movex#-0.5
endif
if action=2
//move bunny right
movex#=movex#+0.5
endif
//keep these bunnies in a cubed area
if playerx#>1000 then action=1
if playerx#<-500 then action=2
//speed fix maximum speed
if movex#>3.0 then movex#=3.0
if movex#<-3.0 then movex#=-3.0
if movex#<0.25 and movex#>-0.25 then movex#=0.0
if movex#>0.0 then movex#=movex#-0.25
if movex#<0.0 then movex#=movex#+0.25
//decide whichway to face
if angley#=0 then angley#=90
if movex#>0.0 then angley#=90
if movex#<0.0 then angley#=270
//move the bunny
playerx#=playerx#+movex#
//adjust animation frames based on movement
framecnt#=framecnt#+abs(movex#)
if frame=0 then frame=1
//setup stand still animation (basicaly 0 it)
if action<>1 and action<>2 and move#=0.0
frame=1
framecnt#=0.0
if getobjectexists(600+enemy)=1
deleteobject(600+enemy)
instanceobject(600+enemy,99+frame)
setobjectvisible(600+enemy,1)
endif
endif
//control animation movement
if framecnt#>10.0
framecnt#=framecnt#-10.0
frame=frame+1
if frame=>9 then frame=1
if frame=5 then gravity#=gravity#+random(5,7) //give bunny a hop on this frame
if getobjectexists(600+enemy)=1
deleteobject(600+enemy)
instanceobject(600+enemy,99+frame)
setobjectvisible(600+enemy,1)
endif
endif
if playery#>0 then playeronground=0
players#[enemy,1]=playerx#
players#[enemy,2]=playery#
players#[enemy,3]=playerz#
players#[enemy,4]=playeronground
players#[enemy,5]=gravity#
players#[enemy,6]=action
players#[enemy,7]=timedaction
players#[enemy,8]=angley#
players#[enemy,9]=movex#
players#[enemy,11]=frame
players#[enemy,12]=framecnt#
players#[enemy,13]=isjumping
if getobjectexists(600+enemy)=1
setobjectposition(600+enemy,playerx#,playery#,playerz#)
setobjectvisible(600+enemy,1)
setobjectrotation(600+enemy,0,angley#,0)
setobjectcolor(600+enemy,players#[enemy,18],players#[enemy,19],players#[enemy,20],255)
endif
endfunction
just know that it was partially cut from another project of mine to basicaly show how it can be done and not be too harsh on system resources.