Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   .NET Game Programming (http://www.xtremevbtalk.com/-net-game-programming/)
-   -   Game Tile Transitions (http://www.xtremevbtalk.com/-net-game-programming/324473-game-tile-transitions.html)

VB_Alien 07-23-2012 04:17 AM

Game Auto Tiles
Since i can't sleep tonight (sunday) and it is now after 6am monday,
i was thinking about how Auto Tiles work.

I have a couple of half thought-out tuts that attempt to explain it but
they don't go far enough for me to understand the processes
involved to even begin a very small project like this.

I was just curious if anyone here has ever tried creating a tilebase
game map with auto tiling before.

hDC_0 07-23-2012 03:06 PM

VB_Alien returns..after over a month's absense..
2 Attachment(s)
Hey you're back!

Originally Posted by VB_Alien
i was thinking about how tile transitions work.

Is this a continuance of your Custom Control Image Property thread and/or your Copying tiles from sheet thread?

I didn't post in your custom control thread because I didn't want to discourage you,
but in this post there is code, for Public Sub New(), to turn on doublebuffering:

Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.OptimizedDoubleBuffer, True)

Note: This also works on a panel control, which can act as a container control for using "layered on" picturebox graphics.

However, you can also just
load a picture straight from a file into a memory-based Bitmap object
(to basically have a backbuffer for the graphic) using:

' Load the picture into a Bitmap.
Dim bm As New Bitmap(file_name)
' Display the results.
picImage.Image = bm
picImage.SizeMode = PictureBoxSizeMode.AutoSize

The more "polite" way of doing this is here.

Code for loading to an Image object (using that as a backbuffer),
and then DrawImageUnscaled painting to a panel control is also shown on this jo0ls post.

jo0ls also posted some nice Surface class code on this social.msdn thread.

Personally I think flipping backbuffered graphics directly onto the form,
(with DoubleBuffered property set to true),
is just as valid as using controls so long as a Multiple buffering pipeline
is set up correctly offscreen.

Do you ever have a chance to play around with the
that surfR2911 posted as the last post in you tiles sheet thread?

There are a whole bunch of ways to do tile transitions:
1.) A "flip map" hop, with or without a tile map scrolling (1, 2)
2.) A 2D "shoots and ladders" type transition
3.) A teleporter pad (with round go-thru portal or flying pad, DungeonSeige-style)
4.) An alpha-blended transition stairway (like Diablo-style)

Speaking of which, if you look for the links to the old VB6 demo that
rpgnewbie did for alphablended transitioning of Diablo-style rpg graphics
most of the links are broken (because they used the old style thread urls).

Additionally rpgnewbie had trouble getting the whole thing up in one zip
because of the upload limitations (and frequent time-outs) of the forum back then,
so maybe I it's time to try and do a re-posting to restore the attachment to its whole condition.

It's a very humble demo, but it still has gotten over 1000 "views" for parts A & B combined,
meaning close to 600 people at least tried it out to date.

