I'm making a level editor type dealy using arrays and externally load tilesets.
I can get the objects to blit nicely with the active picture, the problem is I don't know how to create my objects by reading the array.. I tried a fastloop but I couldn't get my array to create anything but the first tile no matter what i set its values to. I really don't know where to go from here... I have pretty simple code (so far):
+ Start of Frame
- Load array file ".\level.dat"
- Start loop "createx" 10 times
+ Upon pressing "Space"
- Save the array
+ On loop "createx"
- Create backdrop at (index x array)*16, (index y array)*16, rectangle position x = value current position in array*16, rectangle y position = value current position in array*16, width 16, height 16, obstacle
- Move 1 position Right in array
I don't know what to do and my code is probably ridiculous, but if anyone could help out I'd GREATLY appreciate it.
The loading of the array works fine, it's either the creation or my handling of the array that's wrong...
Yes but which event...? Because otherwise it moves diagonally. I tried saying: X index >= 40 then add 1 to y dimension & set x index to 1. But it didn't work...
I use arrays in a stupid way, not sure if it'll solve your problem.
After each loop I just "Add 1 to Y dimension" which sets it to the next row - so making it go through the array vertically. Then I check that row for an object, create the object, then Y dimension will go up by one again and the loop continues until there are no more rows.
You could try something like this:
First add a counter.
Second, add a restriction to the events in which the tiles are created;
"Counter < X.dimension of Array"
also
"add 1 to counter" in the same loopstep.
Now make a copy of the whole event and change
"Counter < X.dimension of Array"
to
"Counter = X.dimension of Array"
and instead of
"add 1 to counter"
use
"set counter to 0"
and
"add 1 to Ydimension of Array"
That should loop it correctly. The only downside to it is that you need to copy each of the creation events, and I noticed you have quite a few. But the upside is that it'll work. You might have to tweak the "Counter = X.dimension of Array" to either "Counter = X.dimension of Array+1" or "Counter = X.dimension of Array-1".
Hope that helps!
Damn smiley!
E_e
Edited by E_e.
Edited by the Author.
Eternal Entertainment's Code'n'Art Man
E_E = All Indie
...actually Ell Endie, but whatever.
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
13th March, 2007 at 01:50:38 -
Okay so reading over the way you are doing it again, it's not particularly efficient. I mean it will work, but it's not the conventional way to do it.
The way I do the loading is how I told you before. Saving the data couldn't be simpler. Make a 'cursor object' (a blank active object) then you just save the data to its (X position / 16) and to its (Y position / 16). I've made an example because I had some free time and put it on clickteam.com: