https://github.com/wisehackermonkey/falling_sand
Another Falling Sand Game
https://github.com/wisehackermonkey/falling_sand
Last synced: 3 months ago
JSON representation
Another Falling Sand Game
- Host: GitHub
- URL: https://github.com/wisehackermonkey/falling_sand
- Owner: wisehackermonkey
- Created: 2024-07-26T00:30:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-26T06:36:18.000Z (over 1 year ago)
- Last Synced: 2025-06-03T21:35:00.611Z (7 months ago)
- Language: JavaScript
- Homepage: https://editor.p5js.org/wisemonkey/sketches/d07oVs7Ws
- Size: 1.54 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# falling sand
inspired by https://www.youtube.com/watch?v=ArcHpsTXhb0
Another Falling Sand Game
# [Demo! click here](https://editor.p5js.org/wisemonkey/sketches/d07oVs7Ws)
https://github.com/wisehackermonkey/falling_sand
creator wisehackermonkey
20240725
found a cool recusive algrotim that speeds up drawing 100x*
also looks cool to boot!
# CONTROLS
# + = make bigger (key is actually "=")
# - = make smaller
# SPACE = reset
inspired by amazing video
Another Falling Sand Game
by
TimidAutomaton
https://www.youtube.com/watch?v=ArcHpsTXhb0
*idk real numbers are hard.
http://localhost:5555/#/falling_sand


first working verions!!!

# first working piling behavor

# prompt
```python
write a javscript p5.js sketch.
creates two grid's
grid_current = a NxN arrays, (hiegnt, width),initalized to all 0 's
grid_buffer = a NxN arrays, (hiegnt, width), initalized to all 0's
create a enum {0: empty, 1: sand}
set current position to
where height defaults to 10
width defaults to 10
create a function updateGridState to screen
inputs:
grid_buffer, grid_current
for each row in grid
iterate the columns
if grid[current row+1][current column] is equal to enum "empty"
set grid_buffer [current row][current column] to 'empty'
# move the sand pixel down
set grid_buffer [current_rowrow+1][current column] to "sand"
if cell bellow current is sand and grid to left & down is 'EMPTY'
set left and down = SAND
set current index to EMPTY
returns buffer grid
create a function draw_pixels
inputs:
scale factor for pixels default to 4x size, grid
for each position in grid draw a rect of size scale factor by scale factor
set fill color to sandstone yellow
return
create a function that sets the current mouse position mapped to which current grid location its pointed to and sets it from EMPTY to full
also set the surounding pixels in a radius of 5 to SAND
funciton draw()
set the result of updateGridState(scale factor, grid_buffer, grid_current) to current grid
draw_pixels
```
prompt v1
draw_pixels
create a edge detection kernal if the sum of the kernal detects a edge add a vertext to beginshape
if not dont do anything

DUDE THIS LOOKS AWESOME
but has error of vertex drawing order

fixed! was simple
dam this one came out looking really cool
prompt v2
draw_pixels
recusively do
start by splitting the grid into 4 quadrents test each, keep sub dividing untill box test size is 1
set call limit to 10
box test is iterate through
if 0 is found then box test fails
recurvivly subdivide the box
if all are 1's then pass
add vertex's for all 4 corners of.

looks cool by color by call depth

create eraser
create water