A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Arrays and Objects for my tile based game

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    252

    Arrays and Objects for my tile based game

    Hi Everyone:

    I'm making a tile based game, and so far it is coming out very nicely. What I want to do is have each level saved in an object array so I can load them easily.
    i want it to look sort of like this

    level = name of array where all levels will be stored.
    level.name = name of the level
    level.map = 'map' is the 2D array that stores the tile information for the level
    level.enemies = this is 2D array that contains 3 elements, what it does is store the enemies's name, x-position, and y-position.

    now this is an example of that it should look like:

    level[0].name = "The Sewers"
    level[0].map = [[0,1,0,1],[0,1,0,1],[0,1,0,1],[0,1,0,1]]; //Example
    level[0].enemies[0][0] = "Cyborg";
    level[0].enemies[0][1] = 275;
    level[0].enemies[0][2] = 300;
    level[0].enemies[1][0] = "Turret";
    level[0].enemies[1][1] = 100;
    level[0].enemies[1][2] = 200;
    level[1].name = "The Sewers 2"
    level[1].map = [[0,1,0,1],[0,1,0,1],[0,1,0,1],[0,1,0,1]]; //Example
    level[1].enemies[0][0] = "Cyborg";
    level[1].enemies[0][1] = 275;
    level[1].enemies[0][2] = 300;
    level[1].enemies[1][0] = "Turret";
    level[1].enemies[1][1] = 100;
    level[1].enemies[1][2] = 200;

    how exaactly should i do this, what is the most efficient way? using prototypes?
    any help would be appriciated

    Thanks

  2. #2
    SaphuA mosterdfles_flash's Avatar
    Join Date
    Jan 2002
    Location
    Tha Couch
    Posts
    935

    hehe

    Attach them in a MC,

    like on frame 1:
    PHP Code:
    attachmovie("empty""ground"0);
    ground.attachmovie("empty""enemys"1);
    ground.attachmovie("empty""items"2); 
    I hoop I understood you well
    ... and that you understand me :P
    Last edited by mosterdfles_flash; 04-12-2003 at 12:36 PM.
    'How Art Is The Visual While We’re Artificial…'

    Mail & MSN
    My Not Finisched Page!
    Nick: SaphuA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center