The Daily Click ::. Forums ::. Klik Coding Help ::. Weird Issue with Level Editor - Array - String Parser
 

Post Reply  Post Oekaki 
 

Posted By Message

caccolothemeaning



Registered
  03/12/2008
Points
  373
16th April, 2009 at 03:01:08 -

Greetings everyone!

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!

 
Image

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
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.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

nim



Registered
  17/05/2002
Points
  7234
16th April, 2009 at 03:33:38 -

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].

 
//

caccolothemeaning



Registered
  03/12/2008
Points
  373
16th April, 2009 at 11:50:04 -

@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:

Image
Image
Image

Edited by caccolothemeaning

 
Image

caccolothemeaning



Registered
  03/12/2008
Points
  373
16th April, 2009 at 12:47:43 -

Another check made...

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 beg for help...

 
Image

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
16th April, 2009 at 13:45:50 -

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.

 
n/a

caccolothemeaning



Registered
  03/12/2008
Points
  373
16th April, 2009 at 13:56:48 -

@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!

 
Image

caccolothemeaning



Registered
  03/12/2008
Points
  373
16th April, 2009 at 14:10:18 -

Would you marry me?



Thanks a bunch! It worked!

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

 
Image

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
16th April, 2009 at 18:02:43 -

Glad I could help.
Thanks for the trophy too

 
n/a
   

Post Reply



 



Advertisement

Worth A Click