Page 1 of 1

Level generator from txt files works wrong after export

PostPosted: Fri Apr 01, 2011 1:59 pm
by bleok
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)

Re: Level generator from txt files works wrong after export

PostPosted: Fri Apr 01, 2011 9:51 pm
by skydereign
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.

Re: Level generator from txt files works wrong after export

PostPosted: Fri Apr 01, 2011 10:56 pm
by bleok
thanks a lot, now it works fine.