You Are Here:

Community: Developer Discussion Boards

#1 Old Fast Sprite Effects on Series 40/30 - 2003-09-29, 11:10

Join Date: Sep 2003
Posts: 7
leissler
Offline
Registered User
Hi,

so now I have done my homework and coded this cool sprite engine, which uses drawPixels for fast blitting, has all sprites in a width-aligned array and uses a modulo of 0 for blitting (hi to all old-school amiga coders out there!) i.e. scanlength=width.

Now I can linearly copy a sprite from this array and apply e.g. a mask to it. However, I see two possibilities to do fast sprite masking:
1. use System.arraycopy first ro read a sprite into the buffer and the apply the mask to the values in the buffer

2. write an own loop doing the copying and masking .

Assuming that 'spritefxbuf' is a static buffer for storing the affected sprites, the fist alternative looks something like this (simplified):

int i, j;
int off = sprites[s.frame];
int fxoff = 0;
short[] buf = (short[]) spriteGfxSets[s.set];
System.arraycopy(buf, off, spritefxbuf, fxoff, s.w * s.h);
for (i = w*h-1; i >= 0; --i)
spritefxbuf[fxoff++] &= mask;
bdg.drawPixels(spritefxbuf, true, 0, w, s.x, s.y, w, h, s.manip, NATIVE_SCREEN_FORMAT);

The second one would be:

int off = sprites[s.frame];
int fxoff = 0;
short[] buf = (short[]) spriteGfxSets[s.set];
for (i = w*h-1; i >= 0; --i)
spritefxbuf[fxoff++] = (short)((buf[off++])&mask);
bdg.drawPixels(spritefxbuf, true, 0, w, s.x, s.y, w, h, s.manip, NATIVE_SCREEN_FORMAT);


The big question now is: Whats faster???

I know there are some really good game coders out there with a lot of tricks in their sleeves :) (Hi Albech: your thread about sprite collisions really should have deserved you a beer ... I'll promise to get you one if I ever meet you).

Any other tricks known for doing e.g. fast sprite zooming? (come on albech ... just one more trick)

all the best

Martin
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia