[Question] 2D Tiled "on map" house

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

User avatar
superLED
Chaos Rift Junior
Chaos Rift Junior
Posts: 303
Joined: Sun Nov 21, 2010 10:56 am
Current Project: Engine
Favorite Gaming Platforms: N64
Programming Language of Choice: C++, PHP
Location: Norway

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

Post 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
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

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

Post 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.
User avatar
k1net1k
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 563
Joined: Sun Nov 07, 2010 2:58 pm
Contact:

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

Post 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
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

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

Post 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:
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Van-B
Chaos Rift Regular
Chaos Rift Regular
Posts: 125
Joined: Tue Aug 10, 2010 7:17 am
Current Project: iPhone puzzle game
Favorite Gaming Platforms: All - Except Amiga
Programming Language of Choice: DBPro, ObjC++
Location: Scotland

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

Post 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).
Health, ammo.... and bacon and eggs.
Post Reply