Multiple layers of images on one surface?

Hello!

I am using Rotozoom in the SDL_gfx library to rotate my sprites.
And in my game I have a Mech (Yea ain’t mechs the coolest thing on this
earth? :D),
the Mech is 3 layers, top is his missile tower, second his canons, and
last his body.

I could rotate and blit all three surfaces separatly, but I don’t want to.
So my questions are rather simple,

Can I send 3 images to one surface and then rotate, and then blit?
How do I do this?

Best regards
Jesper

  1. enable transparency blitting on the 3 mech surfaces, see below
  2. create a surface big enough to hold the whole mech, M
  3. blit the body surface B on M
  4. blit the canon surface C on M
  5. blit the missile surface D on M

Explanation of 0:
Make sure to call SDL_SetColorKey on B, C and D with the correct
"transparency" color (the exact format depends on if you are using
index mode or “truecolor” mode for your surfaces). For example, if you
are using 24 bit surfaces and use the color 0xFF00FF (bright pink) as
transparency color you would first of all do

SDL_SetColorKey(B, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(C, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(D, SDL_SRCCOLORKEY, 0xFF00FF);

Good luck!

/OlofOn 8/7/05, Jesper Liljegren wrote:

Hello!

I am using Rotozoom in the SDL_gfx library to rotate my sprites.
And in my game I have a Mech (Yea ain’t mechs the coolest thing on this
earth? :D),
the Mech is 3 layers, top is his missile tower, second his canons, and
last his body.

I could rotate and blit all three surfaces separatly, but I don’t want to.
So my questions are rather simple,

Can I send 3 images to one surface and then rotate, and then blit?
How do I do this?

Best regards
Jesper


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hey Olof,

How do I create an empty surface thats not empty, if you read me :slight_smile:
I tried to just NULL the pointer and set ->w/h to 64x64, but I got some
compilerrors.
Pretty obvious tho, but you gotta try.
Got any tips?

And one more thing, does this SDL_SetColorKey also apply on .png? My
.png already comes with an transparant background.

Best regards
Jesper

Olof Bjarnason skrev:>0. enable transparency blitting on the 3 mech surfaces, see below

  1. create a surface big enough to hold the whole mech, M
  2. blit the body surface B on M
  3. blit the canon surface C on M
  4. blit the missile surface D on M

Explanation of 0:
Make sure to call SDL_SetColorKey on B, C and D with the correct
"transparency" color (the exact format depends on if you are using
index mode or “truecolor” mode for your surfaces). For example, if you
are using 24 bit surfaces and use the color 0xFF00FF (bright pink) as
transparency color you would first of all do

SDL_SetColorKey(B, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(C, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(D, SDL_SRCCOLORKEY, 0xFF00FF);

Good luck!

/Olof

On 8/7/05, Jesper Liljegren <@Jesper_Liljegren> wrote:

Hello!

I am using Rotozoom in the SDL_gfx library to rotate my sprites.
And in my game I have a Mech (Yea ain’t mechs the coolest thing on this
earth? :D),
the Mech is 3 layers, top is his missile tower, second his canons, and
last his body.

I could rotate and blit all three surfaces separatly, but I don’t want to.
So my questions are rather simple,

Can I send 3 images to one surface and then rotate, and then blit?
How do I do this?

Best regards
Jesper


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hey Olof,

How do I create an empty surface thats not empty, if you read me :slight_smile:
I tried to just NULL the pointer and set ->w/h to 64x64, but I got some
compilerrors.
Pretty obvious tho, but you gotta try.
Got any tips?
Read about SDL_CreateRGBSurface.

And one more thing, does this SDL_SetColorKey also apply on .png? My
.png already comes with an transparant background.
Yes, but SDL_image (or what you are using) does not recognize this to
my knowledge. Easiest fix is if you use your paint program and fill
all “transparent areas” with FF00FF (or other non-popular color) and
use the method I described.On 8/7/05, Jesper Liljegren wrote:

Best regards
Jesper

Olof Bjarnason skrev:

  1. enable transparency blitting on the 3 mech surfaces, see below
  2. create a surface big enough to hold the whole mech, M
  3. blit the body surface B on M
  4. blit the canon surface C on M
  5. blit the missile surface D on M

Explanation of 0:
Make sure to call SDL_SetColorKey on B, C and D with the correct
"transparency" color (the exact format depends on if you are using
index mode or “truecolor” mode for your surfaces). For example, if you
are using 24 bit surfaces and use the color 0xFF00FF (bright pink) as
transparency color you would first of all do

SDL_SetColorKey(B, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(C, SDL_SRCCOLORKEY, 0xFF00FF);
SDL_SetColorKey(D, SDL_SRCCOLORKEY, 0xFF00FF);

Good luck!

/Olof

On 8/7/05, Jesper Liljegren wrote:

Hello!

I am using Rotozoom in the SDL_gfx library to rotate my sprites.
And in my game I have a Mech (Yea ain’t mechs the coolest thing on this
earth? :D),
the Mech is 3 layers, top is his missile tower, second his canons, and
last his body.

I could rotate and blit all three surfaces separatly, but I don’t want to.
So my questions are rather simple,

Can I send 3 images to one surface and then rotate, and then blit?
How do I do this?

Best regards
Jesper


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I tried to just NULL the pointer and set ->w/h to 64x64, but I got
some compilerrors.

Go buy a book on C.On Aug 7, 2005, at 10:39 AM, Jesper Liljegren wrote:

Please, go buy a book about reading…

“Pretty obvious tho, but you gotta try.”

Donny Viszneki skrev:>

On Aug 7, 2005, at 10:39 AM, Jesper Liljegren wrote:

I tried to just NULL the pointer and set ->w/h to 64x64, but I got
some compilerrors.

Go buy a book on C.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl