A small falling sand game in less then 560 characters of code.

Controls:

  • Scroll left and right with arrow keys
  • Z to place sand

This game was made for #TweetTweetJam 4. The rules of this jam are that the code must be able to fit within two tweets with no other assets other then the code.

Code:

i,g,h,w,a=0,30,60,btn,{}
for x=0,128 do
a[x] = {}
for y=0,128 do
a[x][y] = 0
end
end
function b()
cls(0)
for x=128,0,-1 do
for y=128,0,-1 do
if(a[x][y] == 1)then
if a[x][y+1] == 0 then
a[x][y] = 0 a[x][y+1] = 1
elseif a[x+1&127][y+1] == 0 then
a[x][y] = 0
a[x+1&127][y+1] = 1
elseif a[x-1&127][y+1] == 0 then
a[x][y] = 0
a[x-1&127][y+1] = 1
end
pset(x,y,10)
end end end end
function _update()
if(w(0))then g-=1&127 end
if(w(1))then g+=1&127 end
if(w(4))then a[g][h] = 1 end
if i==1 then b() i=0 end
i+=1
end

StatusReleased
PlatformsHTML5
Rating
Rated 4.0 out of 5 stars
(1 total ratings)
Authorend_sub
GenreSimulation
Made withPICO-8

Comments

Log in with itch.io to leave a comment.

Ooh, relaxing!  I know the constraints are rough, but I yearn for another color of sand to mingle together.  Surprisingly legible code given the challenge.  

Cool!

Oooo I love these sand game, very nice work!

Here's a hot tip though, rather than declare a big 2D array for all your pixels, you can make use of pget() and pset() to do the same job! I made a similar tweet cart a sort while ago with this in mind;
https://twitter.com/ctinney94/status/1250410751820472321

Hope to see you for TTJ5!