Hi there . I have converted my robot Dbpro code to Agk ...I have to say I prefer the Dpbro one .
My Robot
// Project: robot
// Created: 2019-01-20
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "robot 2" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
gr=makecolor(80,80,80)
drawbox(0,0,50,50,gr,gr,gr,gr,1)
getimage(100,0,0,100,100)
drawbox(0,0,128,128,gr,gr,gr,gr,1)
gr2=makecolor(100,100,100)
for i= 1 to 128 step 5
drawbox(0,i*2,128,3+i*2,gr2,gr2,gr2,gr2,1)
next
getimage(1,0,0,128,128)
`leg
createobjectbox(1,10,4,10)
setobjectposition(1,0,-2,-5)
fixobjectpivot(1)
createobjectcylinder(2,50,6,20)
CreateMemblockFromObjectMesh(1,1,1)
CreateMemblockFromObjectMesh(2,2,1)
deleteobject(2)
addlimb(1,2,2,0,-26,-6) `obj,mesh,limb,x,y,z
addlimb(1,1,3,0,-50,0)
deletememblock(2)
createobjectbox(2,2,50,2)
CreateMemblockFromObjectMesh(2,2,1)
deleteobject(2)
addlimb(1,2,4,-3.7,-26,-1)
addlimb(1,2,5,7.2,0,0)
deletememblock(2)
createobjectsphere(2,13,18,18)
CreateMemblockFromObjectMesh(2,2,1)
deleteobject(2)
addlimb(1,2,6,0,-55,-4)
setobjectimage(1,1,0)
y=makecolor(100,90,30)
drawbox(0,0,2,2,y,y,y,y,1)
getimage(2,0,0,1,1)
setobjectmeshimage(1,6,2,0)
`--------
cloneobject(2,1)
setobjectposition(2,20,0,0)
cloneobject(3,1)
FixObjectToObject(3,1)
setobjectposition(3,0,-53,0)
cloneobject(4,1)
fixobjecttoobject(4,2)
setobjectposition(4,0,-53,0)
`waist
createobjectbox(5,40,15,15)
setobjectimage(5,1,0)
`fixing legs to waist
FixObjectToObject(1,5)
fixobjecttoobject(2,5)
setobjectposition(1,-13,0,5)
setobjectposition(2,13,0,5)
`main body
CreateObjectSphere(6,120,18,12)
setobjectimage(6,1,0)
conic(6,0.6)
setobjectscale(6,1,0.3,1)
fixobjectpivot(6)
FixObjectToObject(6,5)
setobjectposition(6,0,20,0)
`floor
createobjectbox(50,10000,10,100)
CreateMemblockFromObjectMesh(50,50,1)
for i= 1 to 100
addlimb(50,50,i,0,0,105)
next
setobjectposition(50,0,-110,-3000)
fixobjectpivot(50)
setobjectimage(50,1,0)
`machine gun
ob=10
for i= 1 to 10
createobjectbox( ob,2,2,80)
setobjectrotation(ob,0,0,36*i)
MoveObjectLocalx(ob,4)
fixobjecttoobject(ob,6)
setobjectposition(ob,getobjectx(ob)-25,getobjecty(ob)-20,getobjectz(ob)+20)
setobjectcolor(ob,90,90,90,0)
cloneobject(ob+10,ob)
FixObjectToObject(ob+10,6)
setobjectposition(ob+10,getobjectx(ob+10)+50,getobjecty(ob+10),getobjectz(ob+10))
inc ob
next
gr=makecolor(100,100,100)
drawbox(0,0,50,50,gr,gr,gr,gr,1)
getimage(50,0,0,100,100)
`feets
createobjectbox(40,14,4,25)
setobjectposition(40,0,0,-10)
fixobjectpivot(40)
FixObjectToObject(40,3)
setobjectposition(40,0,-60,0)
setobjectimage(40,1,0)
createobjectbox(41,14,4,25)
setobjectposition(41,0,0,-10)
fixobjectpivot(41)
FixObjectToObject(41,4)
setobjectposition(41,0,-60,0)
setobjectimage(41,1,0)
`balls
createobjectsphere(150,10,12,12)
setobjectposition(150,0,0,-20)
setobjectscale(150,1,1.5,1)
setobjectposition(150,0,-5,0)
FixObjectToObject(150,6)
setobjectposition(150,-3,-20,-25)
cloneobject(151,150)
fixobjecttoobject(151,6)
setobjectposition(151,3,-20,-25)
setobjectrotation(150,0,0,-15)
setobjectrotation(151,0,0,15)
setobjectimage(150,1,0)
setobjectimage(151,1,0)
`radar
createobjectsphere(300,20,18,18)
setobjectimage(300,100,0)
setobjectposition(300,0,38,0)
SetObjectTransparency(300,1)
fixobjectpivot(300)
cloneobject(301,300)
SetObjectCullMode(301,0)
fixobjecttoobject(301,300)
createobjectsphere(302,10,18,18)
setobjectposition(302,-2,42,0)
setobjectscale(302,0.7,0.6,1)
fixobjectpivot(302)
fixobjecttoobject(302,300)
SetObjectColorEmissive(302,0,255,0)
FixObjectToObject(300,6)
setobjectposition(300,0,-20,0)
`sky
createobjectsphere(1500,3000,12,12)
SetObjectCullMode(1500,0)
setobjectcolor(1500,200,70,40,0)
setcamerarange(1,0.1,1000000)
SetRawMousePosition(500,400)
setcameraposition(1,-172,56,220)
SetCameraLookAt(1,0,0,0,0)
mv#=0
createpointlight(2,0,-30,300,1300,255,255,0)
SetSunActive(1)
SetAmbientColor(0,0,0)
do
g=g+10
setobjectrotation(300,0,g,0)
`animation
if b=1 then a#=a#+2
if a#=40 then b=2
if b=2 then a#=a#-2
if a#=0 then b=1
`waist
setobjectrotation(5,0,0,-5+(a#/4))
`foots and knees
setobjectrotation(1,a#+10,0,-ang#*2)
setobjectrotation(2,39-a#+10,0,-ang#*2)
setobjectrotation(3,-110+(a#*2),-10,0)
setobjectrotation(4,-30-(a#*2),10,0)
ang#=GetObjectAngleZ(5)
setobjectrotation(6,0,-5+(a#/2),0)
fty#=getobjectworldy(40)
rty#=getobjectworldy(41)
setobjectrotation(40,45+fty#*2,0,0)
setobjectrotation(41,45+rty#*2,0,0)
if fty#<-50 then MoveObjectLocalZ(50,-4)
if rty#<-50 then MoveObjectLocalZ(50,-4)
if getobjectz(50)<-2000 then setobjectposition(50,0,-110,-1000)
`balls ;) :D
setobjectrotation(151,0,a#/3,a#/3)
setobjectrotation(150,0,-a#/3,-a#/3)
`CAMERA
movecameralocalz(1,(GetRawKeyState( 38 )*5)-GetRawKeyState( 40 )*5)
movecameralocalx(1,(GetRawKeyState( 39 )*5)-GetRawKeyState( 37 )*5)
setcamerarotation(1,getpointery(),-80+getpointerx(),0)
if GetRawKeyState( 27) then end `salimos con tecla escape ( 32 para Spacekey)
SetCameraLookAt(1,0,0,0,0)
Sync()
loop
function addlimb(obj,malla,limb,xx#,yy#,zz#)
AddObjectMeshFromMemblock(obj,malla)
verts= GetMemblockInt( malla, 0 )
for i= 0 to verts-1
x#=GetMeshMemblockVertexX(malla,i)
y#=GetMeshMemblockVertexy(malla,i)
z#=GetMeshMemblockVertexz(malla,i)
SetMeshMemblockVertexPosition(malla,i, x#+xx#,y#+yy#,z#+zz#)
u#=GetMeshMemblockVertexU(malla,i)
v#=GetMeshMemblockVertexV(malla,i)
next i
`fixing mesh
SetObjectMeshFromMemblock(obj,limb,malla)
endfunction
function conic(obj,zz#)
`making a mesh from object
mesh = CreateMemblockFromObjectMesh(obj,1)
//getting vertex quantity
verts= GetMemblockInt( mesh, 0 )
for i= 0 to verts-1
x#=GetMeshMemblockVertexX(mesh,i)
y#=GetMeshMemblockVertexy(mesh,i)
z#=GetMeshMemblockVertexz(mesh,i)
if y#>1 then SetMeshMemblockVertexPosition(mesh,i, x#*zz#,y#,z#*zz#)
next i
//fixing mesh
SetObjectMeshFromMemblock(obj,1,mesh)
endfunction
Here's the Dbpro code if you want to test .
autocam off
sync on
rem robot texture
ink rgb(20,20,20),1
box 0,0,50,50
ink rgb(60,60,60),1
box 10,10,40,40
get image 1,0,0,50,50
ink rgb(90,90,90),1
box 0,0,50,50
ink rgb(70,70,70),1
box 5,5,45,45
get image 2,0,0,50,50
rem =================================================
rem NUMBER TEXTURE
cls
ink rgb(2,2,2),1
for i= 1 to 120
ellipse 10+i,30,2,12
next i
ink rgb(255,255,255),1
for i= 1 to 115
ellipse 12+i,30,2,10
next i
ink rgb(5,5,5),0
set cursor 15,24
print " L Z H A 120 "
get image 10,8,19,132,45,1
rem suelo
make object box 500,2200,1,2200
position object 500,0,-100,0
texture object 500,2:scale object texture 500,30,30
rem -------------------------------------------------
rem CREATING DIFFERENTS PARTS
make object box 2, 11,50,11
make object box 3, 15,35,15
position object 3,0,0,5
make object box 4,7,40,11
perform csg difference 2,3
perform csg difference 2,4
delete object 3
delete object 4
make object cylinder 3,8
scale object 3,100,550,100
scale limb texture 3,0,1,5
offset limb 3,0,0,-4,0
make mesh from object 10,3
add limb 2,1,10
delete object 3
delete mesh 10
offset limb 2,0,0,-25,5
offset limb 2,1,0,0,5
make mesh from object 1,2 rem mesh for legs
delete object 2
make object box 2,15,5,25 rem foot
make object box 3,25,8,55
position object 3,-18,0,15
yrotate object 3,8
perform csg difference 2,3
yrotate object 3,-8
position object 3,18,0,15
perform csg difference 2,3
delete object 3
offset limb 2,0,0,-5,-9
delete object 3
make mesh from object 2,2
make object sphere 3,10
scale object texture 3,20,20
make mesh from object 10,3 rem mesh for leg`s balls
delete object 3
delete object 2
rem --------------------------------------------
make object 2,2,1 :scale object texture 2,2,2 rem right leg
make object 3,2,1 :scale object texture 3,2,2 rem left leg
make object sphere 4,15 rem right leg ball
make object sphere 5,15 rem left leg ball
color object 4,rgb(70,40,0)
color object 5,rgb(70,40,0)
rem -------------------------------------------------------------
rem guns
for i= 1 to 12
make object box 100+i,1,1,35
zrotate object 100+i,i*30
offset limb 100+i,0,2.3,0,0
make mesh from object 100+i,100+i
delete object 100+i
next i
make object 21,101,1
for i= 2 to 12
add limb 21,i-1,100+i
delete mesh 100+i
next i
scale object 21,200,200,200
scale object texture 21,2,1
make mesh from object 30,21
delete object 21
rem ------------------------------------------------------------
make object box 1,40,14,14
rem right leg
add limb 1,1,1 :link limb 1,0,1:offset limb 1,1,-14,0,-5
add limb 1,2,1:link limb 1,1,2:offset limb 1,2,0,-50,0
add limb 1,3,10:link limb 1,2,3:offset limb 1,3,0,-50,5
rem left leg
add limb 1,4,1:link limb 1,0,4:offset limb 1,4,14,0,-5
add limb 1,5,1:link limb 1,4,5:offset limb 1,5,0,-50,0
add limb 1,6,10:link limb 1,5,6:offset limb 1,6,0,-50,5
rem body --------------------------------------------
make object sphere 10,100
lock vertexdata for limb 10,0
for i = 1 to 25
x# = get vertexdata position x(i)
y# = get vertexdata position y(i)
z# = get vertexdata position z(i)
set vertexdata position i,x#,y#+25,z#
next i
unlock vertexdata
rem set object normals 10
scale object 10,100,50,100
scale limb texture 10,0,5,5
offset limb 10,0,0,0,-20
make mesh from object 10,10
delete object 10
rem NUMBER --------------------------------------------
make object box 50,30,10,0
offset limb 50,0,0,0,-8
texture object 50,10
set object 50,1,1,1,1
position object 50,0,-10,-30
rem -----------------------------------------------------
add limb 1,7,10: link limb 1,0,7 rem body (big sphere)
add limb 1,8,30:link limb 1,7,8:offset limb 1,8,-25,-25,-40 rem gun
add limb 1,9,30:link limb 1,7,9:offset limb 1,9,25,-25,-40 rem gun
texture object 1,1
scale object texture 1,2,1
rem -----------------------------------------------------------------
position camera -99,15,-147
point camera 0,0,0
cam#=45
rem this part of code is not mine ...someone on TGC Forum
Make Memblock 1, 1000
` Make the header for the sound inside the memblock
write memblock dword 1, 0, 1 ` wFormatTag
write memblock dword 1, 4, 1 ` nChannels
write memblock dword 1, 8, 22050 ` nSamplesPerSec
write memblock dword 1, 12, 44100 ` nAvgBytesPerSec
write memblock dword 1, 16, 2 ` nBlockAlign
write memblock dword 1, 20, 16 ` wBitsPerSample
write memblock dword 1, 24, 0 ` cbSize
` write crazy random data to memblock
for i = 28 to 999
Write Memblock Byte 1, i, rnd( 255 )
next
` Convert the memblock to a sound
Make Sound From Memblock 1, 1
make sound from memblock 2,1
rem --------------------------------------------------------------------------
do
position object 50,object position x(1),-10,object position z(1)
rotate object 50,limb angle x(1,0)*1.5,limb angle y(1,0)*1.5,limb angle z(1,0)*1.1
rem scroll del suelo
scll#=0.0031
scroll object texture 500,0,scll#
rem -----------------------------------------------------------------------------
rem positioning copper ball on knees and feet
position object 2,limb position x(1,3),limb position y(1,3),limb position z(1,3)
position object 3,limb position x(1,6),limb position y(1,6),limb position z(1,6)
position object 4,limb position x(1,2),limb position y(1,2),limb position z(1,2)+5
position object 5,limb position x(1,5),limb position y(1,5),limb position z(1,5)+5
`---------------------------------------------------------
`Animation
al#=al#+1 rem timer to make body go up and down (limb 7)
if al#>300 then al#=0
if al#<150 then ss#=ss#+0.6
if al#>150 then ss#=ss#-0.6
offset limb 1,7,0,20+ss#/30,0
`---------------------------------------------------------
m=m+1 rem timer for animation
if m<300 then g#=g#+0.6
if m>300 then g#=g#-0.6
if m>599 then m=0
if g#<0 then g#=0 rem stop
rem sound effects ++++++++++++++++++++++++++++++++
set sound speed 1,1000
if m<5 then play sound 1
if m>300 and m<305 then play sound 1
loop sound 2
set sound speed 2,10000+ss#*20:set sound volume 2,90
rem ++++++++++++++++++++++++++++++++++++++++++++++++
if m>150 and m<300 then g2#=g2#+0.5
if m<150 then g2#=g2#-0.5
if m=0 then g2#=0:g3#=0
if m>450 then g3#=g3#+0.5
if m>300 and m<450 then g3#=g3#-0.5
rem ---------------------------------------------------------
vl#=-15+g#/6
vl2#=g2#/2
vl3#=g3#/2
rotate limb 1,1,-30+vl#*1.5,10,0+2-vl#/2.5-5-vl#/10 rem right leg
rotate limb 1,4,-30-vl#*1.5,-10,-2-vl#/2.5+5-vl#/10 rem left leg
rotate limb 1,2,50-vl2#*2,0,10 rem right knee
rotate limb 1,5,50-vl3#*2,0,-10 rem left knee
rotate limb 1,0,0,0,(g#-100)/10 rem waist limb 0
rotate limb 1,7,ss#/10,-5+g#/10,0 rem twist (limb 7)
rem ajusting feet rotation with feet height
u#=object position y(2)
u2#=object position y(3)
xrotate object 2,-u#*0.6-55 rem right foot
xrotate object 3,-u2#*0.6-55 rem left foot
rem camera controls
control camera using arrowkeys 0,0.4,0.4
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
sync
loop
I'm not a grumpy grandpa