dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Have you ever felt like....

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Posts
    18

    Have you ever felt like....

    If I could just get a map laid out and be able to look at it in flash I would feel a lot better. That is the stage I am at now and my goal for this week is to get a nice flat map with flat grass in isometric mode laid out on the screen lol.

    I have been doing research on engines available. I wonder which engines you guys suggest using for games?

  2. #2
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    I've always made anything I want working for me o-o
    Partially because I seem to be bad about tutorials/kits/etc., some of which make simple tasks suddenly seem complicated with terminology

    But it's also because it just feels good to do it yourself

    I think an isometric tiling system is simple enough where persons don't need to recommend an engine; can just explain the process to you?

    I can probably throw together somin real quick for you, just tell me what topics you want covered

  3. #3
    Junior Member
    Join Date
    Jul 2009
    Posts
    18
    The engine would be for the overall game. I am trying to do a strategy game in flash. Nothing too complicated, just attack the castle, but not silly side view cartoony like whats available out there. I want a fake 3d world (isometric) with a nice castle, and the units to attempt to pummel it lol.

  4. #4
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    Well isometric works a lot like any other tile system; it may look 3d, but everything still stores 2-dimensionally
    As such, you will need a 2-dimensional array to store your tile data

    Let's say each grass tile is represented by a 0, and you have a 5x5 grid of em

    Code:
    var grass:Array=new Array(new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0));
    The positioning is just a little less direct
    Let's say each tile is 100 pixels wide and 50 pixels tall
    Every time you move it horizontally in the "3d" world, it would actually move 50 pixels over and 25 pixels down
    Moving it vertically in the 3d world would move it 50 pixels the other direction, and 25 pixels down

    Therefore, you can go through and place each tile like so

    Code:
    for(i=0;i<grass.length;i++){
    	for(j=0;j<grass.length;j++){
    		depth=i+j*grass.length;
    		if(grass[i][j]==0){
    			attachMovie("tile","tile"+depth,depth);
    		}
    		this["tile"+depth]._x=275+50*i-50*j;
    		this["tile"+depth]._y=25+25*i+25*j;
    	}
    }
    Need any elaboration?
    By the way, this only works if you have your grass graphic exported to actionscript as "tile"

    There are other ways to do it though
    You can store your grass as a bitmap instead of a movieclip, as well as your map for instance

    Saves a lot of computer power


  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    18
    This is where I run into trouble everytime I try to follow any tutorial or use any engine I am checking out. I do it step by step, I read over it make sure I understand what is going on in the code. When I put the code into flash I get undefined property errors all over the place.

    Its like something important is always left out, which makes it really hard for someone new like me. Am I supposed to be importing something somewhere? Should I be using any functions or anything I am not realizing? I get arrays, no problem that reads like english to me. I do php, html, and have scripted for mirc and some game projects in the past. (scripting is not programming I know, but the object orientation is still the same principles).

    But its like when I try to learn flash, which I should be able to pick up easily with my past scripting knowledge, people leave key things out everywhere.

    I imported my bitmap that I was going to use for grass, I made a new movieclip named tile, exporting to actionscript as tile. I entered the code exactly like you have it to ensure no mistakes.

    var grass:Array=new Array(new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0),new Array(0,0,0,0,0));

    for(i=0;i<grass.length;i++){
    for(j=0;j<grass.length;j++){
    depth=i+j*grass.length;
    if(grass[i][j]==0){
    attachMovie("tile","tile"+depth,depth);
    }
    this["tile"+depth]._x=275+50*i-50*j;
    this["tile"+depth]._y=25+25*i+25*j;
    }
    }

    but I still get nothing but a pile of "access of undefined property i, and j, and depth in this one for example.
    Last edited by maltech; 07-12-2009 at 05:09 PM.

  6. #6
    Junior Member
    Join Date
    Jul 2009
    Posts
    18
    OK OK lol, I got it to an extent. A very very simple yet very very important thing was left out....its AS2 I was trying to run that code in AS3.

  7. #7
    Senior Member Draxus's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    123
    That's because he's just giving you examples of how to do those specific things, and assuming you know how/where to use them. Your undefined i and j are the iterators in the 2 loops you're using and depth is the target depth for the grass MC, you need to declare them before the loop.

    Code:
    var i
    var j
    var depth
    for(i=0;i<grass.length;i++){
    	for(j=0;j<grass.length;j++){
    		depth=i+j*grass.length;
    		if(grass[i][j]==0){
    			attachMovie("tile","tile"+depth,depth);
    		}
    		this["tile"+depth]._x=275+50*i-50*j;
    		this["tile"+depth]._y=25+25*i+25*j;
    	}
    }
    I'm not trying to sound like a jerk, but if you can't see i is undefined using that code and know how to fix it, you should make something more simple than an isometric strategy game first, like pong or breakout.

  8. #8
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    I'm going to guess that it would've worked in AS3 if you made the modifications he suggested

    I don't know though, never picked up AS3 -.0

  9. #9
    Senior Member Draxus's Avatar
    Join Date
    Sep 2007
    Location
    Florida
    Posts
    123
    Err... yeah, haven't used AS2 in awhile, my fix would have been for AS3.

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