UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: Jupei on June 26, 2008, 03:05:18 PM

Title: Confusion Re: Map Level Transparency
Post by: Jupei on June 26, 2008, 03:05:18 PM
I'm trying to learn how to work with maps and levels.
I can't seem to figure out how to render 2 layers of levels (foreground and background) with transparency, so that the transparent pixels in the foreground show through to the background. Its my understanding thats how "levels" are supposed to work so it should be possible right? Here the tiles I made:

As they should appear:
(http://www.captain-angry.com/gamedev/td_tiles_black.png)

With 255 green as a mask:
(http://www.captain-angry.com/gamedev/td_tiles_green.png)

As a transparent PNG:
(http://www.captain-angry.com/gamedev/td_tiles_trans.png)

Here is my code:
[pbcode]Map1=NewMap(2)

;Load Map Tile Image
LoadImage "td_tiles_green.png",1
ImageMaskColour 1, RGB(0,255,0) ; Right/Wrong?

;Assign MapGFX attached to MyMap with 255G as "transparentColour"
MakeMapGFX Map1,1,32,32,32,RGB(0,0,0)

;Create 2 Levels, BG and FG
ForeGround=NewLevel(Map1,25,18)
BackGround=NewLevel(Map1,25,18)

;Fill ForeGround with highly transparent tiles from top row of tiles
For X = 0 To 25
   For Y = 0 To 18
      T = T + 1
      PokeLevelTile Map1,ForeGround,X,Y,T
      If T = 7 THEN T = 0
   Next Y
Next X

;Fill BackGround with dark background tiles
T = 15
For X = 0 To 25
   For Y = 0 To 18
      T = T + 1
      PokeLevelTile Map1,BackGround,X,Y,T
      IF T = 17 THEN T = 15
   Next Y
Next X

;draw BG Level at 0,0
DrawMap Map1,BackGround,0,0

;draw FG Level at offset to check for transparency
DrawMap Map1,ForeGround,16,16

sync
waitkey
[/pbcode]

Here is what I end up with:
(http://www.captain-angry.com/gamedev/bad_trans.png)

All that green should be transparent... I have tried setting the ImageMaskColour of the tiles image to green. I have tried setting the "TransparentColour" flag in MakeMapGFX to green. I've tried doing them both together. If I just use a transparent PNG, the green just changes to blue... What am I missing?

Thanks in advance.
Title: Re: Confusion Re: Map Level Transparency
Post by: kevin on June 26, 2008, 03:10:47 PM


See ->  LevelTransparent

Title: Re: Confusion Re: Map Level Transparency
Post by: Jupei on June 26, 2008, 03:15:18 PM
Excellent. Thank you.

;Create 2 Levels, BG and FG, make FG transparent on 255G
ForeGround=NewLevel(Map1,25,18)
BackGround=NewLevel(Map1,25,18)
LevelTransparent Map1,ForeGround, 0


(http://img294.imageshack.us/img294/834/goodtranser7.png)
Title: Re: Confusion Re: Map Level Transparency
Post by: kevin on June 26, 2008, 03:31:52 PM
  Glad it works..  Any reason you're using a really old version of V1.63 ?
Title: Re: Confusion Re: Map Level Transparency
Post by: Jupei on June 26, 2008, 05:16:02 PM
Nope, just never upgraded after purchasing.

I will patch up to 1.63w if its going to keep you up at night. ;D
Title: Re: Confusion Re: Map Level Transparency
Post by: kevin on June 26, 2008, 09:33:55 PM

Ahh, just thought you might be running the old demo..