src/viewport.cpp
branchnoai
changeset 9694 e72987579514
parent 9629 66dde6412125
child 9701 d1ac22c62f64
--- a/src/viewport.cpp	Fri Aug 03 19:16:36 2007 +0000
+++ b/src/viewport.cpp	Fri Aug 03 22:09:42 2007 +0000
@@ -134,7 +134,8 @@
 	return p;
 }
 
-void InitViewports() {
+void InitViewports()
+{
 	memset(_viewports, 0, sizeof(_viewports));
 	_active_viewports = 0;
 }
@@ -477,8 +478,18 @@
 	AddChildSpriteScreen(image, pal, pt.x - vd->parent_list[-1]->left, pt.y - vd->parent_list[-1]->top);
 }
 
-
-void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z)
+/** Draw a (transparent) sprite at given coordinates
+ * @param image the image to combine and draw,
+ * @param pal the provided palette,
+ * @param x position x of the sprite,
+ * @param y position y of the sprite,
+ * @param w width of the sprite,
+ * @param h height of the sprite,
+ * @param dz delta z, difference of elevation between sprite and parent sprite,
+ * @param z elevation of the sprite,
+ * @param transparent if true, switch the palette between the provided palette and the transparent palette
+ */
+void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, int x, int y, int w, int h, byte dz, byte z, bool transparent)
 {
 	ViewportDrawer *vd = _cur_vd;
 	ParentSpriteToDraw *ps;
@@ -487,6 +498,12 @@
 
 	assert((image & SPRITE_MASK) < MAX_SPRITES);
 
+	/* make the sprites transparent with the right palette */
+	if (transparent) {
+		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
+		pal = PALETTE_TO_TRANSPARENT;
+	}
+
 	if (vd->combine_sprites == 2) {
 		AddCombinedSprite(image, pal, x, y, z);
 		return;