New answers tagged tiles
1
You need to create polygons to check for collisions and check them every step in updating the position. I found example in the internet and try translate comments to English.
You can download example.
Other way is creating collision map, like this
P.S. Sorry for Google-translate.
4
This guide didn't exist when the question was asked, but here's my guide to hex grid math:
Hexagonal Grids
0
I usually have an array of solid tiles and a function to check collisions against them.
function inArray(needle, haystack) {
for (var key in haystack) {
if (haystack[key] == needle) {
return true;
}
}
return false;
}
var solidTiles = [3, 6, 14];
function (isSolidTile(x, y) { //x and y are pixel coordinates, not tile ...
0
You can actually do this without A*. I did this on a hex grid using recursion but the premise is the same.
You start at your characters current position with the set number of moves. then move outward in all directions reducing the number of moves by the amount of moves required to enter that square. Then repeat for each square you entered.
One thing to ...
2
A* is for finding the shortest path from vert a to vert b. Its not a good fit for finding all verts x distance from vert a.
A Depth First Search (DFS) should be suitable for your problem and very cheep on both memory and clock cycles. There is another basic search algorithm called the Breadth First Search (BFS) that would run at similar speeds but uses ...
0
If I read it right try checking the center 9px for an alpha color. If there is not that much deviation you probably need to split your 32px sprites into 4 16px sprites.
The center 9 being
x-1, y-1 :x, y-1 :x+1, y-1
x-1, y :x, y :x+1, y
x-1, y+1 :x, y+1 :x+1, y+1
where x,y = top+16,left+16
1
This is very much something that I would hard-code. If there were fewer tiles, I'd be tempted to simply hard-code the rectangles for each tile. But in this case, you can hard-code the regions and do a bit of maths to get the rectangles for individual tiles:
public static class TilesetInfo
{
private static Rectangle TileInRegion(int regionX, int regionY,
...
0
Leandro, you can simply use Tiled and a tmx map loader for XNA. Tiled will load your tileset image and split it into several different tiles, allowing you to visually create your map without coding. Then, you'll use the tmx map loader to import the map into your game.
Tiled: http://www.mapeditor.org/
TMX Map Loader for XNA and other resources: ...
Top 50 recent answers are included