Terraria, Blocks That Matter, Battle Block theater, and junk jack can all do this...
So I'm building a very basic platformer right now its a green square moving around in a world of orange square. Every time I make a new square I have to manually code so it works with the rest of the world. In all the games in the title they somehow wrote a way to say when you hit this type of block it stops you from falling, or it kills you, or it sets you on fire... I don't even know how this is done, is it a subview class? or something like that...
So I'm building a very basic platformer right now its a green square moving around in a world of orange square. Every time I make a new square I have to manually code so it works with the rest of the world. In all the games in the title they somehow wrote a way to say when you hit this type of block it stops you from falling, or it kills you, or it sets you on fire... I don't even know how this is done, is it a subview class? or something like that...
Dude if you going to reply to the post at all please write more than two words. The problems isn't whatever you ment by collision detection, I was asking how games like terraria or junk jack know when your touching a certain type of block, because dirt blocks drop dirt and stone blocks drop stone. In the platformer I've been making I have to code each block and it seems more like it would efficient to be able to code types of blocks instead of every individual block.
You store the blocks in some kind of data structure, like a 2d array of pointers. Then you can ask questions like "give me the block in front of the player" and then call methods like [theBlock giveRewardTo: player].
Depending on the type of the block, the player would get a different reward.
Going from code-driven to data-driven is a big step, so it'll be confusing at first. It's how "real" game are written, though.
You store the blocks in some kind of data structure, like a 2d array of pointers. Then you can ask questions like "give me the block in front of the player" and then call methods like [theBlock giveRewardTo: player].
Depending on the type of the block, the player would get a different reward.
Going from code-driven to data-driven is a big step, so it'll be confusing at first. It's how "real" game are written, though.
Could you point me in the right direction to learn more about this?
You store the blocks in some kind of data structure, like a 2d array of pointers. Then you can ask questions like "give me the block in front of the player" and then call methods like [theBlock giveRewardTo: player].
Depending on the type of the block, the player would get a different reward.
Going from code-driven to data-driven is a big step, so it'll be confusing at first. It's how "real" game are written, though.