Main.bb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ;Motion Blur
  2. ;David Bird
  3. ;[email protected]
  4. Graphics3D 640,480
  5. SetBuffer BackBuffer()
  6. lit=CreateLight()
  7. Global demo=True
  8. Global ax#,ay#,az#
  9. cam=CreateCamera()
  10. CameraRange cam,1,10000
  11. CameraClsColor cam,50,50,255
  12. PositionEntity cam,0,1,3
  13. Global jet=LoadMesh("jet.x")
  14. RotateMesh jet,0,90,0
  15. HideEntity jet ; load and hide jet entity
  16. ply.obj=Create_Player()
  17. While Not KeyDown(1)
  18. PointEntity cam,ply\piv
  19. Add_Effect(ply\ent)
  20. Update_Players()
  21. Update_Effects()
  22. UpdateWorld
  23. RenderWorld
  24. dx#=(EntityX(ply\piv,True)-EntityX(cam))*.1
  25. dy#=((EntityY(ply\piv,True)+15)-EntityY(cam))*.1
  26. dz#=((EntityZ(ply\piv,True)-50)-EntityZ(cam))*.1
  27. TranslateEntity cam,dx,dy,dz
  28. Flip
  29. Wend
  30. FreeEntity cam
  31. EndGraphics
  32. End
  33. Type Obj
  34. Field piv
  35. Field ent
  36. Field thrust#
  37. Field rudpitch#
  38. Field rudroll#
  39. End Type
  40. Function Create_Player.obj()
  41. a.obj=New obj
  42. a\piv=CreatePivot()
  43. a\ent=CopyEntity(jet,a\piv)
  44. Return a
  45. End Function
  46. Function Update_Players()
  47. For a.obj=Each obj
  48. Get_Rudder(a)
  49. TurnEntity a\piv,1*a\rudpitch,0,2*a\rudroll
  50. MoveEntity a\piv,0,0,-1*a\thrust
  51. Next
  52. End Function
  53. Function Get_Rudder(a.obj)
  54. If demo=True Then
  55. a\thrust=-.47
  56. ax=ax-.01
  57. If ax<.1 Then ax=Rnd(4)
  58. az=az-.01
  59. If az<.1 Then az=Rnd(4)
  60. a\rudpitch=ax
  61. a\rudroll=az
  62. Else
  63. a\rudpitch=-JoyY()
  64. a\rudroll=-JoyX()
  65. a\thrust=JoyZ()
  66. End If
  67. End Function
  68. Type eff
  69. Field ent
  70. Field alpha#
  71. End Type
  72. Function Add_effect(ent)
  73. a.eff=New eff
  74. a\ent=CopyEntity(ent)
  75. EntityParent a\ent,0
  76. a\alpha=.5
  77. EntityAlpha a\ent,a\alpha
  78. PositionEntity a\ent,EntityX(ent,True),EntityY(ent,True),EntityZ(ent,True)
  79. RotateEntity a\ent,EntityPitch(ent,True),EntityYaw(ent,True),EntityRoll(ent,True)
  80. ScaleEntity a\ent,.95,.95,.95
  81. End Function
  82. Function Update_effects()
  83. For a.eff=Each eff
  84. If a\alpha>0 Then
  85. a\alpha=a\alpha-.02
  86. EntityAlpha a\ent,a\alpha
  87. Else
  88. FreeEntity a\ent
  89. Delete a
  90. End If
  91. Next
  92. End Function