ForumsProgramming ForumStoring multiple values?

5 3921
rjbman
offline
rjbman
215 posts
Nomad

Alright so I've got a platform game where there's multiple variables I need to store. Like, there's the embed .txt file with the tilemap, then the player x and y starting, then the 5 separate enemy x and y starting, then the goal x and y variable.

My question is, is there some way to store all these in a variable type? Like so I can call lvl1 and it does the tilemap and all the starting postitions?

  • 5 Replies
Darkroot
offline
Darkroot
2,763 posts
Peasant
BeastMode10
offline
BeastMode10
374 posts
Nomad

Parallel Arrays perhaps?

Like maybe:

var xArray:Array = [playerx, enemyx, goalx]
var yArray:Array = [playery, enemyy, goaly]

Or something like that. I have no idea where you should place the .txt file, though.

rjbman
offline
rjbman
215 posts
Nomad

The array is stored in a class. You can use an array like that though? Sorry I'm used to visual Basic where (i'm pretty sure) arrays are a single type.

Darkroot
offline
Darkroot
2,763 posts
Peasant

An array is a class, for the text file you can use urlloader

var myTextLoader:URLLoader = new URLLoader();

myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(e:Event):void {
trace(e.target.data);
}

myTextLoader.load(new URLRequest("myText.txt&quot);


and write a function that pushes the text into it. But I myself haven't done much i/o in flash.

In java and c++ the type is hardcoded but in python and apparently as3 it's not.

rjbman
offline
rjbman
215 posts
Nomad

I've got the text embedded fine. I think I'm getting it to work, slowly.

Trying to remake the level initiator is tough.

Showing 1-5 of 5