kirupa.com has a ton of tutorials on Isometric stuff
that I've found very useful.

http://www.kirupa.com/developer/flash/index.htm#Isometry


--- Jobe Makar <[EMAIL PROTECTED]> wrote:

> Hi Jiri,
> 
> I've pasted below the isometric class that I wrote
> for one of my game books. 
> It is a handy class that allows for easy translation
> between screen coords, 
> and iso coords. In addition, it handles tile-based
> dept calculations as 
> well. You asked how do you handle multiple per tile
> - check out the leeway 
> variable in this class. If leeway is set to 5, and
> calculateDepth returns 
> 1230, then you can place your item anywhere from
> 1230 to 1235. You just have 
> to keep track of which depth is being used.
> 
> You don't have to swap depths of every item every
> frame. You just have to 
> swap depths on any items that has just changed
> tiles.
> 
> There are two limitations with this technique:
> 1) It does the depth calculations based on the size
> of the map. For most 
> uses this is fine. But if your map is like 5000 X
> 5000 tiles, then this 
> depth calculation can probably quickly get too high
> for Flash to handle 
> without further modifications.
> 2) A sortable item needs to be no bigger than a
> tile. If the base of this 
> item takes up multiple tiles (like a couch, or
> bench, etc) then you need to 
> either slice it up into tile-sized pieces, or change
> the depth approach. The 
> approach that you use if you are not slicing it up
> does require resorting 
> lots of item depths frequently rather than using
> just using unique depths 
> per tile.
> 
> //Isometric CLASS
> 
> class com.electrotank.world.Isometric {
>  private var maxx:Number;
>  private var maxz:Number;
>  private var theta:Number;
>  private var alpha:Number;
>  private var sinTheta:Number;
>  private var cosTheta:Number;
>  private var sinAlpha:Number;
>  private var cosAlpha:Number;
>  var leeway:Number;
>  public function Isometric(x:Number, z:Number) {
>   maxx = x;
>   maxz = z;
>   theta = 30;
>   alpha = 45;
>   theta *= Math.PI/180;
>   alpha *= Math.PI/180;
>   sinTheta = Math.sin(theta);
>   cosTheta = Math.cos(theta);
>   sinAlpha = Math.sin(alpha);
>   cosAlpha = Math.cos(alpha);
>   leeway = 5;
>  }
>  public function mapToScreen(xpp:Number, ypp:Number,
> zpp:Number):Array {
>   var yp:Number = ypp;
>   var xp:Number = xpp*cosAlpha+zpp*sinAlpha;
>   var zp:Number = zpp*cosAlpha-xpp*sinAlpha;
>   var x:Number = xp;
>   var y:Number = yp*cosTheta-zp*sinTheta;
>   return [x, y];
>  }
>  public function mapToIsoWorld(screenX:Number,
> screenY:Number):Array {
>   var z:Number = 
>
(screenX/cosAlpha-screenY/(sinAlpha*sinTheta))*(1/(cosAlpha/sinAlpha+sinAlpha/cosAlpha));
>   var x:Number = (1/cosAlpha)*(screenX-z*sinAlpha);
>   return [x, z];
>  }
>  public function setLeeway(value:Number) {
>   leeway = value;
>  }
>  public function calculateDepth(x:Number, y:Number,
> z:Number):Number {
>   var x:Number = Math.abs(x)*leeway;
>   var y:Number = Math.abs(y);
>   var z:Number = Math.abs(z)*leeway;
>   var a:Number = maxx;
>   var b:Number = maxz;
>   var floor:Number = a*(b-1)+x;
>   var depth:Number = a*(z-1)+x+floor*y;
>   return depth;
>  }
> }
> 
> 
> Jobe Makar
> http://www.electrotank.com
> http://www.electro-server.com
> phone: 252-627-8026
> mobile: 919-609-0408
> fax: 919-882-1121
> ----- Original Message ----- 
> From: "Jiri Heitlager"
> <[EMAIL PROTECTED]>
> To: <flashcoders@chattyfig.figleaf.com>
> Sent: Tuesday, September 11, 2007 8:50 AM
> Subject: [Flashcoders] Isometic game - zdepth
> managing for multiple 
> movablecharacters
> 
> 
> > He guys (and maybe girls),
> >
> > I have a question that is related to z-depth
> managing in an isometric 
> > game, that needs to be made in AS2.
> > In the game I basically use one abstract layer
> that holds all the tiles 
> > and their information wheter or not a movable
> object is allowed to 'walk' 
> > over the tile. Then there is another layer that
> holds all the objects, so 
> > that includes a player, a computer controlled
> player and enviormental 
> > objects that players cannot walk through being the
> visualization of the 
> > first layer.
> > Every object gets a z-depth assigned. For the
> players the zdpeth need to 
> > be set based on the tile they are at. This way the
> players can walk 
> > 'around' the enviorment objects. For the z-depth
> calculation I use the 
> > tile grid x and y plus the width of the row, this
> generates an unique 
> > z-depth number and makes sure that the higher the
> y, the bigger the 
> > z-depth , thus objects appear infront of objects
> with a lower y index.
> > Here is the problem I am trying to figure out. If
> two movable objects, or 
> > even three of them are at the same time on the
> same tile, then the above 
> > described z-depth managing will fail. How do I
> deal with that?
> >
> > Then another question I have is this. Does every
> movable object needs to 
> > check/swap z-depth on every frame. Wouldn't that
> be to CPU intensive?
> >
> > I really hope someone can clear this up for me.
> >
> > thank you in advance,
> >
> > Jiri
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the
> archive:
> >
>
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> > 
> 
> 
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the
> archive:
>
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> 
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
> 



      
____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect.  Join Yahoo!'s user panel 
and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to