The Daily Click ::. Forums ::. Klik Coding Help ::. Level loading in Flash
 

Post Reply  Post Oekaki 
 

Posted By Message

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
11th January, 2011 at 02:20:29 -

How can I make a level loading system in TGF2:NE?

I tried using the list object, because it's easier to play with than a string, but this method turned out to be completely stupid (a bit slow in TGF, doesn't work at all when compiled to flash). Should I use a string instead? Am I missing something fundamental?

I just wanna make my levels elsewhere, then drag them into the level editor and load them up as needed.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
11th January, 2011 at 02:59:15 -

I wanted to be quite flexible with what I could store, you see, that's why I used the list object... Different values and strings for different object instances etc

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
11th January, 2011 at 03:43:56 -

Turns out it's just the 'current line' business with the list object that doesn't work in Flash, and done properly it's speedier than in TGF normally.

Feel free to weigh in though, klikkers!

 
n/a

Ricky

loves Left For Dead 2

Registered
  28/12/2006
Points
  4075

Has Donated, Thank You!Game of the Week WinnerVIP MemberWii OwnerHero of TimeGOTM Winner! - November 2009I am an April Fool
11th January, 2011 at 05:00:15 -

Man i wish my game was finished so i could show you the source code. I'm using the string object though, and storing the data in paragraphs

 
-

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
11th January, 2011 at 11:33:12 -

a single string can hold the data for your entire game. string parser is your friend.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
11th January, 2011 at 13:17:24 -


storing the data in paragraphs



Beats me how you'd do this without making it a royal pain for yourself - unless it's just one paragraph per level or something?


string parser is your friend.



An extension? In TGF2:NE?

I tried it with a string object, before realising I could adapt my list object version to work in Flash, but I'm very rusty with the built-in string parsing options and wanted to store data of whatever length for each tile, etc.

Thanks for the replies guys!

 
n/a

Hagar

Administrator
Old klik fart

Registered
  20/02/2002
Points
  1692

You've Been Circy'd!Teddy Bear
11th January, 2011 at 13:27:07 -

In the C world I would delimit each line as an object, and look for the '\n' (end of line - line feed and carriage return).

Perhaps this could be done in TGF:NE? Not sure if its possible really, I tried making an app to recieve binary data and the serial object was cutting out the null terminators ('/0' or number 0) , but surely a newline would be detectable...

 
n/a

nim



Registered
  17/05/2002
Points
  7234
11th January, 2011 at 13:28:33 -

I've loaded levels with a string object before but it was not all that fun. I used String Parser (sorry, I know - no extensions in TGF) to grab each character and retrieve its ASCII value (a number), which then changed the animation direction of the "tile object" before it was pasted into the backdrop. This gave me a total of 32 tiles but I'm sure you could get more by using another expression to change the current animation too.

Without the extension, I'd use 2-digit numbers stored in a string object (each level using a new paragraph)

At the most basic level, this would look like: (where number 01 is a background tile)

0101010101010101
0100000000000001
0100000000000001
0100000000000001
0100000000000001
0100000000000001
0101010101010101

Be careful of line breaks too, if you're doing this, as they will also count as a character.

 
//

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
11th January, 2011 at 14:07:22 -


delimit each line



Yeah, this is sort of what my current system looks like - the list object is basically a multiline string and you can select a line by value, which is why it's more appealing than hacking together something similar with the string object and built-in parsing functions. It doesn't like having its values looped through when run through TGF2 itself, or a standard klik exe I imagine (it takes about a full second to load a level up) but funnily enough it's perfectly nippy when compiled to Flash. Unfortunately it won't respond to 'get focus', 'set line' or similar actions in Flash so I've got to specify a line in each expression.


Without the extension, I'd use 2-digit numbers stored in a string object



Somewhere between posts #2 and #3 (so around 3am) I ported most of my stuff over to this method, but it had me stumped on storing additional values and strings for certain tiles (e.g., signposts with unique text).

Thanks again!

 
n/a

Mårten



Registered
  25/06/2002
Points
  769
12th January, 2011 at 10:56:23 -

In your case I would do something like this (presuming you have some sort of tile based system);
- choose a special delimeter character dedicated to start a new tile code, for example: ¤
- the character following ¤ is your tile type, i.e. "1" means block, "e" means enemy, "S" means sign post.
- The characters following the tile type is parameters for the tile, which could be anything.

Your string would be something like this (for 5 blocks):
¤1¤1¤e¤SThis is a signpost text¤e
and would result in: block, block, enemy, a sign post with the text "This is a signpost", enemy

You could use different delimeters to have multiple parameters for objects etc.

This would of course require you to have some sort of editor to create these strings, as the strings themselves aren't very easy to read.



Edited by Mårten

 
---

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
16th January, 2011 at 02:05:28 -

you mean like loading levels in a flash editor? I'm trying to work that out now. It works so far, a few bugs though. Here's the demo flash:

http://create-games.com/download.asp?id=8325

I may post some article on it later.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
17th January, 2011 at 23:21:56 -

Hey Sumo, won't load up for me, Flash Editor.swf 404s... Looks beautiful though

 
n/a

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2723
23rd January, 2011 at 14:07:09 -

The movie from the mmf flasheditor won't load for me either.

When I was working with TGF I used to store tiles and game objects in an ini file. Not sure if that would work with TGF2NE though.

It sounds like you need to create some kind of level editor using strings and multiple delimiters. Or perhaps the array object can help you?

In Flash it's usually done with some nice xml files ...

Using a special character as a line break might help a lot when dealing with multiple strings inside a string, but it gets messy anyway.

 
Image jenswa.neocities.org

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
23rd January, 2011 at 20:39:35 -

Hey Jenswa, You can use arrays in TGF2:NE, as you can ini for storing some local data, but the problem is you can't handle external files (of course!) and there's no real way to populate this stuff apart from in the event editor, which is pretty daft. It'd be cool if the array object came with a GUI when you placed it in the level editor.

So the solution is to copy and paste your levels into a string object or some such. I got it working with the list object shortly after making this topic but I'm glad everyone weighed in. Mårten's method is, well, probably better than mine, but I don't know my way around the built-in string parsing facilities well enough!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click