example from me
rem
rem AGK Application 2017.09.25
rem MR 01.11.2017
rem Landscape App
SetWindowSize(1280,720,0)
SetDisplayAspect( 16.0/9.0 )
SetVirtualResolution(1280,720)
SetSunDirection(0,-.9,.1)
SetSunColor(255,255,255)
setcameraposition(1,0,1.80,0)
SetCameraLookAt(1,0,1.0,10,0)
SetCameraFOV(1, 80 )
SetCameraRange(1,0.1,1000.0)
Main()
End
Function Main()
ground=CreateObjectPlane(1000,1000) //XY
SetObjectLightMode(ground,1)
RotateObjectGlobalX(ground,90)
SetObjectColor(ground,100,120,50,255)
human = CreateObjectCylinder(1.8,.4,8)
SetObjectColor(human,255,192,192,255)
SetObjectLightMode(human,1)
SetObjectPosition(human,0,.6,0)
sword = CreateObjectCylinder(1,.1,8)
SetObjectColor(sword,192,192,192,255)
SetObjectLightMode(sword,1)
RandomCubes()
local a as float
rem A Wizard Did It!
do
Print("hello 3d sword , esc to exit")
RotateObjectGlobalY(human,-10.0/60.0)
HumanForward(human,1.0/60.0)
Sword(human,sword,sin(a)*60.0)
CameraBehind(human)
a = a + 45.0 / 60.0
if a > 360.0 then a = a -360.0
if GetRawKeyPressed ( 27 ) then exit
Sync()
loop
EndFunction
Function RandomCubes()
for i = 1 to 1000
o=CreateObjectBox(.5,.5,.5)
SetObjectPosition(o,Random2(-100,100),0.25,Random2(-100,100))
SetObjectLightMode(o,1)
SetObjectColor(o,Random2(20,255),Random2(20,255),Random2(20,255),255)
next
EndFunction
Function CameraBehind(human)
local x as float,y as float,z as float
x=getobjectx(human)
y=getobjecty(human)
z=getobjectz(human)
setcameraposition(1,x,y,z)
x=GetObjectAngleX(human)
y=GetObjectAngleY(human)
z=GetObjectAngleZ(human)
SetCameraRotation(1,x,y,z)
MoveCameraLocalY(1,.90) //move to head
MoveCameraLocalZ(1,-1.5) //behind
EndFunction
function HumanForward(human as integer,amount as float)
MoveObjectLocalZ(human,amount)
endfunction
Function Sword(human,sword,angle)
local x as float,y as float,z as float
x=getobjectx(human)
y=getobjecty(human)
z=getobjectz(human)
SetObjectPosition(sword,x,y,z) //same as human
x=GetObjectAngleX(human)
y=GetObjectAngleY(human)
z=GetObjectAngleZ(human)
SetObjectRotation(sword,x,y,z) //same as human
RotateObjectLocalY(sword,-20) //turn into front
MoveObjectLocalX(sword,.30) //move right
MoveObjectLocalY(sword,.9) //move up
MoveObjectLocalZ(sword,.2) //move forward
RotateObjectLocalX(sword,angle) //swing
EndFunction
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.9.3) Radeon R7 265 : Mac mini OS High Sierra (10.13)