rosshadden/MMORPGKTHX — Issue #11: Refactor buildings/objects
Author: rosshadden
Created: 2011-11-20 21:48:20+00:00
State: open

Right now buildings are in the following format:

```javascript
{
"type":	"building",
"src":	"img/pokemon.png",
"where": {
"x":	6,
"y":	4
},
"x":	0,
"y":	0,
"w":	82,
"h":	70,
"dw":	75,
"dh":	70,
"door": {
"map": {
"x":	1,
"y":	1
},
"instance": {
"x":	7,
"y":	6
},
"at": {
"x":	7,
"y":	6
},
"to": {
"x":	12,
"y":	15
}
}
}
```

items are in this format:

```javascript
{
"type":	"item",
"src":	"img/zelda.png",
"where": {
"x":	14,
"y":	14
},
"x":	102,
"y":	659,
"w":	16,
"h":	16,
"dw":	25,
"dh":	25,
"data":	{
"contents":	[{
"id":	4,
"amount":	2
}]
}
}
```

and structures are in this format:

```javascript
{
"type":	"structure",
"src":	"img/wall.jpg",
"where": {
"x":	23,
"y":	1
},
"x":	0,
"y":	0,
"w":	154,
"h":	154,
"dw":	25,
"dh":	25,
"repeatY":	13,
"except": [{
"x":	23,
"y":	2
}]
}
```

In order for objects to be partially drawn, the format needs to be changed to something that contains a list of tiles the object contains. Something like this (for buildings):

```javascript
{
"type":	"building",
"src":	"img/zelda.png",
"where": {
"x":	6,
"y":	9
},
"x":	106,
"y":	303,
"w":	96,
"h":	64,
"tiles":[{
"x":	6,
"y":	9
},{
"x":	7,
"y":	9
},{
"x":	8,
"y":	9
},{
"x":	6,
"y":	10
},{
"x":	7,
"y":	10
},{
"x":	8,
"y":	10
}],
"door": {
"map": {
"x":	1,
"y":	1
},
"instance": {
"x":	7,
"y":	10
},
"at": {
"x":	7,
"y":	10
},
"to": {
"x":	12,
"y":	15
}
}
}
```