Tile game: Getting stuck between tiles

Hello forums,
I am currently trying to create a tile game with Box2D.
There is a two dimensional array, that holds the information for the map (as integers representing the tile's type), which is then interpreted and corresponding actors are created, each containing a b2Body.
Now I sometimes got the problem to get stuck with the player over crossing tiles (he is controlled using ApplyForce on the x-axis while there is gravity downwards). This appears to happen only, if the speed is too low, so I think that it has to do with the tiny gaps between the tiles.
What's a good way to fix that getting stuck?
I haven't been searching thoroughly enough. Found a solution: http://www.box2d.org/forum/viewtopic.php?f=3&t=3117&p=15281#p15281
It suggests to make 'clusters' of adjacent tiles, which I'm currently trying to implement. If someone has an idea on how to search for these groups within the array and form an according edge shape, I'd be happy to listen though. 🙂
OK, I finally managed to get it to work somehow. This script takes a two dimensional Array and finds the groups within, drawing an outline of each tile.
I can't think of a way to find the outline for the groups yet though. Again I would be happy about any input (sorry if I'm too hasty).

Will post again if I found a further solution.

[old script removed]
I've updated the code and it is now able to find corners for the groups though it seems to be a bit buggy. Still it doesn't give you corners in the correct order.

If anyone has an idea, how to get the corners into the correct order please help.
Thanks


I've uploaded a zip containing all the needed files to compile yourself.

EDIT: Removed the source from my post, since it was too long.
From what it looks like to me, your trying to read the array the same way your placing the tiles on the screen.
I haven't looked at your code so I'm not positive. If you are, try reading from left to right or top to bottom.
Also, make sure how your storing the points can be read back in a CCW motion.
Don't forget to take in account for the maximum amount of points allowed per shape.
I think I found a way to get the algorithm to work. The picture below describes it best I think.
It should check the directions in the order given by the numbers following the colors from blue to green to orange. (Of course this only shows the first recursions.)
I'll tell you again when I wrote the solution.
Seems like I found a partly solution.

My current algorithm for sorting corners finds the outline, but it still has a major flaw. Sometimes it has problems finding corners, because it only checks one direction for a point without a limited distance and then the other (see problem_sorted.jpg attached).
I don't know how to make it search for the missing corners.

There's a bug in the corner algorithm too, so not really every corner is found (see problem_unsorted.jpg attached).

I marked the missing corners red on both pictures.

The source is attached, so you can try around and maybe help.
Would be nice if someone could contribute an idea on one of the problems described. 🙂
i don't get why people insist on using a complex physics engine for a game that needs very simple physics.

I have been looking for a game thats a great example of this(can't find it), one of those games where you click the box to remove it and all adjacent like-color boxes, more blocks fall, wash rinse repeat. the problems was that the boxes would get caught on each other and not fall correctly. and frankly, tile-based collision is super easy and efficient.

I'm sorry, I love box2d, it's bringing my paycheck, but i hate games that are overly complex, finicky, and buggy

Edit: I think i should say something productive.
for the outline what if you had TWO 2d arrays of booleans. one array for each horizontal edge formed between 2 tiles and one array for each vertical edge. For each tile you want outlined toggle the index corresponding to each of its edges. with this method adjacent tiles will cancel each other out sense you are toggling them twice. loop through the arrays and draw them if they are true.

for instance:
lets say our game has 1 row and 4 columns. Our verticle array is initialized to
00000
if you have a tile at (0,1)
01100
then (0,2)
01010
the edge between the 2 blocks was toggled twice so its false, when you loop through it isn't drawn

ill right a code because I'm bored/interested in doing this anyways
ok i got it working. i dont know if this will work with you're game but here it is
Code:
var col:int = 9;
var row:int = 6;
var size:int = 50;

var tileList:Array = new Array();
var vEdgeList:Array = new Array();
var hEdgeList:Array = new Array();

var i,j:int
//create array of tiles
for(i = 0; i < col; i++){
   tileList.push(new Array());
   for(j = 0; j < row; j++)
      tileList[i].push(false);
}

//create verticle edge list
for(i = 0; i <= col; i++){
   vEdgeList.push(new Array());
   for(j = 0; j < row; j++)
      vEdgeList[i].push(false);
}

//create horizontal edge list
for(i = 0; i < col; i++){
   hEdgeList.push(new Array());
   for(j = 0; j <= row; j++)
      hEdgeList[i].push(false);
}

function drawTiles():void{
   //draw tiles
   for(i = 0; i < row; i++)
      for(j = 0; j < col; j++){
         graphics.beginFill(tileList[i][j] ? 0x666666 : 0xAAAAAA)
         graphics.drawRect(j*size, i*size, size, size);
      }
   graphics.lineStyle(2,0xFF);
   //draw vertical lines
   for(i = 0; i <= col; i++)
      for(j = 0; j < row; j++)
         if(vEdgeList[i][j]){
            graphics.moveTo(i*size, j*size);
            graphics.lineTo(i*size, (j+1)*size);
         }
         
   //draw horizontal lines
   for(i = 0; i < col; i++)
      for(j = 0; j <= row; j++)
         if(hEdgeList[i][j]){
            graphics.moveTo(i*size, j*size);
            graphics.lineTo((i+1)*size, j*size);
         }
}
function setTile(x:int, y:int, value:Boolean):void{
   if(tileList[x][y] == value) return;//dont switch the same one twice
   tileList[x][y] = value;//change tile
   hEdgeList[y][x]       = !hEdgeList[y][x];//togge top
   hEdgeList[y][x+1]    = !hEdgeList[y][x+1];//bottom
   vEdgeList[y][x]       = !vEdgeList[y][x];//left
   vEdgeList[y+1][x]    = !vEdgeList[y+1][x];//right
}
for(i = 0; i < 15; i++)
   setTile(int(Math.random() * (row-1)), int(Math.random() * (col-1)), true);

drawTiles();
x = y = size;
It is quite hard to do that for a similar with the tiles. You should use a different algorithm from the array. Anyway, I just downloaded the source file for compile it later and test it.

online roulette

Original thread: https://box2d.org/forum/viewtopic.php?t=3456