ENIGMA Development Environment
Website is in read-only mode due to a recent attack.

Pages: 1
  Print  
Author Topic: Map loading  (Read 1946 times)
Offline (Unknown gender) Game_boy
Posted on: April 07, 2010, 07:59:39 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
This is for a GM project of mine, a Pokémon clone.

It's stalled because the map loading is extremely slow and my attempts to optimise it fail.

The map data is currently made by an external level editor (also mine) and written to a file using a DLL as bytes representing kinds of tiles and collision state (walk-through or not) for each 16x16 square. The world map is a collection of 32x32 of these squares as a 'level', and then these levels are dynamically loaded as you walk around so there is a seamless world but it only has loaded the level you're on and the four adjacent levels at any one instant.

It currently reads the bytes from the file using a DLL line-by-line and creates their associated tiles when it's loaded a line of data. When you're no longer adjacent to a level it discards that data and the objects/tiles belongng to it. If it hasn't fully loaded a level by the time you reach the boundary then the game pauses until it has so that you never see the unloaded levels.

I currently get fractions of an FPS when walking around.

So, in i) GM and ii) Enigma, what would be a better way of handling map data? I can modify the level editor's output and the game's handling of those files however is necessary, and I care only about speed and that the player never sees unloaded data.

Thanks.
Logged
Offline (Male) retep998
Reply #1 Posted on: April 07, 2010, 08:02:14 AM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Stick the loading into a thread.
Make it load several rows beyond the edge of the screen.
Presto, your fps becomes magically faster.
Logged
Offline (Unknown gender) Game_boy
Reply #2 Posted on: April 07, 2010, 08:09:37 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
Is that even possible in GM?

Unless you mean as a DLL, in which case I don't know C++.

I have kind of simulated that already by loading a few lines each step, but the limiting factor seems to be reading speed.
Logged
Offline (Male) retep998
Reply #3 Posted on: April 07, 2010, 08:16:35 AM

Member
Location: Where else?
Joined: Jan 2010
Posts: 248
MSN Messenger - retep998@charter.net AOL Instant Messenger - retep998 Yahoo Instant Messenger - retep998
View Profile Email
Get gmthreads.
You can find it in the dll section of gmc.
Currently your loading code has to wait for the stuff to load, so valuable cpu time is lost.
While you're drawing and stuff, you don't use the hard drive, so valuable reading time is lost.
If you put the loading into a thread, the game will read at the same time as using up cpu.
Just try it out, you'll be amazed.
Logged
Offline (Unknown gender) Game_boy
Reply #4 Posted on: April 07, 2010, 08:35:15 AM
Member
Joined: Apr 2008
Posts: 228

View Profile
Thanks.
Logged
Offline (Male) RetroX
Reply #5 Posted on: April 07, 2010, 10:31:42 AM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
GM loading of anything will always be slow.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Male) Josh @ Dreamland
Reply #6 Posted on: April 07, 2010, 02:37:07 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2951

View Profile Email
Waiting for a thread to finish loading something is going to be risky.
I can't think of a good way to do it faster in GML... Threads will have to work for now.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Female) IsmAvatar
Reply #7 Posted on: April 07, 2010, 04:05:41 PM

LateralGM Developer
LGM Developer
Location: Pennsylvania/USA
Joined: Apr 2008
Posts: 877

View Profile Email
LGM uses threads to load the Game Information and Game Settings frame, and then waits for them if the user requests them. It cut an entire 2 seconds off the LGM load time, and chances are the user won't click on one of those in the first 2 seconds.
Logged
Offline (Unknown gender) Game_boy
Reply #8 Posted on: April 07, 2010, 04:16:58 PM
Member
Joined: Apr 2008
Posts: 228

View Profile
Well, the other thread wouldn't be affecting variables or data the player would be interacting with, and I'm happy to have the game freeze if you get there faster than it loads.

So I should avoid most of the problems with threads and memory issues.

Also I can use both of my CPU cores, that's got to help.
Logged
Pages: 1
  Print