The Daily Click ::. Forums ::. Klik Coding Help ::. Loading terrain from array + active picture tileset
 

Post Reply  Post Oekaki 
 

Posted By Message

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
27th July, 2009 at 2:29:42 AM -

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


 
http://jthongbai.deviantart.com/

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
27th July, 2009 at 3:44:01 AM -

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"

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
27th July, 2009 at 8:18:10 AM -

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

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
27th July, 2009 at 10:04:40 AM -

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

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
27th July, 2009 at 12:34:44 PM -

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
  6/25/2005
Points
  601

I'm on a Boat
29th July, 2009 at 7:24:12 AM -

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

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
29th July, 2009 at 7:47:15 AM -

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

 
http://jthongbai.deviantart.com/

maVado



Registered
  6/25/2005
Points
  601

I'm on a Boat
29th July, 2009 at 1:57:27 PM -

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

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
3rd August, 2009 at 6:20:35 AM -

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.

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
4th August, 2009 at 10:55:24 AM -

sorry I tried to solve your problem, but without success

 
n/a

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
5th August, 2009 at 10:39:04 PM -

Thanks for taking a look anyway
Anyone else?

Pleeeease?

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
6th August, 2009 at 8:04:08 PM -

Person to help us?
http://www.youtube.com/watch?v=Zo-9r04_R-Y

 
n/a

Zephni

My other cars a Balrog

Registered
  10/17/2007
Points
  3919

Has Donated, Thank You!VIP MemberSonic Speed
14th August, 2009 at 9:53:44 AM -

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
  10/17/2007
Points
  3919

Has Donated, Thank You!VIP MemberSonic Speed
14th August, 2009 at 10:13:34 AM -

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

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
14th August, 2009 at 10:32:28 AM -

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.

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
14th August, 2009 at 11:39:45 AM -

Jthongbai - Zaphni thank you very much, it's cool!
http://www.youtube.com/watch?v=WdlPjAJFIrw&feature=channel
http://www.youtube.com/watch?v=ZWhjCrPJf1k

 
n/a

Zephni

My other cars a Balrog

Registered
  10/17/2007
Points
  3919

Has Donated, Thank You!VIP MemberSonic Speed
14th August, 2009 at 11:45:08 AM -

thanks... and its zEphni =

 
dont make me divide by zero...

tamtoum



Registered
  5/7/2009
Points
  13
23rd August, 2009 at 11:18:12 AM -

In the example the object "spawn" can not work due to
small typographical error on a line "spawnr"

I seek the right command line for the better
run with 4 images (directional).

Not easy to solve for me.

Sorry for my English

 
n/a

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
23rd August, 2009 at 12:08:20 PM -

Which example are you talking about, tamtoum?

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
23rd August, 2009 at 2:49:36 PM -

hello

the first as the second example

spawn on the object different from other
http://imagik.fr/view-rl/111651

 
n/a

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
24th August, 2009 at 12:05:27 AM -

Oh okay I knew that was buggy but I just needed help with the tileset in this thread (which is all cleared up!). Thanks anyway!

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
24th August, 2009 at 8:05:28 AM -

thank you anyway for the example

I will continue to seek

 
n/a

tamtoum



Registered
  5/7/2009
Points
  13
27th August, 2009 at 8:33:59 AM -

I advance slowly

- Spawn (create object)
- Spawn2 (object source)

When pressing the "Shift"
if "tile selected" above "Spawn2"

Sets the direction dir "Spawn"
> "Spawn2"-8

But I still have not found for array



Edited by tamtoum

 
n/a

jthongbai

Likes to put dots on paper

Registered
  12/8/2008
Points
  143

MushroomVIP MemberARGH Sign
27th August, 2009 at 9:01:11 AM -

You need to write a new string to the array so it knows when it loads what direction to face the spawn.

so when it faces --->, "spawn0" (direction 0)
and up is "spawn8"
left is "spawn16"
down is "spawn 24"

when you load, just parse the string.
on loading loop when Left$ of string = spawn and Right$ of string = 0 , set direction to 0. repeat for others.

 
http://jthongbai.deviantart.com/

tamtoum



Registered
  5/7/2009
Points
  13
27th August, 2009 at 10:10:10 AM -



Ha ok thank you jthongbai


I try

 
n/a

tamtoum



Registered
  5/7/2009
Points
  13
27th August, 2009 at 4:31:33 PM -

Thank you very much Jthongbai



http://www.youtube.com/watch?v=v0PNwh0PqF4&feature=related

 
n/a
   

Post Reply



 



Advertisement

Worth A Click