Page 2 of 2

Re: [Question] 2D Tiled "on map" house

Posted: Fri Sep 09, 2011 1:15 pm
by superLED
GyroVorbis wrote:I mean no offense, but now each roof is allocated as a completely separate structure that must be iterated through. This kind of completely destroys the point of a tile-based engine. How do you handle collision on the roof? How does this roof at all fit in with the rest of a tile-based engine, considering it is now a giant image, rather than being composed of tiles?

szdarkhack's solution is going to be much better. That's my recommended way. Just make sure that instead of iterating through the whole map, this is in your loop for only rendering tiles that are in view.
Yeah, I can see it now. I messed up a little. The Roof struct should only hold the x, y, w, h position of the roof, and somehow linked to the group of roof tiles. Then, you check if the player is inside one of these roof positions, if so, don't draw the group of roof tiles that are linked to the corresponding roof struct.

I have never made something like this, so I don't know if this is a good idea or not. So I shall stay shut from now on, on things I have no experience with :p

Re: [Question] 2D Tiled "on map" house

Posted: Fri Sep 09, 2011 1:35 pm
by Falco Girgis
superLED wrote:
GyroVorbis wrote:I mean no offense, but now each roof is allocated as a completely separate structure that must be iterated through. This kind of completely destroys the point of a tile-based engine. How do you handle collision on the roof? How does this roof at all fit in with the rest of a tile-based engine, considering it is now a giant image, rather than being composed of tiles?

szdarkhack's solution is going to be much better. That's my recommended way. Just make sure that instead of iterating through the whole map, this is in your loop for only rendering tiles that are in view.
Yeah, I can see it now. I messed up a little. The Roof struct should only hold the x, y, w, h position of the roof, and somehow linked to the group of roof tiles. Then, you check if the player is inside one of these roof positions, if so, don't draw the group of roof tiles that are linked to the corresponding roof struct.

I have never made something like this, so I don't know if this is a good idea or not. So I shall stay shut from now on, on things I have no experience with :p
Don't shut up from now on. This forum is for broadening our horizons. It's not like you put a disclaimer saying "this idea is absolutely correct and completely optimized." He solicited opinions, and you gave one. Good for you, and I respect that more than the people who are too afraid to post.

Re: [Question] 2D Tiled "on map" house

Posted: Sat Sep 10, 2011 4:04 am
by k1net1k
M_D_K wrote: :shock: wtf
The OP has a Skrillex logo for his avatar. I was kind of bored and retarded so i made a reply including as many skrillex song references as I could think of

Re: [Question] 2D Tiled "on map" house

Posted: Sat Sep 10, 2011 11:09 am
by dandymcgee
k1net1k wrote:
M_D_K wrote: :shock: wtf
The OP has a Skrillex logo for his avatar. I was kind of bored and retarded so i made a reply including as many skrillex song references as I could think of
Lmao :lol:

Re: [Question] 2D Tiled "on map" house

Posted: Sat Sep 10, 2011 5:17 pm
by Van-B
As the disappearing roof is a big part of the game, I would do something similar to the tile ID idea mentioned. I'd have 3 layers to the map, ground, building, and roof, and an extra byte sized ID, unique to each building. This would be set for each tile, so you would just figure out the ID the player is inside, and exclude that ID when drawing the roof layer unless the player is on top of the roof (if relevant).

It might not be ideal for optimizing vertex arrays, but maybe detect changes in the players ground ID and recalculate the vertices of the previous ID (when exiting) or current ID (when entering).