by fzammetti » Jul 7, 2003 @ 4:10am
Just as a reference benchmark, this may help...
My current project involves a 200x200 playfield that is completely redrawn every frame. Basically, there is a 200x200 portion of the screen that is constantly changing, the rest of the screen is static, or at least changes far less frequently.
The way I accomplish this is that I have a 400x400 temporary surface, and I draw to that all the elements of the game field. What I do is I draw to a 200x200 region that is centered on that 400x400 surface (i.e., there is 100 pixels on all sides of the part I draw on). Then, every frame, I do a FillRect on that portion of the surface, redraw all the sprites and other components of the game, and blit that portion of the surface to the real backbuffer.
This allows me to not bother with clipping at all. If a 50x50 sprite is positioned at 180,160 on my temporary surface for example, it will of course get drawn, since it doesn't break a surface boundary. Then when I blit the 200x200 portion of the temporary surface, part of it is of course outside of the source rect, so it's effectively clipped without any calculations whatsoever.
This may sound suboptimal, and I'm not about to argue that it is! But it does make the code rather more simple and removes any clipping concerns I would otherwise have to deal with.
My point to all this though is with regard to speed... On my stock Casio E-125 (MIPS 150MHz for those that don't know), I get 40FPS solid at all times (the game is set to run at that speed). I know that the Casio does it's own double-buffering, so that would logically add to the potential speed difficulties. However, there doesn't appear to be any difficulty at all! I haven't tried to unbound it to see what the maximum frame rate would be (EDIT: I just did... hangs between 50-60 the whole time, depending on what's actually going on at the time) but it's reasonable to guess it would be higher, since it's solid at 40.
There could conceivably be devices out there with specific issues that will cause speed problems later on, but if it runs that well on my Casio, it's a fairly safe bet all "modern" devices will have no trouble whatsoever keeping up.
If I can get these results with what most would view as an inefficient way of doing things, I would say there is something very odd going on for you.
Last edited by
fzammetti on Jul 7, 2003 @ 4:22am, edited 1 time in total.
...and so I said to Mr. Gates: "$640 billion should be enough for anyone!"