I'm not so known among the TDC community and usually I prefere to live as a lone wolf, posting some downloads once a time.
This time though I'm facing a really weird issue I really need to go take care of with some kind help. I'm going to explain what I have:
I'm building a retro (figures...) game, old style, you know those early 80s games... yeah well I've already builded a proper level editor engine for this game that seems to work in the right direction BUT!... I have a bunch of active object placed as tiles on the level grid and wrote the X,Y into the 2D array. Every active object uses the same behaviour of the others but some shows when loaded from the array, some not.
First of all things my most sincere apologies for my english (I'm just one of that bunch of millions little italians... ) I'll try to explain better:
(Coma as String Parser delimiter)
--- Create Level ---
Key Press
Create Wall 0,0 on Cursor
Array: Create String "Wall," to (X"Cursor"+1), (Y"Cursor+1)
--- Save Level ---
Array: Save Array to File via a File Selector
--- Load Level ---
Start Loop: "load_x", (Array X Dimension) Times
Start Loop: "load_y", (Array Y Dimension) Times
String Parser: Get Element, 1 = "Wall"
Create "Wall" 0,0 Layer 1
X Position "Wall" = LoopIndex("load_x")
Y Position "Wall" = LoopIndex("load_y")
Ok that's all. Say we have more than a "Wall" object... well some of them do show when loaded and some do not. I don't really know where to put my hands...
I hope I've managed to explain my problem and I really apreciate any kind of help given
Thanks in advance!
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
16th April, 2009 at 03:28:42 -
Have you checked the Max Number of Objects for your frame? I suggest that you set it to 20,000. It may be that you just have too many walls which aren't being created due to the object cap.
IF it's random then maybe it's working too fast, and MMF is tripping over itself. I'd also suggest not using the String Parser object for something as simple as if text = "1". You could say Set direction of "Wall" to Value[Array].
@Andy: Definitely not a max # object problem. Occurs also with just 4 objects of the same kind (the kind that won't show up...). Thanks anyway
@Nim: So you suggest to write strings into the array like that 1 at 5,9 instead of Wall at 5,9? But how can I check if 1, 2, 3...? Array just have IFs about ending of one of its dimension... Or you know a better way to store tiles coord into arrays?
I've tried something: I've cut the level editor frame into a new application and tested out....
... O_o ...
The application with just the level editor frame saves/loads more object respect the main game application... and the code isn't changed a bit! -_-
Now I need to know if it is a loading or saving problem... need to figure out if data is really stored or simply not shown correctly.
PS: Oh another thing - object that won't show up are always the same. I mean if I fill the level with "Brick1", save and load it works. With "Brick2" works also... but when I fill it with "Brick3" and load I just receive one Brick3 al the lowest right corner of the shape I've drawn.
------------- UPDATE -------------
I've made some testing and I figured it is a showing problem since data is correctly stored into the array. I'll paste some pics to show you the very issue of the topic:
Tiles are stored yes and also are loaded into the frame but aren't positioned at the right coordinates unless the last tile of a (broken) kind loaded...
Looking at the third picture all 4 tiles are loaded at 0,0 coordinates but only the last one loaded are placed correctly...
I have a few suggestions, which may or may not actually fix the problem.
Firstly, it seems to me that all the tiles are being created, but being moved to the same position on screen.
I've occasionally had this problem myself, and what I find usually works is to set the position separately, so something like this maybe:
+ On Loop "Load_Y"
+String Parser: Get Element, 1 = "Wall"
-> Create "Wall" 0,0 Layer 1
+ On Loop "Load_Y"
+ Wall: Flag 0 is OFF
-> X Position "Wall" = LoopIndex("load_x") * Tile_Width
-> Y Position "Wall" = LoopIndex("load_y") * Tile_Height
-> Wall: set Flag 0 ON
Next suggestion - Don't have separate "load_x" and "load_y" loops. All you need is one "load" loop - much simpler, and that often means less buggy.
X = LoopIndex("Load") mod DimX( "Array" )
Y = LoopIndex("Load") / DimX( "Array" )
Finally - Do the blocks *need* to be Active objects? If not, then use the "add to backdrop" function instead of creating many new objects.
@Sketchy: Yes they need to be when in level editor (in order to modify it etc.) but already scripted to be added as background (obstacle or not) then destroy, within the game application
I'm going to try what you suggest. Thanks a lot for your help I hope it'll works!
I thought separating the process of creating/positioning would be the correct solution but really haven't figured how to do by myself! Thanks a lot again for helping me!
PS: Thanks for your suggestion to use just a single loop but until it goes with two loops I'll keep it like that. I'll keep the thing in mind though. Thanks