My Adventure Game Engine - Making Way For Adventure Engine 2
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Zelda style adventure engine progress thread
Have you tried reading the map bit by bit? You know, read n tiles, go on with update()ing and draw()ing, read n tiles, etcetera.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Zelda style adventure engine progress thread
Doesn't quite work that way.
Once it enters the for lines in file loop it won't return control until it's done.
I know it's not the most optimized way to do it. It's all the filesystem loading that causes the pause. The longest delay is the for lines in file loop. Everything else is fast enough. And while it's in the loadMap function, the draw function doesn't even get called at all so it's not like I can draw the words "loading" on the screen or anything.
Gonna do some tests. See how fast it takes to load 100 characters, 1000 characters, 10000, 100000 and 1000000 and compare the results.
Once it enters the for lines in file loop it won't return control until it's done.
Code: Select all
function loadMap(m)
local mFile = "maps/" .. tostring(m) .. ".map"
if love.filesystem.exists(mFile) then
local i = 0
local mD = {}
for line in love.filesystem.lines(mFile) do
mD[i] = line
i = i + 1
end
mapHeight = i * 32
mapWidth = math.floor((tonumber(string.len(mD[1]))+1) / 22) * 32
for x=0,mapWidth/32-1 do
for y=0,mapHeight/32-1 do
mapTiles[x][y] = string.sub(mD[y], (x * 22) + 1, (x * 22) + 4)
mapDeco1[x][y] = string.sub(mD[y], (x * 22) + 5, (x * 22) + 8)
mapDeco2[x][y] = string.sub(mD[y], (x * 22) + 9, (x * 22) + 12)
mapDeco3[x][y] = string.sub(mD[y], (x * 22) + 13, (x * 22) + 16)
mapDeco4[x][y] = string.sub(mD[y], (x * 22) + 17, (x * 22) + 20)
mapHit[x][y] = string.sub(mD[y], (x * 22) + 21, (x * 22) + 21)
mapHitN[x][y] = string.sub(mD[y], (x * 22) + 22, (x * 22) + 22)
end
end
else
error("Oops! It seems you are missing a certain map file.\nThe map \"" .. mFile .. "\" seems to be missing from its home.\nOr maybe your character has wandered into uncharted territory.")
end
end
Gonna do some tests. See how fast it takes to load 100 characters, 1000 characters, 10000, 100000 and 1000000 and compare the results.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Zelda style adventure engine progress thread
My findings with loading large files via love.filesystem.lines():
A 250x250 map has about 1.3 million characters. Currently. Using 22 chars per tile.
Code: Select all
Characters Time in Seconds
1,000 0.00103759765625
10,000 0.01397705078125
100,000 0.12103271484375
1,000,000 1.2219848632812
10,000,000 12.185974121094
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Zelda style adventure engine progress thread
Well, I think it would be possible to use the iterator lines(mFile) returns to load a line every frame, and set a flag when it's done, so the parsing can start (or maybe just check whether lastline == nil?)Jasoco wrote:Once it enters the for lines in file loop it won't return control until it's done.
That would require a major rewrite of your map loading code though, because it has to be placed in update() (or update has to call loadmap() as long as the map isn't loaded.)
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Zelda style adventure engine progress thread
There's really no reason though since most maps are gonna be so small they load in a blink anyway. Having an entire world in one map is nice, but it's not really optimal unless you're doing Sim City. (I wonder, how many tiles in width and height was the biggest Sim City map area?
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: My Zelda style adventure engine progress thread
Sim City always took a long time to load though, so it might be an unfair comparison.
Reticulating Splines
Reticulating Splines
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Zelda style adventure engine progress thread
Sim City has other problems, loading level map grids is the least of its loading. It also had to load many megabytes of images and other data. Plus it was a lot slower system.
It is a fair comparison, because Sim City is the only time you see a map grid that size. Other games just break maps down into smaller bite-size chunks.
It is a fair comparison, because Sim City is the only time you see a map grid that size. Other games just break maps down into smaller bite-size chunks.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: My Zelda style adventure engine progress thread
OK, I didn't thought of that. If you have small maps anyway, there is no reason to mess around with the map loading.Jasoco wrote:There's really no reason though since most maps are gonna be so small they load in a blink anyway.
Help us help you: attach a .love.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: My Zelda style adventure engine progress thread
Games like GTA and Oblivion use sophisticated routines for loading stuff in at runtime. They rely on the ability to reach into a map file/database and grab a specific set of variables from a specific area in the file/database. Which is a huge array of data. X, Y, Z points, image definitions and position data. A lot of stuff. Games like that have inline map loading. The small starting area is loaded at startup, then more areas are loaded as you run around depending on where you go.
With work, I could in theory set up my game to have seamless loading of levels, but really, I'm not that big on it. I mean it'd be cool. But too much for me.
With work, I could in theory set up my game to have seamless loading of levels, but really, I'm not that big on it. I mean it'd be cool. But too much for me.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: My Zelda style adventure engine progress thread
This still seems weird, can it be that big? Anyway, you might load only portions of the map, which means longer loading times in-game, but also way better memory usage.
Who is online
Users browsing this forum: No registered users and 4 guests