Sorceress

wibble

Sep 13th, 2020
184
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'DGC Code Pong : Untitled Elite-like
  2. 'ver 0000 : 2020-09-13
  3.  
  4. '--- Definitions ------------------------------------------
  5. CONST kPi = 3.14159265
  6. CONST kPi2 = 6.28318531
  7. CONST kDiv3 = 0.333333333
  8. CONST kRoot2 = 1.414213562
  9. CONST kDivRoot2 = 0.7071067812
  10.  
  11. TYPE tVec3
  12. x AS SINGLE
  13. y AS SINGLE
  14. z AS SINGLE
  15. END TYPE
  16.  
  17. TYPE tStar
  18. p AS tVec3 'position
  19. c AS INTEGER
  20. END TYPE
  21. DIM star(1000) AS tStar
  22. DIM stars AS LONG
  23.  
  24. '--- Main -------------------------------------------------
  25. SCREEN 13: cX = 160: cY = 100 'screen centres
  26. stars = 1000: GOSUB GenGalaxy
  27. DO
  28. a1 = a1 + 0.01
  29. a2 = COS(a1 / 3) ^ 2
  30. CLS
  31. FOR i = 1 TO stars
  32. pX = star(i).p.x
  33. pY = star(i).p.y
  34. pZ = star(i).p.z
  35.  
  36. pX1 = pX * COS(a1) - pY * SIN(a1)
  37. pY = pX * SIN(a1) + pY * COS(a1)
  38. pX = pX1
  39.  
  40. pZ1 = pZ * COS(a2) - pY * SIN(a2)
  41. pY = pZ * SIN(a2) + pY * COS(a2)
  42. pZ = pZ1
  43.  
  44. CIRCLE (cX + pX, cY + pZ), 2, star(i).c
  45. NEXT
  46.  
  47. page = 1 - page
  48. SCREEN 13, , page, 1 - page
  49.  
  50. LOOP
  51. SLEEP
  52. SYSTEM
  53.  
  54. '--- Subs -------------------------------------------------
  55. GenGalaxy:
  56. RANDOMIZE TIMER
  57. r = 100 'Galactic Radius
  58. FOR i = 1 TO stars
  59. a = (RND + RND) / 2
  60. b = kPi2 * RND: b = b + SIN(2 * b) - 6 * a
  61. c = (RND - RND) / (4 + 30 * a * a)
  62.  
  63. star(i).p.x = r * a * COS(b)
  64. star(i).p.y = r * a * SIN(b)
  65. star(i).p.z = r * c
  66. SELECT CASE INT(RND * 100)
  67. CASE 0: star(i).c = 11 'blue giant
  68. CASE 1 TO 2: star(i).c = 15 'white
  69. CASE 3 TO 12: star(i).c = 14 'yellow
  70. CASE 13 TO 82: star(i).c = 4 'red dwarf
  71. CASE 83 TO 92: star(i).c = 6 'brown dwarf
  72. CASE 93: star(i).c = 12 'red giant
  73. CASE 95 TO 98: star(i).c = 7 'white dwarf
  74. CASE 99: star(i).c = 8 'compact object
  75. END SELECT
  76. NEXT
  77. RETURN
  78.  
  79.  
  80.  
RAW Paste Data