In terms of an alphablending demo, using rpg graphics, that is designed to show a transitioning:
"when you go inside a building or behind a pillar the game "fades out" the blocking wall/roof/pillar."
it's pretty much the best demo available,
even though it uses isometric tiling
(and of course for your purposes would need some VB.Net alphablending code
similar to what is going on now in posts #19, #22, & #25 of the Viewer thread).

VB_Alien 07-23-2012 04:52 PM

Thanks for you reply hDC. I'm afraid i may have mislead
you in what i was talking about. Perhaps i used the wrong

What i meant by tile transition is, lets say you draw a 32x32 water tile
in the map, the drawing automatically draws the grass tiles all around the
water tile, like RPG Maker does. Now that i think about it, isn't that called

I'm sorry about the misunderstanding.


I changed the thread title and the post to reflex
more about what i was talking about.

hDC_0 07-23-2012 04:58 PM

Well that's a totally different thing.

So you basically want to automate the placing of tiles more
than the auto-fill tile routines in the last post in the tile threads cited above..

What type of A.I. criteria are you thinking of
for how this auto-tiling is to be done?

For instance - if you place a set of 4 water tiles then does the
grass tiles automatically get placed surrounding them?

Of are you thinking about being able to place a set of tiles as a
group..like a palace or a fort or group of village huts
and then have an "auto-fill wilderness" button to wrap different
forest and grass tiles around the center cluster of tiles.

Or perhaps you are worrying about "blending" of the autotiling?
I heard it can be an issue with tile sets in RPGMaker.

VB_Alien 07-23-2012 05:09 PM

At this point, i'm not sure of anything. I'm just trying
to pick some brains here to see if anyone has ever
attempted this in vb before. I've never seen it done

I don't think an A.I. would be used in this case but
maybe more like an algorithm. I'm just guessing though.

Much like RPG Maker, the tiles used as auto tiles would
probably be limited to about 4 maybe 5. Grass, water,
snow, forest.

I know this would be a heavy duty subject to try and explain
so it would be nice if anyone knows of any simple vb projects
that have tried to use this feature in game tiling or maybe a
tutorial somewhere.

hDC_0 07-23-2012 05:11 PM

auto-tiling theory algorithm and some rpgmaker-like source code
Have you seen:
CodeProject: Implementing Auto-tiling Functionality in a Tile Map Editor
..which attempts to give some of the theory/algorithm behind the type of auto-tiling that RPGMaker does..

I remember that was a once a discussion of an "Auto Tile orientor"..
Here is my bookmark for that old thread.

I think the biggest issue is getting the sub-
images of the tile sheet to line up with the script.

That's all I got..I certainly haven't looked at the source code for RPGMaker to know
exactly how it works internally..but someone did try to create something called the: "RPG Maker 20XX Engine".

There is some auto tile code C++ code inside the "wcmapdraw.h" file here,
but this code seems more oriented to emulating the rpgmaker player (RPG_RT.exe)
than the editor.
The whole thing can be downloaded as a C++ solution here.

VB_Alien 07-23-2012 10:37 PM

I've already seen most of what you posted, except for
a couple of links and those really made no sense to me.

I've seen the Code Project one before to. I really don't
understand what it is trying to tell me but maybe i should
just buckle down and study a little harder on it.

I'd like to eventually see a demo of auto tiling posted
here, either by me or someone else. I know there are
people wanting to know how this is done, but no one
wants to invest the time it would take to learn how to
do it from scratch....

This is going to be a big learning curve because, once
someone learns how to correctly draw the auto tiles,
then they will need to learn how to save the map a little
bit differently, unless the auto tiling is strictly an algorithm
process that happens as you load the map. I've got lots to
learn i guess.

Thanks for your help, hDC....

VB_Alien 07-31-2012 12:32 AM

3 Attachment(s)
I was trying my hand at auto tiling but i was stopped real
quick. The tiles that i am using are from RPG Maker VX.
The tiles in the editor are 32 x 32. When placing a tile in
the game map area:

1: Referring to the darker blue water tile that is automatically
drawn on a blank map, if you lay out some grassy area and then
right click on that dark blue water tile and place it on the grassy
area, the tile is not the same one you just copied.

2: After you lay a tile, a border is drawn around that tile. The
tile you layed is 32 x 32 and with the border, it's around a
40 x 40 tile altogether.

Question is, where did that border come from? I can't find any
tile that is bigger than a 32 x 32 and i have all the new VX game

I'll attach 3 images of what i'm talking about.

The first image "Sample1" is a snapshot of the map editor drawing
area of the RPGMake VX. To the right are ocean tiles and to the left
are grass tiles. In the grassy area, you'll see two single drawings of
the ocean tiles. Looking at the bottom one, you can see the tile selector
square. It is 32 x 32 and then you see the border around that. Where did
the border come from?

The next image "Sample2" are all the water tiles, as seen in the editor.

The next image "TileA1" are the first set of the original tiles that come
with RPGMaker VX.

These are the only water tiles that the editor offers.

hDC_0 07-31-2012 11:44 AM

missing autotile code

Originally Posted by VB_Alien
1: Referring to the darker blue water tile that is automatically
drawn on a blank map, if you lay out some grassy area and then
right click on that dark blue water tile and place it on the grassy
area, the tile is not the same one you just copied.

2: After you lay a tile, a border is drawn around that tile. The
tile you layed is 32 x 32 and with the border, it's around a
40 x 40 tile altogether.

Question is, where did that border come from? I can't find any
tile that is bigger than a 32 x 32 and i have all the new VX game

Where did the border come from?, you ask..
Probably from something you are doing in you autotile code?

However since you haven't shown any code it's a mystery
as to exactly what in your code might be causing this..

passel 07-31-2012 01:43 PM

It's not from his code, it's a screenshot from RPGMaker VX.
And I thought this effect is what you were referring to from the start.

When two dissembler tiles abut one another, code is run to auto generate texture to blend/blur the edges of the two tiles so you don’t have a sharp line transition between the tile edges.
There are a number of ways this can be done. One of the simpler is have pre-canned combo textures for all combinations that can be placed next to each other and painting that along the edge.
But if you have many combinations, rather than pre-generate and store all possible combinations, the border texture may be generated on the fly when the two tiles are next to each other by shifting and fading, portions of the tile along the edge.

surfR2911 07-31-2012 03:03 PM

fading = alpha fading?

Originally Posted by passel
..the border texture may be generated on the fly when the two tiles are next to each other by..fading, portions of the tile along the edge

We are talking alpha fading - probably by the use of some color matrix code, right?
Page 2 of the Viewer thread does have some alpha fading examples.

I hate threads that are mostly theoretically and don't have much in the way of code examples.

The CodeProject AutoTile link that hDC_0 linked to back in post #6 of this thread is not all theoretical though.
The author, Colin Vella, did post his tIDE code (even though it's not VB.Net code).

passel 07-31-2012 03:16 PM

I wouldn't necessarily assume alpha fading.
I haven't read a lot of the links that closely, but I believe there are various techniques discussed that one may use, such as interleaving pixels, or manually combining the pixels through some other process.
Since it is already covered in the links, I wasn't going to speculate on any particular method.

VB_Alien 07-31-2012 04:13 PM

Ya. All the sample images came from RPGMaker VX. I haven't
done any coding yet. I can't code, if i know nothing of the
process, which is why i am here.

So maybe what passel is talking about is tile transitioning, at least
in part. This is a process that blends two different tiles (water to grass)
together, so that straight lines are removed. The tiles are feathered together
sort of.

The rest of it probably is like what passel described to. Auto-generated textures,
It's the only thing that makes sense.

There is a lot of tile shifting when using RPGMaker. That first water tile that i
supplied, has very little water in it but when you start placing them on grass
tiles, it creates more water with borders where they belong.

Maybe this project is best left to the experts. This is way over my head.

Thanks for the information guys. It really helped me understand how the process
of auto-tiling works.

VB_Alien 05-25-2013 09:48 AM

1 Attachment(s)
Opps. Forgot to post the zip file.

VB_Alien 05-25-2013 09:54 AM

Some how, i screwed up my post. I got the cart before the
horse, so to speak.

As you can see, i have already posted a zip file, that contains
the javascript source code that contains the rpg maker vx code
on how to do auto tiling.

I was hoping if someone that is able to, to please convert this
java script to c# or vb.net, if possible.

Here's the web site.

Auto-tiling algorithm for RPG Maker VX tile set

You can also download the code, by clicking on a
download button, at the bottom of that page.

Any help would be appreciated.

ephestion 07-16-2013 12:29 PM

I would probably go with Map templates with randomised variables. Much better than pure random and better than one standard way of producing maps.

Dungeons and walls would probably need hardcoding since you will need to ensure they close properly and have doorways. Open area maps can be script based. For example you have a text or xml file with a format similar to this:

//Player Startup Objects
Player Sprite
Player Location (specific or variable +- 5 tiles)
Place Player On (Grass, Mountain, Walkable, or any other tile specs you want to define.)

//Land Fill
Base Land (First Layer, Water or Grass or other)
Player Start Base (Some template to draw a starting town or village or outland area on which player starts...may inlcude hardcoded things like preset encounters, tavern, inn etc.)
Player Avoids (Trees, Unwalkables, Water, buildings or any other class you defined for your tiles.)

//Place terrain
Place Terrain Objects X On (Base Land/Water, trees, grass etc)

//Create Rooms
Area To Turn To Building (Define a Rectangle or select tiles to be used for buildings)
Enclose Building (a method fires to draw all around the tiles needed)
Make Exits On Walls X (Where X can be Number of Doors min to add to walls)

You can also use your pathfinding procedure to outline a particular path you want kept clear and the rest of teh specified area can be filled with walls, doors and items.

Script like this are used in Random Map Generation for games like Empire Earth, Age Of Empires and Age of Mythology series.

An Alternative is just have template blocks of say 5 x 5 tiles of predefined things. Like a 5x5 Village, A 5x5 Forest area with a small path, a 5x5 Dungeon and all these are added upto the number of tiles wide and high you want to append them. If entire map is 25x25 tiles then you place 5 (5x5) chunks randomly together or base don some % chance.

All times are GMT -6. The time now is 05:28 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.