Forum Topic: Storing level data

(81 views • 4 replies)

This topic is 1 page long.

<< < > >>
None

gapern

Reply To Post Reply & Quote

Posted at: 2/21/09 07:56 PM

gapern NEUTRAL LEVEL 08

Sign-Up: 11/03/06

Posts: 90

So I'm a c++ coder looking to move to flash. My goal is to make games of course! I'm just curious how level data is created and stored with flash. As far as I know you are not able to read from a separate file to populate an array. It seems to me that all the level data is "hard coded" into the swf. Is that correct? Let's say I was going to make a game where I was using tiles and there were several hundred placed in a single level. Would I be typing every single x and y coordinate by hand into an array? Would I be making a level editor that writes to an array for me and I would somehow copy the contents of the array into the games swf? Fill me in on how it's done please.


None

XBigTK13X

Reply To Post Reply & Quote

Posted at: 2/21/09 08:04 PM

XBigTK13X LIGHT LEVEL 28

Sign-Up: 08/04/05

Posts: 370

When I build a level editor that will generate embeddable code, I usually have the program generate a formatted AS3 array that I can copy and paste into my game and then publish. If you prefer to have a dynamically loaded level system, you could look into using XML data.


None

TVK

Reply To Post Reply & Quote

Posted at: 2/21/09 08:10 PM

TVK DARK LEVEL 11

Sign-Up: 01/20/05

Posts: 59

As far as I know you can't get variables from an imported SWF (not 100% sure here though), however, the most common way to get external information into an SWF after it has been compiled is by using XML.
But yes, most stuff is being hardcoded into the SWF upon compiling, this includes external class AS files (if you're going to use OOP which you probably will).

So, if you want to use external files for generating levels, I'd suggest either putting them in an XML or textfile which the AS then parses into an array.


None

Alphabit

Reply To Post Reply & Quote

Posted at: 2/21/09 08:56 PM

Alphabit NEUTRAL LEVEL 09

Sign-Up: 02/14/06

Posts: 4,078

In a way, Flash can be used as a level editor... Generally what people do is make the engine; assign responsibilities to each object (in code) and then they 'design' each level on a separate frames by visually dragging objects on the screen and assigning names.

Personally, I don't like using frames, I prefer just coding everything from scratch... I like to keep an array of LevelData objects for each level and then I pass it as an argument to my Game engine when required... For creation, I would make a separate flash file that acts specifically as a level editor; so I would drag shapes in place and when I'm done, I would get it to print data representing the configuration of the game for that level... I would then copy (ctrl+c) that data, go to my game.fla, instantiate a LevelData object using that data as an argument, then I would put the LevelData in an array representing a list of all the levels; all this is done during the game's initialization.

Flash games aren't usually complex enough such that you'd need to store game data in an external file.

BAM! IN YOUR FACE!
My NEW blog: http://jonsworkblog.blogspot.com/
Current Project: http://modset.net/physicsb.html


None

gapern

Reply To Post Reply & Quote

Posted at: 2/21/09 09:54 PM

gapern NEUTRAL LEVEL 08

Sign-Up: 11/03/06

Posts: 90

Well I don't need to read from an external file if I don't have to. That's just the only way I know how from my experience with c++. I may just have to download the free trial to fully understand how it's done. If I can use flash itself as the level editor and just drag and drop things that would be awesome.


All times are Eastern Standard Time (GMT -5) | Current Time: 03:11 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!