November 28, 2020, 01:41:17 PM

Author Topic: [bb] Simpler TForm 3D Radar by _PJ_ [ 1+ years ago ]  (Read 552 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Simpler TForm 3D Radar by _PJ_ [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Simpler TForm 3D Radar
Author : _PJ_
Posted : 1+ years ago

Description : As per 'Elite' radar - thanks to Klaas, skidracer & Stevie G

Code :
Code: BlitzBasic
  1. Graphics3D 800,600,32,0
  2. SetBuffer BackBuffer()
  3.  
  4. lighting=CreateLight(2)
  5.  
  6. PositionEntity lighting,-20,20,-30
  7.  
  8. ship=CreateCone(3,1)
  9. ScaleMesh ship,2,5,1
  10. RotateMesh ship,-90,180,0
  11.  
  12. red=CreateCube()
  13. blue=CreateCube()
  14. green=CreateCube()
  15.  
  16. EntityColor red,255,0,0
  17. EntityColor green,0,255,0
  18. EntityColor blue,0,0,255
  19.  
  20. cam=CreateCamera()
  21.  
  22. MoveEntity cam,0,0,-20
  23. PointEntity cam,ship
  24.  
  25. PositionEntity red,Rand(-10,10),Rand(-10,10),Rand(-10,10)
  26. PositionEntity blue,Rand(-10,10),Rand(-10,10),Rand(-10,10)
  27. PositionEntity green,Rand(-10,10),Rand(-10,10),Rand(-10,10)
  28.  
  29. While Not KeyDown(1)
  30.  
  31. If KeyDown(208) Then TurnEntity ship,5,0,0
  32. If KeyDown(200) Then TurnEntity ship,-5,0,0
  33.  
  34. If KeyDown(203) Then TurnEntity ship,0,5,0
  35. If KeyDown(205) Then TurnEntity ship,0,-5,0
  36.  
  37. If MouseDown(1) MoveEntity ship,0,0,1
  38.  
  39. UpdateWorld
  40. RenderWorld
  41.  
  42. ;Radar
  43. Color 255,255,255
  44. Rect 400,500,3,3,0
  45.  
  46. ;Red Dot
  47. TFormPoint (EntityX(red),EntityY(red),EntityZ(red),0,ship)
  48. red_relativeX=(0-TFormedX())
  49. red_relativey=TFormedY()
  50. red_relativez=TFormedZ()
  51. Color 255,0,0
  52.  
  53. If red_relativeY>0 Then Rect 400-red_relativeX,500-red_relativeZ,1,red_relativeY,1
  54. If red_relativeY<0 Then Rect 400-red_relativeX,500-red_relativeZ+Abs(red_relativeY),1,Abs(red_relativeY),1
  55.  
  56. ;Green Dot
  57. TFormPoint (EntityX(green),EntityY(green),EntityZ(green),0,ship)
  58. green_relativeX=(0-TFormedX())
  59. green_relativey=TFormedY()
  60. green_relativez=TFormedZ()
  61. Color 0,255,0
  62.  
  63. If green_relativeY>0 Then Rect 400-green_relativeX,500-green_relativeZ,1,green_relativeY,1
  64. If green_relativeY<0 Then Rect 400-green_relativeX,500-green_relativeZ+Abs(green_relativeY),1,Abs(green_relativeY),1
  65.  
  66.  
  67. ;Blue Dot
  68. TFormPoint (EntityX(blue),EntityY(blue),EntityZ(blue),0,ship)
  69. blue_relativeX=(0-TFormedX())
  70. blue_relativey=TFormedY()
  71. blue_relativez=TFormedZ()
  72. Color 0,0,255
  73.  
  74. If blue_relativeY>0 Then Rect 400-blue_relativeX,500-blue_relativeZ,1,blue_relativeY+1,1
  75. If blue_relativeY<0 Then Rect 400-blue_relativeX,500-blue_relativeZ+Abs(blue_relativeY),1,Abs(blue_relativeY),1
  76.  
  77. Flip
  78.  
  79. Wend
  80.  
  81. End


Comments :


Rook Zimbabwe(Posted 1+ years ago)

 I was racking my pitiful brain trying to come up with a way to do this!


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal