Sprites in RUDL

G

Glenn

My attempt at writing PACMAN was going smoothly but now I've stalled.
Not being a "games" programmer (other than 5 or 6 Tetris version), I
rarely deal with graphics as such, and I'm having a problem with the
sprites (ie. pacman and ghosties).

Basically I want to move the sprite without damaging the "underneath"
picture, as it were. I have a display which is double buffered, so I
can flip the pic etc for fast updates and I can get the effect I want
if each time I completely re-paint the maze first, but of course that
is slowwwwwww.

What I want is (I guess), to restore just the areas where the sprite
moved from, so I guess I need to take a copy of what was in that area
before I draw the sprite.

Can't for the life of me figure out how. Help!

PS. My wife thinks my hands are glued to my new "Programming Ruby"
book because I haven't put it down in days!!!

Cheers

G
 
L

Linus Sellberg

What I want is (I guess), to restore just the areas where the sprite
moved from, so I guess I need to take a copy of what was in that area
before I draw the sprite.

Well, an idea that requires less work is to keep the whole background
unmodified all the time, and just update the area around (and under for
simplicities sake) the pac, all the time.
 
F

Florian Gross

Glenn said:
What I want is (I guess), to restore just the areas where the sprite
moved from, so I guess I need to take a copy of what was in that area
before I draw the sprite.
Can't for the life of me figure out how. Help!

This is how I do these things:

1) Blit all elements of the background to a background surface. (You
only need to do this when the background changes.)
2) Blit the background surface to the main surface every frame.
3) Blit pacman to the main surface every frame.

Regards,
Florian Gross
 
F

Florian Gross

Glenn said:
So you blit the whole background each time - doesn't that slow things down?

Works like a charm. I'm getting good frame rates. Most games actually
redraw the whole screen multiple times per second.

You could slow things up by doing exactly that (my version redraws
*everything* the whole time even if it's not in the ViewPort) or by
using a system to detect what region of the Screen has actually changed
-- but I'd think that the overhead added by that would actually exceed
any performance gained.
 
G

Glenn

Thanks to your help, Pacman is very much now back on track! He's
moving round that maze like a good little pacman should!

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top