Page 1 of 1

Hi, i don't really know how to solve my problem

Posted: Fri May 08, 2015 9:28 pm
by sladjkf
So, to quickly explain things:

I'm making a topdown kinda game, and there are solid tiles in it, of course. I'm using love.physics for collision detection/resolution.
I made an algorithmy thing that looks through the map and adds EdgeShapes (for the border of the solid tiles, i'm using EdgeShapes to avoid the "crack" collision problem).

The problem here is that my algorithmy thing isn't working right, and I have no idea why. To me, everything in it seems structurally sound. I can't tell why it wouldn't work.

the "algorithmy thing" in question is tile_alg_1/tile_alg_2 in walls.lua, by the way

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 1:12 am
by sladjkf
also forgot to mention exactly what my problem is, sorry. This should explain it
Image

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 10:08 am
by cohadar
I recommend you make an "overkill" algorithm for this.
You add 4 edge shapes on every wall tile (even inside walls)
And after that a prune algorithm that removes unnecessary edges inside walls.

Sometimes it does not pay to be too smart with algorithms.

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 10:18 am
by bobbyjones
Using edgeshapes wouldn't be the best idea if I'm not mistaken if it has low DT or high speed I think. It would just jump right pass them. A polygon shape would be better. I think an algorithm to convert the tiles into polygons would be the best.

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 5:30 pm
by sladjkf
cohadar wrote:I recommend you make an "overkill" algorithm for this.
You add 4 edge shapes on every wall tile (even inside walls)
And after that a prune algorithm that removes unnecessary edges inside walls.

Sometimes it does not pay to be too smart with algorithms.
Tried that. It's alg_3 in my walls.lua. It encountered a similar problem.
bobbyjones wrote:Using edgeshapes wouldn't be the best idea if I'm not mistaken if it has low DT or high speed I think. It would just jump right pass them. A polygon shape would be better. I think an algorithm to convert the tiles into polygons would be the best.
Tried that as well. I'm not using polygon shapes to avoid the "crack" collision problem. I remember reading something about ghost vertices, but just figured that EdgeShapes would be easier to deal with.

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 6:08 pm
by cohadar
I donwloaded the code and took a serious look.
ALL your algorithms are correct.
Your error is in iteration:

Code: Select all

	for y_index,value in ipairs(map) do
	 	for x_index,tile in ipairs(value) do
EDIT:
to be more precise your tile data is not correct.
previous algorithm for detecting which walls are invisible (tile == 0) is not correct.

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 6:52 pm
by Evine
There is something wrong with "map_generator.lua" You place non wall segments where there should have been a wall.

The .love I've added now draws red walls instead when map[x][y] == 1. I've also made the math.randomseed(10) so I don't have to go looking for broken wall segment each time.

Re: Hi, i don't really know how to solve my problem

Posted: Sat May 09, 2015 11:37 pm
by sladjkf
cohadar wrote:I donwloaded the code and took a serious look.
ALL your algorithms are correct.
Your error is in iteration:

Code: Select all

	for y_index,value in ipairs(map) do
	 	for x_index,tile in ipairs(value) do
EDIT:
to be more precise your tile data is not correct.
previous algorithm for detecting which walls are invisible (tile == 0) is not correct.
I apologize, I don't quite understand what you mean. What do you mean by tile data is not correct and detecting which walls are invisible (tile == 0) is not correct?

Re: Hi, i don't really know how to solve my problem

Posted: Sun May 10, 2015 5:06 am
by cohadar
tile types in your map:
[0]walls that are inside/invisible
[1]walls visible by player (adjecent to floor tiles)
[2]floor tiles

To "see" what I mean, turn on alg_3 than instead of this:

Code: Select all

function tile_alg_3(tile,objects,x_index,y_index)
	if tile == 1 then
do this:

Code: Select all

function tile_alg_3(tile,objects,x_index,y_index)
	if tile < 2 then
take a look, and ask yourself, why is it working now?

Re: Hi, i don't really know how to solve my problem

Posted: Sun May 10, 2015 6:57 pm
by sladjkf
Haha. I can't believe it. I forgot about the 0's. Thank you so so much. I've been having this problem for so long.