Ooops
November 28, 2020, 10:50:34 AM

Author Topic: [bb] Pointy Rockets by Blitzplotter [ 1+ years ago ]  (Read 534 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Pointy Rockets by Blitzplotter [ 1+ years ago ]
« on: June 29, 2017, 12:28:39 AM »
Title : Pointy Rockets
Author : Blitzplotter
Posted : 1+ years ago

Description : Plots 4 rockets and rotates them to point to the next one (needs the rocket.3ds)

Code :
Code: BlitzBasic
  1. ; Movement & Rotation ***
  2. ; By Paul Gerfen (www.gamecoding.co.uk)
  3.  
  4. ; added to slightly by Blitzplotter
  5.  
  6.  
  7.  
  8. Global quadrant=9
  9.  
  10.  
  11. Graphics3D 800,600
  12.  
  13. SetBuffer BackBuffer()
  14.  
  15. camera=CreateCamera()
  16. CameraViewport camera,0,0,800,600
  17.  
  18. light=CreateLight()
  19.  
  20. rocket=LoadMesh( "rocket.3ds" )
  21. PositionEntity rocket,0,0,37
  22.  
  23.  
  24. r1_quad=return_angle(1,1,3,3)
  25. r2_quad=return_angle(0,0,3,-3)
  26. r3_quad=return_angle(0,0,-3,-3)
  27. r4_quad=return_angle(0,0,-3,3)
  28.  
  29.  
  30. Print r1_quad
  31.  
  32. Print r2_quad
  33.  
  34. Print r3_quad
  35.  
  36. Print r4_quad
  37.  
  38.  
  39. ;give rockets positions E,S,W & N (ish) co-ordinates respectively
  40.  
  41. x1=-28
  42.  y1=18
  43.  
  44. x2=8
  45.  y2=8
  46.  
  47. x3=18
  48.  y3=-8
  49.  
  50. x4=-18
  51.  y4=-18
  52.  
  53.  
  54.  
  55. rocket1=LoadMesh( "rocket.3ds" )
  56. PositionEntity rocket1,x1,y1,47
  57.  
  58. rocket2=LoadMesh( "rocket.3ds" )
  59. PositionEntity rocket2,x2,y2,47
  60.  
  61. rocket3=LoadMesh( "rocket.3ds" )
  62. PositionEntity rocket3,x3,y3,47
  63.  
  64. rocket4=LoadMesh( "rocket.3ds" )
  65. PositionEntity rocket4,x4,y4,47
  66.  
  67.  
  68. r1_angle=return_angle(x1,y1,x2,y2)
  69.  
  70. r2_angle=return_angle(x2,y2,x3,y3)
  71.  
  72. r3_angle=return_angle(x3,y3,x4,y4)
  73.  
  74. r4_angle=return_angle(x4,y4,x1,y1)
  75.  
  76. Print " "
  77. Print "Thats a slice of debug... Press Any Key"
  78.  
  79. WaitKey
  80.  
  81.  
  82.  
  83. RotateEntity rocket1,0,0,-r1_angle
  84.  
  85. RotateEntity rocket2,0,0,-r2_angle
  86.  
  87. RotateEntity rocket3,0,0,-r3_angle
  88.  
  89. RotateEntity rocket4,0,0,-r4_angle
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96. While Not KeyHit(1)
  97.  
  98.        
  99.         If KeyDown(200) Then
  100.                 MoveEntity rocket,0,0.05,0
  101.         EndIf
  102.        
  103.         If KeyDown(203) Then
  104.                 TurnEntity rocket,0,0,1.0
  105.         EndIf
  106.        
  107.         If KeyDown(205) Then
  108.                 TurnEntity rocket,0,0,-1.0
  109.         EndIf
  110.        
  111.         UpdateWorld
  112.         RenderWorld
  113.        
  114.         Text 320,500,"One rocket - Movement & Rotation"
  115.        
  116.         Text 270,522,"With four other rockets that'll point to each other"
  117.        
  118.         Flip
  119.  
  120. Wend
  121. End
  122.  
  123.  
  124.  
  125. Function return_angle(x1,y1,x2,y2)
  126.  
  127. quadrant=5
  128.  
  129. ;first establish which quadrant 2nd co-ords are in with respect to first co-ords
  130.  
  131. If x1<x2
  132.  
  133.         If y1<y2
  134.                 quadrant=1
  135.         Else
  136.                 quadrant=2
  137.         EndIf
  138.        
  139. Else
  140.  
  141.         If y1>y2
  142.                 quadrant=3
  143.         Else
  144.                 quadrant=4
  145.         EndIf
  146.  
  147. EndIf
  148.  
  149. Select(quadrant)
  150.  
  151. Case 1
  152.         Print "1-1"
  153.         Print" x1:"+x1+" y1:"+y1+" x2: "+x2+" y2: "+y2
  154.         angle#= Float ATan2(y2-y1,x2-x1)
  155.         ;1st quadrant fixer:
  156.         angle2#= 0+(90-angle)
  157.        
  158.        
  159. Case 2
  160.         Print "2-2"
  161.         Print" x1:"+x1+" y1:"+y1+" x2: "+x2+" y2: "+y2
  162.         angle#= (Float (ATan2(y2-y1,x2-x1)))+180
  163.         ;2nd quadrant fixer:
  164.         angle2# = 90+(180-angle)
  165.        
  166.        
  167. Case 3
  168.         Print "3-3"
  169.         Print" x1:"+x1+" y1:"+y1+" x2: "+x2+" y2: "+y2
  170.         angle#= (Float (ATan2(y2-y1,x2-x1)))+360
  171.         ;3rd quadrantfixer:
  172.         angle2#=180+(270-angle)
  173.        
  174.        
  175.        
  176. Case 4
  177.         Print "4-4"
  178.         Print" x1:"+x1+" y1:"+y1+" x2: "+x2+" y2: "+y2
  179.         angle#= (Float (ATan2(y2-y1,x2-x1)))+180
  180.         ;4th quadrant fixer
  181.         angle2#=270+(360-angle)
  182.        
  183.        
  184. End Select
  185.  
  186.  
  187. Return(angle2)
  188.  
  189.  
  190.  
  191. End Function


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal