Hot answers tagged tilemap
34
Among the many other related questions on the site, there's an often linked article for map generation: Polygonal Map Generation for Games you can glean some good strategies from that article, but it can't really be used as is.
While not a tutorial, there's an article on how Dwarf fortress world maps are generated. Basically you generate multiple layers of ...
25
"Staggered" refers to the jagged edges of isometric maps that have an overall rectangular shape. These maps emphasize the north/south and west/east axes, and often have North up (example: Civilization 2). Diamond maps on the other hand emphasize the diagonal orientation and movement. North is often at the top right (example: Simcity 2000). Also notice the ...
20
Your question leads you into the field of procedural content generation.
Tile-based world generation derived from continuous/analog methods
By continuous, I means something that is not tiles, something that is analog, an example being a vectorised map. You can use any continuous technique for generation, and then quantise it. For example generate a high ...
18
Yes, they use tilemaps (more precisely : small 8x8 hardware tiles). The main reason is that background scrolling and sprites display on most 16-bit consoles are hardware accelerated (there is a dedicated hardware chip for that, VDP in case of genesis). The only way to use that feature on genesis is to divide the background and sprites into small 8x8 tiles ...
15
What you've noticed is the difference between a random number generator and a noise function. A random number generator spits out a different number each time you call it. A noise function takes some arguments - say, a map x and y - and spits out numbers with random-like statistical properties, but the same value for the same arguments every time, i.e. it is ...
13
While the other answers here are really good for generating the kinds of static landscapes that would work for this specific need. There are other methods that people coming across this question might be looking for if they want to create landscapes that change over time or appear much more realistic you can follow this technique.
Unlike the other answers ...
11
Maybe this is how it's typically done. You have your list of different tiles that represent a road tiles in all their possible orientations. Left to right, all four corners, top to bottom, whatever. Now you'll index all those tiles with a byte each. 8 bits, one for each direction. This could be in a hashmap or by file name... however you want to do this.
So ...
10
You can use Perlin Noise for the generation of the terrain, here is how the biomes in Minecraft work.
As you can see he uses a heatmap in combination with a rainmap to create the biomes.
9
You can generate the optimal path using A*, then distort it with midpoint displacement.
This will ensure your endpoints are met and allow you to control the randomness to a great degree. For example, I would not randomize roads as much as rivers. Whatever intelligence is building roads typically attempts to be optimal about it.
Take care to ensure that ...
8
If your argument against an array is "The world will be huge", then it's not about the data-structure, but rather about memory constraints. If your world is so large, that it doesn't fit into memory with a 2D array, then it won't fit into any other data-structure.
Instead you would have to implement a (file-)format, that allows loading chunks (or sectors) ...
8
First of all and to clarify, do you require it to be completely top-down or do you consider something like this as being top-down too. In that example you can tell that the house is much taller than the barrel simply by the amount of tiles that they both span vertically. Also, allowing the character to move behind the objects is another good way to let the ...
8
Hopefully you have solved this yourself by now, if not here is some help to get you there.
Debugger
That program you're using to type all your code in to? It's not just for typing code in and pressing "play". It's an IDE (Integrated Development Environment). This means it contains many tools to help you develop, one of those tools is the debugger. I ...
7
Like Byte56 suggested, rather than fix the collision, you simply doesn't allow the collision to happen in the first place.
Here's a snippet of how my engine handles it
// Reset flags just like you do.
this.IsPushingLeft = false;
this.IsPushingRight = false;
// verticalWall is just a struct containing all the common data for whatever wall of tiles the ...
6
It sounds like most of your cells are unoccupied.
You can dramatically reduce memory if you store only occupied cells; this is termed "sparse" and is straightforward using a simple run-length-encoding (RLE) scheme (the runs of occupied and unoccupied cells are length-encoded).
For example, you could have an array of block instances:
Block[] blocks; // ...
6
A map editor of some sort is what you are going to need (and want!) when your game moves more to the level design phase from the initial engine/coding phase.
If you are using any kind of map/level editor, you will need to code a class (or set of classes) that can:
Read/Input the Data
Translate the data into actual objects (and sets of objects). Your tiles ...
6
I would go for the pseudo-3d approach and visualize the height with a vertical offset. To avoid the problem that parts of the map are concealed by cliffs, I would only use a few pixels per height level and avoid having differences of more than 4 or 5 levels.
As you can see from this mockup, this is good for visualizing that the tile to the north is higher ...
6
Games of that age had to make use of very constrained memory. The Sega Genesis had only 64kb of video ram and only a few MB of ROM per game cartridge. They simply hadn't got the resources for large bitmaps. So they used tilemaps whenever possible and reserved large images for special occasions (boss fights or other memorable key areas of the game).
5
I would never recommend having one large image. One large image will make changing and creating levels very tedious.
In my tile engine, I draw all the tiles to a separate screensized render target, and reuse that render target as the player moves around in the world, only drawing tiles as they enter the screen. This all happens in the background. I then use ...
5
First, You've got your rows and columns backwards:
row = Math.ceil(height / tile.height); //number of rows
column = Math.ceil(width / tile.width); //number of columns
Then, there's a couple different ways to cycle through the tiles, depending on how you want the spaces to be indexed (if this is merely for background purposes, then it's not that important, ...
5
First of your problem is that you're not looking in a further perspective. The ball blocks itself on a wall - just move it 0.5 pixels away. Why not try to unblock it instead? Later you treat a corner like a circle (do you mean a point? If not, I don't understand the idea and it makes me dizzy when I try).
It's OK to do quick, dirty fixes and try if they ...
5
First off, you should be storing all the tiles in a normal square grid. This will make tasks like this a no-brainer. The only place your tiles should actually be diamond shaped is on screen. Any selections on screen utilize a screenToWorld(x,y) function and any world drawing uses a worldToScreen(x,y) function. Then you can easily take your two points from ...
5
What you are asking for is completely doable, as you initially wanted: 3d on 2d. You just got the camera angle wrong. For CG cameras, the perspective is almost always linear (as opposed to say, fish-eye) so all you need to do is have the camera looking straight down.
The best example I can think of is the early GTA games, which had simple 3D models for the ...
5
Most 2D tile-based games use arrays (of some sort) to describe the map. If you assign each type of tile (grass, path, tree, house, water etc.) a numeric index, you can describe your map like so:
[2][1][1][1][1]
[2][2][1][1][1]
[1][1][1][1][1]
[1][1][1][3][1]
[1][1][1][1][1]
(1 = grass; 2 = tree; 3 = house) = a 5x5 map with three trees clustered top-left ...
4
This bit:
public void moveTo(int x, int y){
while(this.position[0]!=x && this.position[1]!=y){
if(this.position[0]<x){
this.position[0]++;
}
if(this.position[1]<y){
this.position[1]++;
}
}
}
Is the crux of your problem. You have to think about game programming in a ...
4
Procedural generation is an immense topic. How deep are you willing to go?
Nick Wiggill's answers are top-notch. I'd add to that by suggesting that you look at some mathematical methods of creating coherent random terrain.
Perlin noise offers a great way to create smoothed randomness, and works great for all sorts of terrain.
Simulating erosion can give a ...
4
Your collision detection is slow because you're checking for collisions between every bullet and every block, even if they're nowhere near one another. You should implement a space-partitioning scheme such as a quadtree. This will greatly minimize the number of potential collisions you have to detect, and should keep things at a playable speed.
Here's an ...
4
On the one hand, your distinction between internal and external transitions looks like kind of a false dichotomy to me. In both cases what you have is tiles depicting a transition from two types of terrain, say sand and water. The only difference is how much sand is depicted vs. how much water. That isn't any sort of technical distinction, just a difference ...
4
This: http://30.media.tumblr.com/tumblr_m06qv6OREt1r2qjpao1_500.png is an example of a map I've done some time ago.
I had a XML representing the map and different types of tiles. Each type would have a few attributes:
Height
Position
Merge Type: Which kind of merging this tile would do, ALL (if it should merge to any tile around it), EQUAL (only merge ...
4
There is no "best overall". This is where the prohibition about premature optimization comes from; neither method is likely going to impact your performance in any measurable way.
Personally, I wouldn't make buildings tiles at all; they should be sprites. Technically, they are a modified form of unit. This allows them to act like units in meaningful ways. ...
4
It's been a while since I used C#, but I think you can structure your class something like this:
public static class Tile {
public static enum TileType {
Air,
Stone
}
public static bool IsSolid(TileType tile) {
switch(tile) {
case Air:
return false;
case Stone:
...
Only top voted, non community-wiki answers of a minimum length are eligible

