Sign in to follow this  
JesterXL

Blitting Architecture Help

Recommended Posts

JesterXL    122
If this question is more appropriate for Isometric Land, can the admin please move it there? Thanks! I need help in writing some blitting algorithms with inheritance. I don't know what patterns people use via inheritance to allow sub-classes to blit to the same bitmap; how do you all handle it? -------------------- Need some context? Background Flash Player 8 and 8.5 now support blitting. In the past, you'd just use sprites (Flash's MovieClip), and nest your tiles in that in a base class. A sub-class could then draw non-player character sprites. A further sub-class could then deal with moving the character; whether centered Final Fantasy 3 style, or move him as well. The upshot of this was that it didn't take a lot of code to do this, and it made your tiles, character animations, etc. extremely flexible from an art sense, and code wise was pretty easy to tweak and manage. Performance blew. We're talking 96% CPU to scroll a max tile map of 25x25 tiles that are 16x16 pixels in size, masked at 160x120. Blitting Now, with Flash Player 8 and 8.5, you can utilize bitmap objects, with all the lovely pixel manipulations you want, effects included. Combine that with bitmap caching, and definable scroll rects, and suddenly, you're doing the above using 0-2% CPU. However, even just replacing the tile engine with that, and keeping the sprites, you're CPU skyrockets yet again. My Challenge So, again, I'm realizing the sprites, as well as the character sprite all need to be blitted to keep the performance good. I've been using double-buffering, drawing everything to an offscreen bitmap that isn't shown, and then when done, copying the pixels from that to 1 on-screen bitmap. This works great for the tilemap, but... not sure how to handle this for sub-classes; do I expose the bitmap data as a public class variable, and allow them to access it? Do I override the super-class's render method, and intercept it to blit my own things to it before the re-rendering is called? How do people handle this in other languages? Thanks if you can help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this