Archived

This topic is now archived and is closed to further replies.

Who know transition algorithm?

This topic is 4945 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites