Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rem Project: life
- Rem Created: Sunday, June 08, 2014
- Rem ***** Main Source File *****
- Rem Project: memblocks
- Rem Created: Sunday, January 02, 2011
- Rem ***** Main Source File *****
- ` ~SETUP~
- set window off
- set display mode 1024,768,32
- `maximize window
- sync on:sync rate 0
- set text font "Times New Roman",1
- set text size 20
- randomize timer()
- ink rgb(255,255,255),0
- ` Varibles
- #constant true=1
- #constant false=0
- grid_width=110
- grid_height=110
- max_width=5000
- max_height=5000
- screen_width=screen width()
- screen_height=screen height()
- cell_width=screen_width/grid_width
- cell_height=screen_height/grid_height
- mouse_cell_x=0
- mouse_cell_y=0
- mx=0
- my=0
- old_mouse_cell_x=0
- old_mouse_cell_y=0
- clicked=0
- entered=0
- enterpressed=0
- sisters=0
- dim time(10)
- dim oldtime(10)
- type cellstuff
- main
- mark
- new
- endtype
- dim cell(max_width, max_height) as cellstuff
- ` Images
- ink rgb(255,255,255), 0
- box 1, 1, cell_width, cell_height
- get image 1, 0, 0, cell_width, cell_height
- sync:cls
- ink rgb(0,192,255), 0
- box 1, 1, cell_width, cell_height
- ink 0, 0
- box 2, 2, cell_width-1, cell_height-1
- get image 2 ,0, 0, cell_width, cell_height
- sync:cls
- ink rgb(165,165,165), 0
- for x=0 to grid_width+1
- line x*cell_width, 0, x*cell_width, grid_height*cell_height
- next x
- for y=0 to grid_height+1
- line 0, y*cell_height, grid_width*cell_width, y*cell_height
- next y
- get image 3 ,0, 0, grid_width*cell_width+1, grid_height*cell_height+1
- sync
- sync:cls
- ` ~MAIN~
- DO
- SELECT Game_State
- `<>
- Case 0
- gosub main
- gosub images
- gosub new_state
- Endcase
- ENDSELECT
- sync:cls
- LOOP
- ` ~SUB~
- `<><><><> 1
- main:
- mx=mousex()
- my=mousey()
- old_mouse_cell_x=mouse_cell_x
- old_mouse_cell_y=mouse_cell_y
- mouse_cell_x=mx/cell_width
- mouse_cell_y=my/cell_height
- if mouse_cell_x<>old_mouse_cell_x
- clicked=0
- endif
- if mouse_cell_y<>old_mouse_cell_y
- clicked=0
- endif
- if mouseclick()=0
- clicked=0
- endif
- if mouseclick()=1
- if clicked=0
- clicked=1
- cell(mouse_cell_x, mouse_cell_y).main=1-cell(mouse_cell_x, mouse_cell_y).main
- endif
- endif
- Return
- `<><><><> 2
- new_state:
- if keystate(28)=0
- entered=0
- endif
- if keystate(28)=1
- if entered=0
- entered=1
- enterpressed=1
- endif
- endif
- if enterpressed=1
- for x=0 to grid_width-1
- for y=0 to grid_height-1
- cell(x, y).mark=0
- cell(x, y).new=cell(x, y).main
- next y
- next x
- for x=0 to grid_width-1
- for y=0 to grid_height-1
- if cell(x, y).main=1
- for x2=x-1 to x+1
- for y2=y-1 to y+1
- if x2>=0 and x2<=grid_width-1
- if y2>=0 and y2<=grid_height-1
- cell(x2, y2).mark=1
- endif
- endif
- next y2
- next x2
- endif
- next y
- next x
- for x=0 to grid_width-1
- for y=0 to grid_height-1
- if cell(x, y).mark=1
- sisters=0
- for x2=x-1 to x+1
- for y2=y-1 to y+1
- if x2<>x or y2<>y
- if x2>=0 and x2<=grid_width-1
- if y2>=0 and y2<=grid_height-1
- if cell(x2, y2).main=1
- inc sisters, 1
- endif
- endif
- endif
- endif
- next y2
- next x2
- if cell(x, y).main=1
- if sisters<2
- cell(x, y).new=0
- endif
- if sisters>3
- cell(x, y).new=0
- endif
- endif
- if cell(x, y).main=0
- if sisters=3
- cell(x, y).new=1
- endif
- endif
- endif
- next y
- next x
- for x=0 to grid_width-1
- for y=0 to grid_height-1
- cell(x, y).main=cell(x, y).new
- next y
- next x
- enterpressed=0
- endif
- Return
- `<><><><> 3
- images:
- paste image 3, 0, 0, 1
- for x=0 to grid_width-1
- for y=0 to grid_height-1
- if cell(x, y).main=1
- paste image 1, x*cell_width, y*cell_height, 1
- endif
- next y
- next x
- paste image 2, mouse_cell_x*cell_width, mouse_cell_y*cell_height, 1
- print mx
- print my
- print mouse_cell_x
- print mouse_cell_y
- Return
- ` Functions
- Function time_check(num, timepass)
- time(num)=timer()-oldtime(num)
- if time(num)>=timepass
- oldtime(num)=timer()
- Exitfunction true
- endif
- Endfunction false
Advertisement
Add Comment
Please, Sign In to add comment