home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / basic3d / exam14.dba < prev    next >
Encoding:
Text File  |  1999-12-08  |  2.5 KB  |  101 lines

  1. Rem * Title  : Simple User Animation
  2. Rem * Author : Aristides Mytaras
  3. Rem * Date   : 15th November 1999
  4. rem ===============================================
  5. rem DARK BASIC demonstration of limb rotation
  6. rem ===============================================
  7. rem A modified example #5 by Aristides Mytaras
  8. rem -----------------------------------------------
  9.  
  10. rem Load your object
  11. load object "idle.x",1
  12. scale object 1,30,30,30
  13.  
  14. rem Find out how many limbs the object has
  15. perform checklist for object limbs 1
  16. numberoflimbs=checklist quantity()
  17.  
  18. rem Set manual sync
  19. draw to front
  20. sync on
  21.  
  22. rem Start with the head limb
  23. lim=15
  24.  
  25. rem Start loop
  26. do
  27.  
  28. rem Select a limb
  29. lastlim=lim
  30. if upkey()=1
  31.     lim=lim+1 : repeat : until upkey()=0
  32. endif
  33. if downkey()=1
  34.     lim=lim-1 : repeat : until downkey()=0
  35. endif
  36. if lim<0 or lim>numberoflimbs then lim=lastlim
  37. if lim<>lastli
  38.     roy#=limb angle y(1,lim)
  39.     rox#=limb angle x(1,lim)
  40.     roz#=limb angle z(1,lim)
  41. endif
  42.  
  43. rem Rotate the selected limb
  44. if leftkey()=1 then roy#=roy#+5
  45. if rightkey()=1 then roy#=roy#-5
  46. if shiftkey()=1 then rox#=rox#+5
  47. if controlkey()=1 then rox#=rox#-5
  48. if inkey$()="," then roz#=roz#+5
  49. if inkey$()="." then roz#=roz#-5
  50.  
  51. rem Do the actual rotation
  52. roy#=wrapvalue(roy#)
  53. rox#=wrapvalue(rox#)
  54. roz#=wrapvalue(roz#)
  55. rx=curvevalue(rox#,rx,10)
  56. ry=curvevalue(roy#,ry,10)
  57. rz=curvevalue(roz#,rz,10)
  58. rotate limb 1,lim,rox#,roy#,roz#
  59.  
  60. rem Print information about object
  61. set cursor 0,0
  62. print "USE THE LEFT, RIGHT, SHIFT, CONTROL, [,] AND [.] KEYS TO ROTATE THE LIMB"
  63. print "USE THE UP AND DOWN ARROW KEYS TO SWITCH TO A NEW LIMB"
  64. print
  65. print "Limb Number:";lim
  66. print
  67. if limb exist(1, lim)=1
  68.     print "limb offset x = ";limb offset x(1, lim)
  69.     print "limb offset y = ";limb offset y(1, lim)
  70.     print "limb offset z = ";limb offset z(1, lim)
  71.     print "limb angle x = ";limb angle x(1, lim)
  72.     print "limb angle y = ";limb angle y(1, lim)
  73.     print "limb angle z = ";limb angle z(1, lim)
  74.     print "limb position x = ";limb position x(1, lim)
  75.     print "limb position y = ";limb position y(1, lim)
  76.     print "limb position z = ";limb position z(1, lim)
  77.     print "limb texture = ";limb texture(1, lim)
  78.     print "limb visible = ";limb visible(1, lim)
  79. endif
  80.  
  81. rem Display the object
  82. position object 1,0,0,0
  83.  
  84. rem Movable camera
  85. camx=curvevalue((mousex()-320)/2,camx,15)
  86. camy=curvevalue((mousey()-240)/2+30,camy,15)
  87. position camera camx,camy,-80
  88. point camera 0,30,0
  89.  
  90. rem Update scree
  91. sync
  92.  
  93. rem End loop
  94. loop
  95.  
  96. rem Delete object
  97. delete object 1
  98.  
  99. rem End the program
  100. end
  101.