Author Topic: Place Objects in an Iso Tile Map  (Read 901 times)

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Place Objects in an Iso Tile Map
« on: May 23, 2011, 02:43:07 AM »
Hey guys,

i want hear some ideas, how can i add Objects, like Buildings, which are bigger than my tiles.

My Idea was to cut the Object in Peaces so i can setup every peace as Base or Non-Base part.
Base Parts are under my Character and Non-Base over my char. The Char cannot go over Base Parts. Base parts are the parts of the Objects which are on the ground.

My Map iam saving as php file. its just a file with a huge array. it looks like this.
areaY0X0.php
<?php
$map[0][0]=>array('gras.png',true); //$map[0][0] means Y = 0 , X = 0. gras.png is the image and true or false displays if the tiles is enterable.
$map[1][0] => array('water1.png',false);

//and so on..
after this i add array with objects
$mapObjects[2][2] => array('tree1.png','-10px -50px',true); // the image, background position , base or non-base
$mapObjects[2][1] => array('tree1.png','-10px -0px',false);

the Problem is, that is hard to calculate the background positions of the objects, but it works. maybe you have another idea how can i add the objects?

greetz BlackScorp

Offline Nox

  • Level 35
  • **
  • Posts: 767
  • Reputation: +12/-2
    • View Profile
Re: Place Objects in an Iso Tile Map
« Reply #1 on: May 23, 2011, 05:42:29 AM »
Hi,
'm not sure I totally understand your implementation, anyways...

First of all I would separate logic and presentation - so in object's properties you'll have position, which would be abstract coordinates on the map, and height

When drawing the object will be placed on it's coordinates (modified (probably multiplied) by the tile size and some iso ratio?) and moved to top based on it's height, but this is just visual thing

Also it's not even necessary to separate objects - which would seem like a lot of work actually - you can do it by wrapping the object into other element, then if you wish to display only bases - again only visual matter - you'll just modify the height of the element - set height to tilesize (* some iso ratio?), map-wide you could do it just by assigning a class to a map (meaning drawing screen), like
Code: [Select]
.map.base-only .object .wrapper { height: ##px; overflow: hidden } /* maybe you'll need the dirty !important... */
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Place Objects in an Iso Tile Map
« Reply #2 on: May 23, 2011, 06:11:08 AM »
the idea behind cutting objects into peaces is for layers. i dont wanna make my map like on RPG Maker, there you choose layer 1(base) put some objects, then select layer2 put other objects.

i want just say on x/y there is an object, this object have 2 peaces , one of them is the ground others not.

your css idea i like, i think i could setup background position with css. somethnk like this

.tree1{background-image:'tree1.gif'}
.tree1.part1{background-position:-0px -100px}

so i need to save in my files just
$mapObject[22][22] = array("tree1 part1",true); //class name  and base or not base

i will try it later and show you my progress

its just, i wanted to add to my world editor, an object editor, where i can make som objects to place them later into the map. like on this editor:
http://www.youtube.com/watch?v=Ol3qQ4CEUTo

there you can see they put a whole object and place it into the map

Offline Nox

  • Level 35
  • **
  • Posts: 767
  • Reputation: +12/-2
    • View Profile
Re: Place Objects in an Iso Tile Map
« Reply #3 on: May 23, 2011, 11:02:57 AM »
if you have fixed layers (same height) then you can define bg-pos to an object in general, right?

anyway - I don't actually understand what is the problem or what do you need

yea, they put a whole object there... you just set the coordinates and that's it, i don't see a problem - plus maybe set height and calculate z-index
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Place Objects in an Iso Tile Map
« Reply #4 on: May 25, 2011, 01:04:43 AM »
the problem are the position of the tiles and the positions of the parts of objects.

in normal 2D view you can just calculate object Height/tileHeight and Object Width / tile Width and you know how many parts your object have. but in isometric view the tiles are over other tiles because every 2nd row you need to move your row half tile width to the left and half tile height to the top. so you cut the object in more peaces in iso view.

so i just asked for alternatives ways ... it seems this dont exists

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Place Objects in an Iso Tile Map
« Reply #5 on: May 25, 2011, 02:06:26 AM »
I did iso games ages ago so I might mess up something here but as far I remember iso rendering is non trivial compared to traditional grid. You basicly have to make z sorting. Especially moving objects (intersection of tiles) give troubles. The absolutely crucial thing is the width of an object (height is irrelevant), in the end you want to cut wider objects into several smaller ones (this was the only and the best solution to me back then).
I'm not sure, but I think we were rendering the view not from top to bottom in horizontal lines but more in a form of "v" (lte line going from left top to centre and from right top to centre) but my memory might be fading here :)

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal