|
-
Sprites vs Bitmaps
There have been many threads on these and many other forums about using Bitmaps over Sprites/MovieClips in game development. I made my own tests quite a while back and I've been inspired by this blog post (http://www.8bitrocket.com/newsdispla...?newspage=7496) to now post mine online on my new blog:
http://blog.fatal-exception.co.uk/?p=4
These tests are very simple and are only meant for beginners. I hope that they are of some use
-
Professional Flash Developer
Wow, great job! That is a nice compliment to the article I wrote. Great explanation. I am sure many people will find this useful.
-Jeff
www.8bitrocket.com
-
Senior Member
If the content of sprite does not change you could set its cacheAsBitmap property to true.
Also, fillRect is 3 times faster then copyPixels, however it only works to fill rectangular area with single color which is rarely case in real games. For more useful results you should consider using copyPixels.
And, you are missing example of many bitmaps added on screen.
-
Thats a very good point. I would have used copyPixels in this test but I ran into a problem - I wanted a quick way to create a pixel of unknown dimensions and a random colour and I wasn't smart enough to think of a quick n easy way to do this.
In a future example I will use a static image and use copyPixels to paint this to the display.
Also, I did not know fillRect was faster than copyPixels. I've learned something new
-
Senior Member
Sprite itself is not directly comparable with pixels in bitmap since Sprite is Interactive Object. For the sake of comparing simplest graphics drawn on screen, I would suggest using Shape object instead of Sprite.
-
Senior Member
Based on research and a lot of the discussion here, we are working on an isometric tile engine for some projects as well (Jeff knows what I'm talking about ). With copyPixel as fast as it is, we are trying out some traditional C++ techniques for tile engines and the initial results are very promising.
Hopefully we will have a speed test example we can put online in the next few days. Basically, we want to apply some of the speed discussion to a large-scale game project. Please keep these threads coming, for those of us that review them regularly, there is a lot of value in them.
-
Professional Flash Developer
Mike, I am working on one more test.
This time I have eliminated the object oriented structure for the display objects and have some very interesting positive results. Of course I get a better frame rate, and a slightly better execution time, but the biggest change is in object creation time. The 15,000 objects when created as generic Objects take just a fraction necessary to create instances of a GameObject class. I am still running all of the test and compiling my results, but I will have it up tomorrow.
I would love to hear about the C++ ideas. I got my original BitmapData array idea form Game Programming All In One Book by John Harbour. It is in C++ using the Allego engine.
-Jeff
-
Professional Flash Developer
http://www.8bitrocket.com/newsdispla...?newspage=7582
Here is my one final speed test for 2007. This time I pitted my fastest object oriented engine with looping event calls against an engine that uses generic objects and instead of instances of my GameObject class.
I am calling it "Good Game Code v. Optimized Game Code". The new, optimized game code came out on top. I was able to achieve another 11-12% increase in FPS and render execution time, and over 230% decrease in both memory usage and object creation time.
-Jeff
-
Really my post and this topic should have been called differently as it isn't really a test of Sprites vs bitmaps.
I'm going to publish a new post on tuesday which actually shows normal animated movieclips and recreates the effect with using copyPixels.
-
Senior Member
 Originally Posted by 8bitjeff
I am calling it "Good Game Code v. Optimized Game Code". The new, optimized game code came out on top. I was able to achieve another 11-12% increase in FPS and render execution time, and over 230% decrease in both memory usage and object creation time.
Its not surprise. Classes and OOP adds lots of things that eat time and resources. However, they also add error checking and create easy-to-read code. I would imagine very best speed will be achieved by creating swf manually in bytecode. You would probably spend years poking around in bytecode to make "Hello World" but it would be fastest possible.
Same way every game engine will perform worse then code written specifically for that specific game because no game uses fully everything the engine can provide. But using engine can speed up development dramatically and allow people who are not able to program everything themselves create games too.
Its always a tradeoff between execution speed and development time. You can keep tinkering with code, making it faster and more optimised every day. There are limitless ways to improve execution time and its not easy to decide where the improvement really matters when people are playing it.
-
Professional Flash Developer
Thanks, Tonypa. I wasn't really surprised either by the FPS increase or the execution time savings. I just didn't know how much they would be, and 10-12%, while significant, won't make me change my engine away from events or OOP. Something I had not considered too much before now was object creation time. It seems that pooling is absolutely necessary if OOP is going to be used for game objects. Unless of course you have so few objects that pooling doesn't make sense.
-Jeff
-
Hype over content...
Is object creation time that big a deal in the grand scheme of things ?
Ok, it's going to cause a hit, but only a slight one, and every game has the object creation process to go through.
With pooling at least you hit that max limit where creation isn't needed any more.
I guess in theory you could fill your object pool up at init time but I really wouldn't worry about it. I find when you kill a baddie in your game ( Replacing the sprite with an explosion, triggering the sound, increasing the score ) is always nastier and needs to be spread over a couple of frames, than actually making an object in the first place.
Squize.
-
Professional Flash Developer
Squize, you are probably right. In fact, there are some things in AS3 that take up much more time than creating objects, and how often will I be creating 15,000 objects at the same time? I like the pooling ideas though, especially for enemy objects (when there are hordes of them), for missiles, etc. A nice little array pool can't hurt when a* is taking up the rest of my cycles.
-Jeff
-
I've finally posted a proper comparison of rendering using MovieClips against using copyPixels. Again, this example is meant for beginners. I hope you find it useful 
http://blog.fatal-exception.co.uk/?p=5
-
Senior Member
Thanks for new test 
However, I think there is something wrong with the swfs in your blog as in the place of movie clips example it shows copyPixel swf and in the place of copyPixel example it just shows "Can not display swf".
-
Hi,
Sorry about that - a careless mistake I would have picked up on if I'd actually tested it with IE. It should be working correctly now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|