A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: [help] iso - collect - tonypa's tbw tuts

  1. #1
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437

    [help] iso - collect - tonypa's tbw tuts

    hey guys,

    for a project in ITS we need to create something for a client (one of the teachers) in flash. what I have to do is create an interactive movie/game for my teacher.

    what it is meant to be at the end
    It is meant to be an isometric view of the workshop, where you wander around into different sections of the workshop (woodwork room, metalwork room, etc). there are tools and machines lying around and when the character walks up to them, a screen pops up asking them whether they want to watch a tutorial on how to use that tool/machine or if they actually want to use it.

    well what i have done so far is created the woodwork and metalwork rooms with walls and benches.

    what i am stuck on is actually placing things (machines and tools) onto the map properly. I have done it with normal tile based, but cannot seem to figure out how to do it properly with iso :S it seems to place it in a different spot! however it does collect the item at the specified spot by myItems, but the graphic isnt in the right spot!

    here is my map:
    code:
    workshop1 = [
    [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], // 0
    [ 1, 0, 0, 0, 0, 0, 0, 0, 0,10], // 1
    [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 2
    [ 1, 0, 0,40, 0, 0,40, 0, 0, 0], // 3
    [ 1,55, 0, 0, 0, 0, 0, 0,44, 0], // 4
    [ 1, 0, 0,40, 0, 0,40, 0,44, 0], // 5
    [ 1,55, 0, 0, 0, 0, 0, 0,44, 0], // 6
    [ 1, 0, 0,40, 0, 0,40, 0, 0, 0], // 7
    [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], // 8
    [ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] // 9
    ];


    here is my script for placing the items:
    code:
    myItems = [
    [0],
    [[1,1,8]]
    ];


    here is my script in the buildMap function:
    code:
    	game.items = myItems[game.currentMap];
    for (var j=0; j<game.items.length/2; ++j){
    for (var i = 0; i<game.items.length; ++i){
    var name = "item" + game.items[i][2] + "_" + game.items[i][1];
    game[name] = new game["Item" + game.items[i][0]];
    game[name].position = i;
    game.clip.attachMovie("items", name, 10001+i);
    game[name].clip = game.clip[name];
    game[name].clip._x = (game.items[j-i][1]*game.tileW);
    game[name].clip._y = (game.items[j+i][2]*game.tileW/2);
    game[name].clip.gotoAndStop(game.items[i][0]);
    }
    }
    _root.tuts = game.tuts;



    thanks guys!

    leighton




    ps: been doing tonypa's tuts, theyre excelent!
    ps2: sory for the long post
    Last edited by leight; 05-09-2004 at 02:01 AM.

  2. #2
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    just been talking to SaphuA,

    i told him about how i wanted it like Bauk's 48hr comp game where u go up to the people (for me: tools/machines) and press Z (for me: SPACE), and you give beer to the people (for me: option for tutorial or interactive).

    SaphuA suggested calculate the tile on which the character is on then go from there, but i guess i want to check to see if the hero is facing towards the machine (in this case (attatched) its the wood lathe: well it will, atm it says 'none') and if they press SPACE, they get the option of doing the tutorial/interactive for that tool/machine.


    how would i do that?



    maybe saying that will get me some help

  3. #3
    SaphuA SaphuA's Avatar
    Join Date
    Oct 2002
    Location
    The Netherlands
    Posts
    2,180

    :)

    That's exactly what I tried to tell you

    Could you explain your item-placement thingy? I'll then try to help you...

    SaphuA
    Last edited by SaphuA; 05-09-2004 at 08:39 AM.

  4. #4
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    mmm, i just had another idea as to how i could do it.

    - check to see if the hero's current x position = desired position
    - check to see it the hero's current y position = desired position
    - check to see it the SPACE key is pressed
    - check the hero's direction to see if theyre facing the object (well tile)
    - if so, then up comes the option screen.


    that would work wouldnt it? same as checking the door tiles really.

    SaphuA: there is a lot of code for the placement of the objects, i think that this way would be easier (if u still wana check it out - coz it will take a long post - go to www.tonypa.pri.ee/tbw/ ). it still does it in the same way (I THINK - well I HOPE!)

    anyone wana confirm that for me?

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    I would make it exactly like you described in your last post

  6. #6
    Ihoss
    Guest
    The way i would do it is that i would make an array of the room with the walls (5), tables (6), floor (0) and tools (2-4). Then when the player hits space the game checks what value the array has at his current position, and if it is 2, 3 or 4 and it runs a function according to the number:
    code:

    map=new Array(["5", "5", "5", "5", "5", "5", "5", "5"],
    ["5", "0", "0", "6", "6", "0", "0", "5"],
    ["5", "0", "0", "2", "3", "0", "0", "5"],
    ["5", "0", "0", "0", "0", "0", "0", "5"],
    ["5", "0", "6", "6", "0", "6", "0", "5"],
    ["5", "0", "6", "4", "0", "6", "0", "5"],
    ["5", "0", "6", "6", "0", "6", "0", "5"],
    ["5", "5", "5", "5", "5", "5", "5", "5"]);
    //draw it like you would normaly do
    function toolPlay(tool){
    _root.popUp.gotoAndPlay(tool);
    //this plays the movie of the tool or opens a menu
    //where you can choose what to do with the tool
    }
    //this is in the main hero:
    onClipEvent(enterFrame){
    if(Key.isDown(37) and Number(_root.map[x+1][y])<5){
    x++;
    }...And so on
    if(Key.isDown(32)){
    pos=Number(_root.map[x][y]);
    switch(pos){
    case 2:
    _root.toolPlay("Welder");
    break;
    case 3:
    _root.toolPlay("Drill");
    break;
    case 4:
    _root.toolPlay("Hammer");
    break;
    }
    }
    }


    Hope you understand that

  7. #7
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    hey guys,
    thanks for the replies im gona do which ever way is easiest!

    tonypa: last post as in post 1,2 or 3?
    if 2: i would do your way, except i dont know how to place the objects in iso view! i do in normal top/side view, but not iso rekkon u can give me a tip or some code
    if 3: i think i got an idea. use currentX and currentY (or whatever it is) and then go from there?

    ihoss: that kinda makes sence (what do all the 'break;''s do? i know it won't take long, but would i have to create a whole array like that each time i wana do something different (not now, as in the future).

    thanks guys!

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Originally posted by leight
    - check to see if the hero's current x position = desired position
    - check to see it the hero's current y position = desired position
    - check to see it the SPACE key is pressed
    - check the hero's direction to see if theyre facing the object (well tile)
    - if so, then up comes the option screen.
    Like this.

  9. #9
    Ihoss
    Guest
    My reply is kinda like tonypa advices. The breaks are there because its a switch/case. it could have been written like this:
    code:

    if(pos==2){
    _root.toolPlay("Welder");
    }else if(pos==3){
    _root.toolPlay("Drill");
    }else if(pos==4){
    _root.toolPlay("Hammer");
    }


    The array is the map. If you standardize the maps, then this engine should work no matter what you load. I would advice you to set a limit at 20 ir 30, and everything below 30 is walkable (instead of and Number(_root.map[x+1][y])<5 you have and Number(_root.map[x+1][y])<30). That way you can fill up that up with tiles for other tools too. The tiles are told to gotoAndPlay the value they have (for table that is 6). But you can have lots of different table tiles.

    If you want to keep this engien open then you can load a .swf url with the tile map for each tool tile. Then when toolPlay is called it loads the swf from its url. Then you can expand it as much as you want. You can also supply a tile map url with the array so you can load different tiles for different engines.

    Hmmm, i think i want to make a tilebased iso engien now

  10. #10
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    WOOHOO!!! my first ever tile based coding without a tutorial

    thanks guys! i took the map array idea from tonypa's tile based tuts, the switch/case from ihoss, some explinations on arrays (actionscript for flash mx: the definitive guide)

    wana see what i wrote?
    code:
    function Items(){
    tool = "none";
    toolsMachines = [
    [1,2,8],[1,2,6],[1,2,4], // wood lathe
    [2,2,5], // router
    [3,3,2] // drill press
    ];
    for (var i=0; i<toolsMachines.length; ++i){
    if (char.xtile == toolsMachines[i][1]){
    if (char.ytile == toolsMachines[i][2]){
    toolType = Number(toolsMachines[i][0]);
    switch(toolType){
    case 1:
    tool = "wood lathe";
    break;
    case 2:
    tool = "router";
    break;
    case 3:
    tool = "drill press";
    break;
    }
    }
    }
    }
    }



    thanks guys!!!

    ps: maybe i should have 2hrs sleep more often
    Last edited by leight; 05-10-2004 at 08:47 PM.

  11. #11
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437

    an easier way???

    hey guys,

    just wondering if there is a more efficient way of setting the tile properties? eg: in my map i have labeled the tiles their own frame numbers. would there be a really quick way to have the tiles from say 45-50 done in one statement (like the actionscript below) instead of doing each individual one???
    code:

    game.Tile10 = function () {};
    game.Tile10.prototype.walkable = false;
    game.Tile10.prototype.frame = 10;



    thanks guys!

  12. #12
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    hey guys,

    just thought that i'd show you what i have done so far with your help. Use the arrow keys to control the character (blue rectangle) and walk around my school workshop. Walk up to machines and press [SPACE] to see what options are available (none atm - so just press close button). The first room is a woodwork room, the second one is the metalwork room

    http://www.leightfgc.com/flash_files/




    oh yeh... temporary graphics

  13. #13
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Nice game so far
    I only wish it would be possible to close options pop-up with some key, not good to switch to mouse for it.

  14. #14
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    what key? I just put [BACKSPACE] - took 2 seconds

    do u know if there is a quicker way? question 2 posts before.

    thanks guys
    Last edited by leight; 05-11-2004 at 06:12 AM.

  15. #15
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Originally posted by leight do u know if there is a quicker way? question 2 posts before.
    You dont actually have to make each tile with every frame number a separate prototype. With simple game like yours, you only need 3 prototypes:
    walkable tile,
    wall tile,
    tool object.

    You can place all the different walkable tiles in frames 1-99, all the wall tiles in frames 100-199 and all the tools in frames >=200.

    Now when you read frame number from map array, you only have to check in which of those 3 it fits and use appropriate prototype.

  16. #16
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    just found out today that i have 20 days left to make it (along with 6 other assignments in 4 weeks )


    thanks tonypa!

  17. #17
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    im having a little bit of trouble with setting it up. my 'Benches' frames are 40-49. i've tried:
    code:

    // another attempt - definatly wrong!
    game.Benches = function () {};
    game.Benches.prototype.frame >= 40;
    game.Benches.prototype.frame <= 49;
    //
    // another attempt - thought it might work
    game.Benches = function () {};
    for (i=39; i<50; ++i){
    game.Benches.prototype.walkable = false;
    game.Benches.prototype.frame = i;
    }
    //
    // another attempt - thought it might work
    for (var i=39; i<50; ++i){
    game.Tile[i] = function () {};
    game.Tile[i].prototype.walkable = false;
    game.Tile[i].prototype.frame = i;
    }


    could i please habe some tips

  18. #18
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Not really like I thought. My idea was something like this:

    //declare prototypes
    game.Tile_walk= function () {};
    game.Tile_walk.prototype.walkable=true;
    game.Tile_wall= function () {};
    game.Tile_wall.prototype.walkable=false;
    game.Tile_tool= function () {};
    game.Tile_tool.prototype.walkable=false;
    game.Tile_tool.prototype.tool=true;

    Now in the buildmap function, check whats the value is in the map array:

    replace this line:
    game[name]= new game["Tile"+map[i][j]];

    with:

    if(map[i][j]<100){
    //walkable
    game[name]= new game.Tile_walk;
    }else if(map[i][j]>200){
    //tool
    game[name]= new game.Tile_tool;
    }else {
    //wall
    game[name]= new game.Tile_wall;
    }
    game[name].frame = map[i][j];

  19. #19
    leight.com.au leight's Avatar
    Join Date
    Sep 2002
    Location
    australia
    Posts
    1,437
    aaahhh its done like that im a tile/iso newbie

    thanks for all your help mate!

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