Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Thousands of objects on screen?

edited June 2014 in Questions Posts: 3

I hate introducing myself on a forum with a help post. So for that, I apologize. I am developing an app that would require thousands of tiny (pixel size) objects on the screen at once. A good example of what I mean by thousands is this app ( https://appsto.re/us/Boj8H.i ). I wanted to use physics objects, but maybe that won't be the way to go. They need to be able to interact with eachother (collision detection) and be affected by gravity, which is why I wanted to use physics. I've tried using circles, squares and lines. But when it reaches about 200 (on the air) it drops to 30-20 fps. Any tips? Maybe just vectors in tables with sprites assigned? Thank you all for your time, this post had to be quick.

EDIT:
Actually what I want to do is make a game like http://powdertoy.co.uk that for iPads. I find it extremely fun. Any new helpful comments?

@Kjell I could use that image idea for pixels that are buried, and have each color identified with a certain element. That way when movement, etc happens it can be converted back into a physics object.

Comments

  • dave1707dave1707 Mod
    Posts: 7,807

    @WhatsALua You already found out that the more physics objects you have, the slower things get. As long as you want the objects to react with each other, you're limited by how many there are. I can't think of a way around that.

  • Posts: 82

    I've watched a video of the app you described (), I don't know if this is exactly what you're after. But in this case, you can greatly oversimplify the system.

    Assuming you can only drop sand from above, you only need individual grains of sand tot interact with each other at the top layer, right? Once a grain is covered by a layer of, say, 20 pixels thick, you can assume that it will stay there. Than you can draw that pixel permanently onto an image, which is drawn underneath the still 'fluid' sand layer. That way you can greatly decrease the number of physics objects necessary.

  • edited June 2014 Posts: 3

    Actually what I want to do is make a game like http://powdertoy.co.uk that for iPads. I find it extremely fun. Any new helpful comments?

    @Kjell I could use that image idea for pixels that are buried, and have each color identified with a certain element. That way when movement, etc happens it can be converted back into a physics object.

    -- Put in the top post as well

  • edited June 2014 Posts: 1,595

    @WhatsALua your best bet is probably creating an image the size of the screen and using image:get/image:set. In my version I use this and have objects defined by colour.

  • Posts: 65

    Do you mean something like this ios game?:
    https://itunes.apple.com/gb/app/powder-game-viewer/id521519384?mt=8

    If you're new to coding and codea, you should start with something easier.
    If you already have some experience: good luck.

  • Posts: 3

    @G_nex yes just like that. Guess it's already a game though, so time to move on.

  • Posts: 65

    Well, if you really want to make a game like that, you always could make a better one.

  • Posts: 425

    There's nothing wrong with remaking a game that's already out there

  • Posts: 65

    Coder is right. There are a billion of flappy bird copies in the appstore :p

  • Posts: 455

    I played with a little bit of stuff akin to this a long time ago. Unfortunately I don't think the box2d physics engine scales very well to these small objects, and approaches like image:get are also far to slow to make this work. But a full physics engine is probably not the right approach, if you look at sand games like this they tend to have a very simplified model of movement and stacking, which you need to get performance.

    I'm not sure lua/Codea (while very powerful and easy) is going to get the performance you want, but if I were to do this again now, there might be angles in shaders to write optimised code and get the GPU to do some of the heavy lifting.

Sign In or Register to comment.