t10dimensional

life

Jun 9th, 2014
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. Rem Project: life
  2. Rem Created: Sunday, June 08, 2014
  3.  
  4. Rem ***** Main Source File *****
  5. Rem Project: memblocks
  6. Rem Created: Sunday, January 02, 2011
  7.  
  8. Rem ***** Main Source File *****
  9.  
  10.  
  11. ` ~SETUP~
  12.  
  13.  
  14. set window off
  15. set display mode 1024,768,32
  16. `maximize window
  17. sync on:sync rate 0
  18. set text font "Times New Roman",1
  19. set text size 20
  20. randomize timer()
  21. ink rgb(255,255,255),0
  22.  
  23. ` Varibles
  24. #constant true=1
  25. #constant false=0
  26. grid_width=110
  27. grid_height=110
  28. max_width=5000
  29. max_height=5000
  30. screen_width=screen width()
  31. screen_height=screen height()
  32. cell_width=screen_width/grid_width
  33. cell_height=screen_height/grid_height
  34. mouse_cell_x=0
  35. mouse_cell_y=0
  36. mx=0
  37. my=0
  38. old_mouse_cell_x=0
  39. old_mouse_cell_y=0
  40. clicked=0
  41. entered=0
  42. enterpressed=0
  43. sisters=0
  44.  
  45. dim time(10)
  46. dim oldtime(10)
  47.  
  48. type cellstuff
  49. main
  50. mark
  51. new
  52. endtype
  53.  
  54. dim cell(max_width, max_height) as cellstuff
  55.  
  56. ` Images
  57. ink rgb(255,255,255), 0
  58. box 1, 1, cell_width, cell_height
  59. get image 1, 0, 0, cell_width, cell_height
  60.  
  61. sync:cls
  62.  
  63. ink rgb(0,192,255), 0
  64. box 1, 1, cell_width, cell_height
  65. ink 0, 0
  66. box 2, 2, cell_width-1, cell_height-1
  67. get image 2 ,0, 0, cell_width, cell_height
  68.  
  69. sync:cls
  70.  
  71. ink rgb(165,165,165), 0
  72.  
  73. for x=0 to grid_width+1
  74. line x*cell_width, 0, x*cell_width, grid_height*cell_height
  75. next x
  76.  
  77. for y=0 to grid_height+1
  78. line 0, y*cell_height, grid_width*cell_width, y*cell_height
  79. next y
  80.  
  81. get image 3 ,0, 0, grid_width*cell_width+1, grid_height*cell_height+1
  82. sync
  83.  
  84. sync:cls
  85.  
  86. ` ~MAIN~
  87.  
  88.  
  89. DO
  90.  
  91.  
  92. SELECT Game_State
  93.  
  94. `<>
  95. Case 0
  96. gosub main
  97. gosub images
  98. gosub new_state
  99. Endcase
  100.  
  101. ENDSELECT
  102.  
  103.  
  104. sync:cls
  105. LOOP
  106.  
  107. ` ~SUB~
  108.  
  109.  
  110. `<><><><> 1
  111. main:
  112. mx=mousex()
  113. my=mousey()
  114.  
  115. old_mouse_cell_x=mouse_cell_x
  116. old_mouse_cell_y=mouse_cell_y
  117. mouse_cell_x=mx/cell_width
  118. mouse_cell_y=my/cell_height
  119.  
  120. if mouse_cell_x<>old_mouse_cell_x
  121. clicked=0
  122. endif
  123.  
  124. if mouse_cell_y<>old_mouse_cell_y
  125. clicked=0
  126. endif
  127.  
  128. if mouseclick()=0
  129. clicked=0
  130. endif
  131.  
  132. if mouseclick()=1
  133. if clicked=0
  134. clicked=1
  135. cell(mouse_cell_x, mouse_cell_y).main=1-cell(mouse_cell_x, mouse_cell_y).main
  136. endif
  137. endif
  138.  
  139. Return
  140.  
  141.  
  142.  
  143. `<><><><> 2
  144. new_state:
  145.  
  146. if keystate(28)=0
  147. entered=0
  148. endif
  149.  
  150. if keystate(28)=1
  151. if entered=0
  152. entered=1
  153. enterpressed=1
  154. endif
  155. endif
  156.  
  157. if enterpressed=1
  158.  
  159. for x=0 to grid_width-1
  160. for y=0 to grid_height-1
  161. cell(x, y).mark=0
  162. cell(x, y).new=cell(x, y).main
  163. next y
  164. next x
  165.  
  166. for x=0 to grid_width-1
  167. for y=0 to grid_height-1
  168. if cell(x, y).main=1
  169.  
  170. for x2=x-1 to x+1
  171. for y2=y-1 to y+1
  172.  
  173. if x2>=0 and x2<=grid_width-1
  174. if y2>=0 and y2<=grid_height-1
  175. cell(x2, y2).mark=1
  176. endif
  177. endif
  178.  
  179. next y2
  180. next x2
  181.  
  182. endif
  183. next y
  184. next x
  185.  
  186. for x=0 to grid_width-1
  187. for y=0 to grid_height-1
  188. if cell(x, y).mark=1
  189. sisters=0
  190. for x2=x-1 to x+1
  191. for y2=y-1 to y+1
  192.  
  193. if x2<>x or y2<>y
  194.  
  195. if x2>=0 and x2<=grid_width-1
  196. if y2>=0 and y2<=grid_height-1
  197. if cell(x2, y2).main=1
  198. inc sisters, 1
  199. endif
  200. endif
  201. endif
  202.  
  203. endif
  204.  
  205. next y2
  206. next x2
  207.  
  208. if cell(x, y).main=1
  209. if sisters<2
  210. cell(x, y).new=0
  211. endif
  212. if sisters>3
  213. cell(x, y).new=0
  214. endif
  215. endif
  216.  
  217. if cell(x, y).main=0
  218. if sisters=3
  219. cell(x, y).new=1
  220. endif
  221. endif
  222.  
  223. endif
  224. next y
  225. next x
  226.  
  227. for x=0 to grid_width-1
  228. for y=0 to grid_height-1
  229. cell(x, y).main=cell(x, y).new
  230. next y
  231. next x
  232.  
  233. enterpressed=0
  234.  
  235. endif
  236.  
  237. Return
  238.  
  239.  
  240.  
  241. `<><><><> 3
  242. images:
  243.  
  244. paste image 3, 0, 0, 1
  245.  
  246. for x=0 to grid_width-1
  247. for y=0 to grid_height-1
  248. if cell(x, y).main=1
  249. paste image 1, x*cell_width, y*cell_height, 1
  250. endif
  251. next y
  252. next x
  253.  
  254. paste image 2, mouse_cell_x*cell_width, mouse_cell_y*cell_height, 1
  255.  
  256.  
  257. print mx
  258. print my
  259. print mouse_cell_x
  260. print mouse_cell_y
  261.  
  262. Return
  263.  
  264.  
  265.  
  266. ` Functions
  267.  
  268. Function time_check(num, timepass)
  269.  
  270. time(num)=timer()-oldtime(num)
  271.  
  272. if time(num)>=timepass
  273. oldtime(num)=timer()
  274. Exitfunction true
  275. endif
  276.  
  277. Endfunction false
Advertisement
Add Comment
Please, Sign In to add comment