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

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
sladjkf
Prole
Posts: 18
Joined: Mon Mar 02, 2015 7:18 pm

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

Post 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
Attachments
my thing.love
(904.72 KiB) Downloaded 178 times
User avatar
sladjkf
Prole
Posts: 18
Joined: Mon Mar 02, 2015 7:18 pm

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

Post by sladjkf »

also forgot to mention exactly what my problem is, sorry. This should explain it
Image
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

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

Post 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.
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

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

Post 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.
User avatar
sladjkf
Prole
Posts: 18
Joined: Mon Mar 02, 2015 7:18 pm

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

Post 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.
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

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

Post 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.
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

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

Post 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.
Attachments
my thing with walls.love
(904.79 KiB) Downloaded 160 times
Artal, A .PSD loader: https://github.com/EvineDev/Artal
User avatar
sladjkf
Prole
Posts: 18
Joined: Mon Mar 02, 2015 7:18 pm

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

Post 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?
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

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

Post 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?
User avatar
sladjkf
Prole
Posts: 18
Joined: Mon Mar 02, 2015 7:18 pm

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests