Gap while drawing a map
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Gap while drawing a map
H-hello all.
I've been trying to make a map using Diamond and Square algorithm and all is looking great...
but
it seems there's a gap in the map. Now, from what I've observed the map is full from 1->257 on both [x] and [y]. I even filled the small hole gaps, which come up at every corner (result of my diamond square) so they would be water.
When I click the blank strip and convert the position to the tile grid it says a tile is there but it doesn't draw . Plus my pathfinding (gets the best immediate tile to move to) (edit:almost) never allows any "person" to go past that blank strip, but A* pathfinding moves them past there (though is troublesome in obstacles here, hence my way).
(y zooms in, a zooms out?)
Anyone know the cause of these black strips?
I've been trying to make a map using Diamond and Square algorithm and all is looking great...
but
it seems there's a gap in the map. Now, from what I've observed the map is full from 1->257 on both [x] and [y]. I even filled the small hole gaps, which come up at every corner (result of my diamond square) so they would be water.
When I click the blank strip and convert the position to the tile grid it says a tile is there but it doesn't draw . Plus my pathfinding (gets the best immediate tile to move to) (edit:almost) never allows any "person" to go past that blank strip, but A* pathfinding moves them past there (though is troublesome in obstacles here, hence my way).
(y zooms in, a zooms out?)
Anyone know the cause of these black strips?
- Attachments
-
- lovegaem.love
- (661.3 KiB) Downloaded 188 times
Re: Gap while drawing a map
Code: Select all
$ find . -iname '*.lua' | xargs wc -l -c | tail -n 1
48894 1447663 total
Can you give a simple test case that reproduces the problem?
Re: Gap while drawing a map
This things cannot go through this black line:
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Re: Gap while drawing a map
Oh, sorry. The main enchilada is in maps/map.lua. Pathfinding is in entities/person.lua. For maps only map.lua is everythingnthere is to get, most of the other files are redundant.
What I use for drawing on to canvas (most likely not helpful):
Running it reproduces the event, I don't even know what causes it. Whether I draw onto a canvas or not (not using one slows down the project) the black strips appear. And what's strange is that sometimes the people can go through black lines.
What I use for drawing on to canvas (most likely not helpful):
Code: Select all
function Map:drawTile(tx, ty, x, y)
local cc = self.grid[tx] and self.grid[tx][ty] and self.grid[tx][ty] or nil
if cc then --log("!!tile "..tx..","..ty)
local i = cc.type.source
local c = cc.value
if c > 1 then
c = 1
elseif c < 0 then
c = 0
end
if type(i)~="table" then
i = {i}
end
for ox, ii in ipairs(i) do
local image = self:getImage(ii)
local _w, _h = resizeImage(image, rez, rez)
love.graphics.draw(image, x*rez, y*rez, 0, _w, _h)
--love.graphics.setColor(get_color(c^2))
end
if rez > 1 then
-- love.graphics.rectangle("fill", rez*x, rez*y, rez, rez)
else
--love.graphics.points(x, y)
end
return true
else
error("no tile"..tx..","..ty)
end
end
local speed = 100
function Map:drawMapOnCanvas()
love.graphics.setCanvas(self.canvas)
self:drawMap()
love.graphics.setCanvas()
end
Re: Gap while drawing a map
Can you check if tiles in the black lines really exist and/or available for reading?
Re: Gap while drawing a map
Can you make an example that runs, only includes the minimal set of files, and shows the problem?
I've tried this but it gives an error because map.chunks is not defined, and I have no idea how to initialize it:
I've tried this but it gives an error because map.chunks is not defined, and I have no idea how to initialize it:
Code: Select all
class = require 'tools.src.rot.class'
local Map = require 'maps.map'
map = Map:new()
map:load()
function love.draw()
map:drawMap()
end
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Re: Gap while drawing a map
Yes,they are there. I did a test where I touch the black strips and convert the touch to tiles, but it said tiles where there.
map:load() is called in initialization, so maybe the problem lies that it's called twice. (Also, I use "maps/map" in require but I don't know what the difference is).pgimeno wrote: ↑Mon Aug 23, 2021 2:39 pm Can you make an example that runs, only includes the minimal set of files, and shows the problem?
I've tried this but it gives an error because map.chunks is not defined, and I have no idea how to initialize it:Code: Select all
class = require 'tools.src.rot.class' local Map = require 'maps.map' map = Map:new() map:load() function love.draw() map:drawMap() end
Here is the example with limited files:
- Attachments
-
- gaem.love
- (236.37 KiB) Downloaded 171 times
Re: Gap while drawing a map
The difference is that the dot is standard, while the slash is system-dependent. Löve uses PhysFS, and path separators in PhysFS require a slash, but Lua in general doesn't use PhysFS, and in order to future-proof it, it uses dots as separators of modules, Python-style. If a new system appears where the slash is not a valid path separator, Lua will be ready by using dot as an abstraction over path separators, and PhysFS will be ready by using a slash, but if you wrote a non-Löve Lua program and you used a slash, your program won't be ready to run on it. For example, I've heard VMS uses a colon as separator, and a slash won't work on it.Gunroar:Cannon() wrote: ↑Mon Aug 23, 2021 6:52 pm map:load() is called in initialization, so maybe the problem lies that it's called twice. (Also, I use "maps/map" in require but I don't know what the difference is).
Also, some libs do depend on a dot as a separator (e.g. in order to require its own files); yet I have not found any library that depends on using a slash.
Well, that's not what I call minimal, but it's a start. Here's my shortened main.lua version that lets me focus on where the meat is:
Code: Select all
function log() end
class = require 'tools.class'
require 'tools.tools'
lume = require 'tools.lume'
Camera = require 'tools.camera'
Tile = require "entities.tile"
Map = require "maps.map"
local map = Map:new({})
function love.draw()
map:drawMap()
end
Code: Select all
function Map:buildTown(x,y)
local town = --[[Town:new]]({
...
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Re: Gap while drawing a map
Dang, pgimeno, you're like a master detective . So darkfrei was right about the tiles being missing...? I knew it! The one time I decide to use ipairs, never again!pgimeno wrote: ↑Mon Aug 23, 2021 10:12 pm With that, I had better weapons. The direct cause for the black lines was that Map.grid[33][1] was nil, and in general, Map.grid[x][1] for all x where a black line appears (1, 33, 65, 97, ...). This causes the Y loop of Map:drawMap() to terminate early.
Something's fishy with your diamond/square implementation.
That really helped narrow down the problem.
1) It seemed that I made the start one, instead of zero, so I changed that: But the result is now: It seems those strips are still blank but I've forced them to be water by force in a loop that I coded previously....
- Gunroar:Cannon()
- Party member
- Posts: 1088
- Joined: Thu Dec 10, 2020 1:57 am
Re: Gap while drawing a map
2) HEY, I'M NOT CRAZY. .So when I change chunk_size to the "proper" value(self.chunk_size=self.map_size-1, I think) it works, as opposed to my way of self.chunk_size=2^self.res,where self.res is 5 instead of 8, it worked before, I'm not crazy )
I just can't seem to spot what is making things like this!?
Edit: So it seems that what's making it are the empty dots in the map, removed ipairs completely so that they don't stop the flow. I'll just deal with the empty dots by making them the average value of their neighbours
That makes a zoomed out version:
Where there are blocks of water(forced water, so they used to be empty) at the bottom of the map. These blocks are also in the other chunk_size=2^res version.
I just can't seem to spot what is making things like this!?
Edit: So it seems that what's making it are the empty dots in the map, removed ipairs completely so that they don't stop the flow. I'll just deal with the empty dots by making them the average value of their neighbours
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 26 guests