Level generator from txt files works wrong after export

Non-platform specific questions.

Level generator from txt files works wrong after export

Postby bleok » Fri Apr 01, 2011 1:59 pm

Hi
I hope someone could help me.
I use readLevel function from this thread http://game-editor.com/forum/viewtopic.php?f=5&t=1305&p=6458&hilit=tiles+readlevel#p6458 , to generate levels from several text files, like level0.txt, level1.txt, level2.txt etc.
Everything works fine in game editor's game mode, but after export, level from first txt file is messed up, but next other generates and works fine.
I tried to use advices from some threads, like set variables to NULL, and tried to use skydereign's mymemset function to clear readLevel function's result array, but had no result.
I attache a little example tiletest.ged that show this problem.
will be appreciated for any advices and solutions.
(in example levels switch by pressing spacebar)
Attachments
tiletest.zip
(86.87 KiB) Downloaded 56 times
bleok
 
Posts: 8
Joined: Sun Mar 06, 2011 2:31 pm
Score: 0 Give a positive score

Re: Level generator from txt files works wrong after export

Postby skydereign » Fri Apr 01, 2011 9:51 pm

Ok haven't done too much testing, but I've seen this happen before. The problem with the load is caused due to a problem gE has when starting up a game. Using CreateActor usually works, but due to the ordering of events on the first frame, that will mess up as well. Draw Actor is the same way, so what is happening is the tile actors are not created at the time the view's draw event tries to load the level... so naturally the actors won't be set. The frame after that doesn't seem to work either, but if you trigger the first load on the second frame, then it works. Lame workaround I know, but that's at least what I have experienced. This doesn't happen in editor because the levels are already created, so the tiles are loaded before the view executes its draw event. The method I used while testing was this.
Code: Select all
if(frame>=2)
{
    // view's draw code here
}


Optimally you wouldn't be using the draw event to trigger your level loading, and then you wouldn't need this workaround.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Level generator from txt files works wrong after export

Postby bleok » Fri Apr 01, 2011 10:56 pm

thanks a lot, now it works fine.
bleok
 
Posts: 8
Joined: Sun Mar 06, 2011 2:31 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest