[ab] Feature suggestion -- support subsurface blitting

Luke J Crook luke at balooga.com
Sat Mar 17 01:00:45 CST 2007


Anthony Fairchild wrote:
> Hello again,
> 
> I finally got back to working on my lispy jigsaw puzzle game and I've
> made a
> few changes to the code to clean things up and make it more manageable.  In
> the first implementation I made a new surface for every puzzle piece and
> rotation.  This generated a very large number of surfaces.  The cleaner
> solution involves using a single surface containing an image array of each
> puzzle piece.  See this link for an example:
> http://img395.imageshack.us/my.php?image=leaveshb1.png
> 
> To blit the images on the screen I have to use SDL-BASE::BLIT-SURFACE
> because it take a source and destination rectangle.  I created my own
> blitting function to wrap the low level foreign pointer stuff, and it
> initially looked like this:


Anthony,

It looks like what you have is a sprite sheet. A surface containing all
the images that you want to use. I think you can make use of the
existing CLEAR-CELL, SET-CELL, SET-CELL-* functions. A 'cell' behaves
like a clipping rectangle, but on the source surface.

So do something like this:

(set-cell-* 0 0 50 50 :surface jigsaw-sheet) ;; This sets the source
rectangle to the x/y w/h of one of your jigsaw pieces.

(draw-surface-at-* jigsaw-surface 100 100 :surface
sdl:*default-display*) ;; This draws the jigsaw piece to the display at
position x/y

There should be zero consing as a new rectangle is not created.

- Luke



More information about the application-builder mailing list