In an attempt to create a bunch of gridlocked civilians, I came across this problem. It would appear that neither the player nor the NPC can move in a direction previously moved in by the other. I'm sure the solution is obvious, but I can't see it for the life of me.
Any help is appreciated.
FatalMarshmallow
Gridlocked Civilians
-
- Prole
- Posts: 17
- Joined: Mon Jul 30, 2012 9:15 pm
Gridlocked Civilians
- Attachments
-
- Example.love
- 0.8.0
- (5.59 KiB) Downloaded 106 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Gridlocked Civilians
Here's your problem:
This function checks if the player and the NPC can move in that direction. If either can't, neither can. Solution:
Don't forget to replace calls to testMap with ones that include either player or civ as a first argument, depending on which one you're going to move.
Code: Select all
function testMap(x, y)
if map[(civ.grid_y / 32) + y][(civ.grid_x / 32) + x] == 1 then
return false
end
if map[(player.grid_y / 32) + y][(player.grid_x / 32) + x] == 1 then
return false
end
return true
end
Code: Select all
function testMap(obj, x, y)
if map[obj.grid_y / 32 + y][obj.grid_x / 32 + x] == 1 then
return false
end
return true
end
-- or, better yet:
function testMap(obj, x, y)
return map[obj.grid_y / 32 + y][obj.grid_x / 32 + x] ~= 1
end
Help us help you: attach a .love.
Re: Gridlocked Civilians
cant you post in "support & dev" forum instead of the General forum?
-
- Prole
- Posts: 17
- Joined: Mon Jul 30, 2012 9:15 pm
Re: Gridlocked Civilians
Thanks for the help, I'm an idiot.
Also, my bad for posting in general, will double check in future.
Also, my bad for posting in general, will double check in future.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 6 guests