PixelGen - A sand sandbox (like PowderGame, Falling Sands)

I tried to use new image class to make a pixel game. After lot’s of attempts, I think this is the most efficient way to make pixels move with gravity and other basic elemental features(like water etc.)(I am not a game programmer :slight_smile: ) Codes are not well organized but I believe this may give someone an idea how to make a sand game.

There are only three elements now. If you remove making pixel white after moving “line” ( delete that line), you may see beautiful pixel based images.

You can download it from here: http://tdgunes.posterous.com/pixelgen

I will be really happy to see comments about making this better. (Maybe there is an another way to make this even easier, if you know that way, please let’s hear it :slight_smile:

This is really cool, tried it out earlier today.

There is one problem, you are running into the instruction limit. Call setInstructionLimit(0) in your setup() function to disable the instruction limit.

Also, it would be cool if when you drag your finger you add a larger number of particles at once, or perhaps you could use a lower resolution image and render it larger with noSmooth(), so the particles are bigger.

Hi,
On nov 13th, I submitted a small program called Particle Fountain. Although (obviously) it does not use the new image class, it could easily be adapted to act as a sand game with the effect Simeon is looking for. Now the particles bounce and go dark over time, but this could easily be changed so the particles stick when they hit either the bottom or a specific value of dark red indicating a stuck pixel. In fact I did the exact thing for my basic-256 program, though not the one posted on my site ( uglymike.net )) Hmmmm, given time, I might do exactly that for my Lua program…

This is a great jumping off point for very detailed control. It would not have occured to me.

@tdgunes, I enjoyed the sand game. It would be cool if more sand was generated and if it was affected by gravity.

@Simeon, thank you for your comment, there is actually a big problem while implementing your opinion about scaling pixels to make them bigger. Current method for generating pixels is easy as writing CurrentTouch.x and CurrentTouch.y. How can make the coordinates scale as I scale image ?

@Fred, For gravity, I mean making pixels move down for every frame. Not accelerometer based gravity. My second goal is making more pixels when you touch and making water more realistic (like acting as a one object)

@tdgunes you would have to apply the inverse scale to the touches. A bit tricky but I’ll see if I can come up with an example later.

There’s an example of this inverse touch scaling in the Mandelbrot sample program.