Skip to main content
GameDev.net gamedev.net
🔒 Locked

Who know transition algorithm?

Started by WillTop May 31, 2004 at 9:09 AM 5 replies 550+ views
Original Post
WillTop
WillTop
At the moment, I write the game map editer, but i want to link such as a block of grassplot with a block sandlot£¬hot to link them smoothly?
Drazgal
Drazgal
I think this is similar to what you are after.

http://www.cbloom.com/3d/techdocs/splatting.txt
WillTop
WillTop
I want it 2D!
Matei
Matei
What library are you using to draw the images? Does it support semitransparent images? If so, for each type of tile, create a "smooth blend" version for each direction it could blend in. Make this start at alpha 0.5 at the edge of the tile to 0 somewhere like a quarter of the way through. Then, overlap this version onto the tiles at its edges if they are a different type. Sorry that this is a bit vague, I can''t find any example that does it, but I''ve seen it done in many 2D games.

For example, say your original tile is this size:

-------
| |
| |
| |
-------

Then the "north blend" version would be as follows:

------- <- alpha value = 0
| | <- north blend tile
------- <- alpha value = 0.5
| |
| | <- original tile
| |
-------

Check if the tile above yours is not of your type, and if so, draw your north blend version above yourself. The tile above will draw its south blend version onto you. Make sure you do this after drawing the real tiles so the blending looks well.
WillTop
WillTop
My library support semitransparent images!Because I use the gta file format, each image contain alpha information,on this condition, how to do ?I think I want some codes!
Matei
Matei
You haven''t even said which library or language you''re using, how can we give you code? Basically, you should be able to create the semitransparent images in Photoshop or some other image editor. If not, most drawing libraries let you edit an image''s pixels one by one, so you can set the alpha yourself to create the blend image.

Pseudocode:

for each tile on the screen:
draw the tile

for each tile on the screen:
if the tile above it is of a different type:
draw the "north blend" version of the tile on the one above
if the tile below it is of a different type:
draw the "south blend" version of the tile on the one brlow
if the tile left of it is of a different type:
draw the "west blend" version of the tile on the one to the left
if the tile right of it is of a different type:
draw the "east blend" version of the tile on the one to the right
WillTop
WillTop
Matei:thank you.My library is written by myself and the language is C++¡£please send codes to my email:true_smart@hotmail.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.