Advertisement
Guest User

Untitled

a guest
Nov 18th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1.  
  2. Import mojo
  3.  
  4. Const SCREEN_WIDTH = 640
  5. Const SCREEN_HEIGHT = 480
  6.  
  7. Class Color
  8. Public Field r,g,b
  9. Method New()
  10. End
  11.  
  12. Method New(r,g,b)
  13. Self.r = r
  14. Self.g = g
  15. Self.b = b
  16. End
  17. End
  18.  
  19. Class Plasma Extends App
  20. Field colors:Color[256]
  21. Field asin:Int[512]
  22. Field pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0, tpos1, tpos2, tpos3, tpos4
  23. Field x,index
  24.  
  25. Method OnCreate()
  26. For Local i=0 Until 512
  27. Local rad:Float = (i * 0.703125) * 0.0174532
  28. asin[i] = Sinr(rad) * 1024
  29. End
  30.  
  31. For Local i=0 Until 64
  32. colors[i] = New Color
  33. colors[i].r = i Shl 2;
  34. colors[i].g = 255 - ((i Shl 2) + 1);
  35. colors[i+64] = New Color
  36. colors[i+64].r = 255;
  37. colors[i+64].g = (i Shl 2) + 1;
  38. colors[i+128] = New Color
  39. colors[i+128].r = 255 - ((i Shl 2) + 1);
  40. colors[i+128].g = 255 - ((i Shl 2) + 1);
  41. colors[i+192] = New Color
  42. colors[i+192].g = (i Shl 2) + 1;
  43. End
  44. SetUpdateRate 60
  45. End
  46.  
  47. Method OnRender()
  48.  
  49. 'Cls 0,0,0
  50.  
  51. tpos4 = pos4
  52. tpos3 = pos3
  53.  
  54. For Local i=0 Until SCREEN_HEIGHT
  55. tpos1 = pos1 + 5
  56. tpos2 = pos2 + 3
  57.  
  58. tpos3 = tpos3 & 511
  59. tpos4 = tpos3 & 511
  60.  
  61. For Local j=0 Until SCREEN_WIDTH
  62. tpos1 = tpos1 & 511
  63. tpos2 = tpos2 & 511
  64.  
  65. x = asin[tpos1] + asin[tpos2] + asin[tpos3] + asin[tpos4]
  66. index = 128 + (x Shr 4)
  67.  
  68. ' index is 8 bit, so need to overflow
  69. If index > 255 Then
  70. index = index - 255
  71. Else If index < 0 Then
  72. index = 255 + index
  73. End
  74.  
  75. SetColor colors[index].r, colors[index].g, colors[index].b
  76. DrawLine j, i, j+1, i+1
  77.  
  78. tpos1 = tpos1 + 5
  79. tpos2 = tpos2 + 3
  80. End
  81. tpos4 = tpos4 + 3
  82. tpos3 = tpos3 + 1
  83. End
  84.  
  85. pos1 = pos1 + 9
  86. pos3 = pos3 + 8
  87. End
  88.  
  89. End
  90.  
  91. Function Main()
  92. New Plasma
  93. End
  94.  
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement