Posted By
|
Message
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
27th July, 2009 at 02:29:42 -
Okay so here I am working on another level editor that incorporates tile sets and I have run into a problem and the code seems fine, I don't understand why it wouldn't work.
When I place a tile from the active picture object, or my tileset rather, I give that array position a string for the X/Y co-ordinates of the tile in the tileset. Same method as Zephni's level editor. It will write "0 0" for the far left top corner tile, "1 0" for the next one along, and so on.
Now when I try to load it and create backdrops for the terrain, I want it to read that string, break it down and paste the corresponding tile into it's place. The problem is that it doesn't seem to break it down properly in the action, and for every terrain tile creates the tile at 0, 0 on the tileset (blank grass). First I thought .. well, obviously it's reading "0 0" in every string or something like that. And I checked it with counters, setting them to Val(Left$(current str$( "Map" ), 1)) ... and it worked properly, showing me the tileset co-ordinates. Yet when I put this same formula into the action for the active picture object to create a backdrop, it creates the same tile over and over.
There's no problem with the event, it's simple, on loading loop it checks if the current string in the editor is different to "" (nothing in it), and if it is (meaning there's something in it) it will do the action. This works fine, it's the actual action that's acting up.
Event
On loop "yLoad"
StrAtXYZ( "Map", LoopIndex("xLoad"), LoopIndex("yLoad"), 1) <> ""
Action
Active Picture Object: Create Backdrop Object
X co-ordinate of destination rectangle: (LoopIndex("xLoad")-1)*32
Y co-ordinate of destination rectangle: (LoopIndex("yLoad")-1)*32
X co-ordinate of picture rectangle to paste: Val(Left$(current str$( "Map" ), 1))*32
Y co-ordinate of picture rectangle to paste: Val(Right$(current str$( "Map" ), 1))*32
Width of rectangle to paste: 32
Height of rectangle to paste: 32
No effect on collisions
Keep in mind that the strings read for tiles look like "2 1".
Therefore the formula Val(Left$(current str$( "Map" ), 1))*32 should extract one character from the left half of the string, that being 2, and then multiply it by 32, giving us 64. So it should know to take the tile from X:64 on the tileset. I know this formula WORKS because I have tested it with debug counters, having them always set to this formula for left/right/x/y, and they will produce "64" and "32".
Zephni's level editor uses the formula Val(Left$(current str$( "Array" ), 1))*16, which is what I used, only changing my Array's name (Map) and tile size (32).
Is there something I have overlooked here? It looks correct to me..
n/a
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
27th July, 2009 at 03:44:01 -
Let me just add that when I place a terrain tile, this is what I write to the array position.
Str$((X( "Tile Selected" )-X( "Tileset" ))/32)+" "+Str$((Y( "Tile Selected" )-Y( "Tileset" ))/32)
Str$(a)+" "+Str$(b)
a = the X position of the tile in relation to the frame/active picture object
b = the Y position of the tile in relation to the frame/active picture object
Resulting in .. "x y" or "0 0"
n/a
|
tamtoum
Registered 07/05/2009
Points 13
|
27th July, 2009 at 08:18:10 -
The example of Zephni is the best example I could find on the net
ARRAY+PICTURE+LAYERS+OBJECTS, But little bit obvious include in its approach ...
Good luck to you.
n/a
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
27th July, 2009 at 10:04:40 -
Yes, herein lies one of my biggest problems, I already have his tutorial and it doesn't seem to work for me
If Zephni sees this I hope he takes a look, but there's also many other talented minds on TDC so hopefully one of those drops in and gives me a little help
n/a
|
tamtoum
Registered 07/05/2009
Points 13
|
27th July, 2009 at 12:34:44 -
The difficulty for me to understand this example comes from too many lines of events interwoven into each other.
I have unfortunately a very small IQ ...
n/a
|
maVado
Registered 25/06/2005
Points 601
|
29th July, 2009 at 07:24:12 -
Active Picture Object: Create Backdrop Object
Width of rectangle to paste: 32
Height of rectangle to paste: 32
Why do you set the object after creating? It will not have any effect.
If I am not mistaken the correct order of event should be:
Action
X co-ordinate of destination rectangle: (LoopIndex("xLoad")-1)*32
Y co-ordinate of destination rectangle: (LoopIndex("yLoad")-1)*32
X co-ordinate of picture rectangle to paste: Val(Left$(current str$( "Map" ), 1))*32
Y co-ordinate of picture rectangle to paste: Val(Right$(current str$( "Map" ), 1))*32
Width of rectangle to paste: 32
Height of rectangle to paste: 32
No effect on collisions
Active Picture Object: Create Backdrop Object
n/a
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
29th July, 2009 at 07:47:15 -
The size of the object is not a problem, I can't actually edit that order of events because it's one single action taken by the Active Picture Object, not several actions. So this is all pre-defined before the action is carried out, it tells the APO the specifics and then it happens. I have no idea why I get this crazy bug, because with that in mind, it makes complete sense to me! Just not to MMF..
n/a
|
maVado
Registered 25/06/2005
Points 601
|
29th July, 2009 at 13:57:27 -
can you upload just that part of the file and a sample map? I have a complex level editor in my game and it works similar with tilesets and active picture but it was coded 2 years ago, I can compare and see what is different...
n/a
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
3rd August, 2009 at 06:20:35 -
Standby, I'm taking the frame out from the application so I can upload it on it's own..
Here we go.
http://files.getdropbox.com/u/1511825/mapeditor_3rdaugust_tilebug.zip
You'll need to extract it along with the default tileset.
n/a
|
tamtoum
Registered 07/05/2009
Points 13
|
4th August, 2009 at 10:55:24 -
sorry I tried to solve your problem, but without success
n/a
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
5th August, 2009 at 22:39:04 -
Thanks for taking a look anyway
Anyone else?
Pleeeease?
n/a
|
tamtoum
Registered 07/05/2009
Points 13
|
6th August, 2009 at 20:04:08 -
Person to help us?
http://www.youtube.com/watch?v=Zo-9r04_R-Y
n/a
|
Zephni My other cars a Balrog
Registered 17/10/2007
Points 4019
|
14th August, 2009 at 09:53:44 -
Hey guys, i think my example has cause a bit of confusion.. Because i went about it the wrong way.. There is a much simpler way of doing this.
I have just downloaded your example and will attack it right now
But im going to upload my latest example very very soon.. I really think it will help people understand level editors entirely!
dont make me divide by zero...
|
Zephni My other cars a Balrog
Registered 17/10/2007
Points 4019
|
14th August, 2009 at 10:13:34 -
Ok ive sorted your problem...
When it pastes the tile and trys to figure out wich one to lay, this should be the x:
(Val(Left$(StrAtXYZ( "Map", LoopIndex("xLoad"), LoopIndex("yLoad"), 1), 1)))*32
and the y would be:
(Val(Right$(StrAtXYZ( "Map", LoopIndex("xLoad"), LoopIndex("yLoad"), 1), 1)))*32
The reason your didnt work was because you were looking for the "current value" of the array object... But the array didnt even know where it was.. SO, in the event where it finds the correct tile to paste, it reads its X Y from the string that is saved, and it knows which string because of the current x and y loop. the Z is "1", but thats because of the way your doing this, you seem to have layer 1 as tiles and layer 2 as objects, which is fine.
This is the MMF file: http://zephni.com/downloads/mapeditor_zephedit.mfa
dont make me divide by zero...
|
[DELETED] Likes to put dots on paper
Registered 08/12/2008
Points 118
|
14th August, 2009 at 10:32:28 -
Wow, thank you! I greatly appreciate your help! And I think the other dude in this thread wanted to learn how to do it also, so thanks very much.
n/a
|
|
|