Performance with 250+ bodies and rects ...

Playing around building a maze type game I seem to run into fps issues
when there’s 250+ bodies and walls (built using physics and rects)
being redrawn using draw() - would a better way be to draw these
rects using setContext and refresh the screen using a sprite ?

@escape75 I ran into this problem as well. I just put all the non-moving bodies into a single image using setContext(). I will most likely put a example here once I’m done with school.

Yeah that’s sort of what I was thinking of …

I wonder why the performance is like that with something basic such as this,
maybe relates to codea insisting on calling draw() at 60 fps ? I don’t know.

@escape75 - physics involves a lot of collision checking, so avoid using it where you don’t need to. Using sprites for non-dynamic bodies is one solution, another is writing your own physics code, if what you want is pretty simple. I have written some posts on doing this, if you need them.

also, even if a body is a physics body, if it’s not movable make sure it’s type is static, this drastically reduces the work needed by the engine. dynamic bodies collide with static, but because the static ones don’t move, the maths for what to do on collision is much simpler.

For example:
http://twolivesleft.com/Codea/Talk/discussion/2077/drop-2000-squares-into-a-pile-at-30-fps

By making objects static when they have stopped moving and moving the drawing of the static to a single image which is blatted across rather than drawing them individually it gets good performance. It is (at the end) a full 2000 physics objects.