Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. add = func(a, b) {
  2. return a + b
  3. }
  4.  
  5. entity = class {
  6. _init_ = func {
  7.  
  8. }
  9. }
  10.  
  11. player = class : entity {
  12. _init_ = func {
  13.  
  14. }
  15. }
  16.  
  17. vec3 = class {
  18. _init_ = func (a, b, c) {
  19. declare(x=a, y=b, z=c)
  20. declare(r=a, g=b, b=b)
  21. }
  22.  
  23. _toArgs_ = func {
  24. return x, y, z
  25. }
  26.  
  27. _add_ = func(o) {
  28. return vec3(x + o.x, y + o.y, z + o.z)
  29. }
  30. }
  31.  
  32. setWin(640, 480, black)
  33.  
  34. _drawFunc_ = func {
  35. drawRect(0, 0, 10, 10, rgb(0, 255, 255))
  36. drawCube(vec3(0, 0, 0), 10, 10, 10, 255, 0, 255)
  37. }
  38.  
  39. _pixel_ = shader(coord, res) {
  40. return rgb(coord/res)
  41. }
  42.  
  43. //----------------------------------------------------------------
  44. //game of life, without the Ceullar Automata lib
  45.  
  46. setWin(1000, 1000, black)
  47.  
  48. import shapes
  49. import arrays
  50. import colors
  51.  
  52. pixels = [100][100]
  53.  
  54. for(pix:pixels[](x, y)) {
  55. pix = randBool()
  56. }
  57.  
  58. _update_ = func {
  59. pixels0 = [[]]
  60. for(pix:pixels[](x, y)) {
  61. count = arrProc(pixels, vec2(x, y)).countNear(square(1, 1), func (i) {return i == true})
  62. if(count == 3 && pix == false)
  63. pixels0[x][y] = true
  64. else if(inRange(count, 2, 3) && pix == true)
  65. pixels0[x][y] = true
  66. }
  67. pixels = pixels0
  68. }
  69.  
  70.  
  71. _draw_ = func {
  72. for(pix:pixels[](x, y)) {
  73. drawSquare(x, y, 10, 10, white)
  74. }
  75. }
  76.  
  77. //wireworld with the cellular automata lib
  78. import calib
  79.  
  80. initCA(100, 100)
  81.  
  82. _castates_ = castates {
  83. HEAD
  84. TAIL
  85. EMPTY
  86. WIRE
  87. }
  88.  
  89. _carules_ = carules {
  90. HEAD -> TAIL
  91. TAIL -> WIRE
  92. WIRE -> HEAD if HEAD in range(1, 2)
  93. }
  94.  
  95. //simple voxel game using the voxel engine
  96.  
  97. import voxels
  98.  
  99. setVoxelResPow(6)
  100. setRenderer(VCT)
  101.  
  102. setVoxels(COLOR, EMPTY)
  103.  
  104. _genVoxWorld_ = voxgen {
  105. pass0:
  106. !vox.color = genNoiseHeight()
  107. pass1:
  108. vox.color = isSurface()
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement