Two Questions involving platform games
Hello, I''m a VB programmer and I''m making a Sonic The Hedgehog platform game. I have two questions about creating the level engine:
1. how would I create an engine which could show all the level pieces for a given position in the level (if you know what I mean). For example: if I were to set the sprite in a certain position in the middle of the level, how would the engine know where to blit the appropriate tiles?
2. How do I make the engine know which tiles to test for collision detection? I had two ideas for how to do this but one seems like it would slow the game down. My first idea (the slow one) was to make an array with collision info for all the tiles in the level and test for position and collisions. My second idea was to somehow test for only tiles that are visible on the screen, but I''m not quite sure how I''d determine which ones are visible.
Jason O
Jason O
Given the width and height of the screen, and the ''scroll position'' (the location, in world-coordinates, of the top-left corner), you can work out a rectangle which is the current ''view.''
Sonic always kept the main character in the middle of the screen; so the scroll-location was always a certain value above and left of the character''s position.
Once you''ve got that rectangle, it''s quite easy to work out the tiles which are at the edges (and, therefore, the tiles within the rectangle). You draw/test them.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Sonic always kept the main character in the middle of the screen; so the scroll-location was always a certain value above and left of the character''s position.
Once you''ve got that rectangle, it''s quite easy to work out the tiles which are at the edges (and, therefore, the tiles within the rectangle). You draw/test them.
Superpig
- saving pigs from untimely fates
- sleeps in a ham-mock at www.thebinaryrefinery.cjb.net
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
Thanks for your reply. Do you know anything about doing tile collision detection though? I was thinking about using a circle for the sonic sprite''s collision detection, but I''m not quite sure how I would test the tiles using a circle. I know that I''d use lines for the flat and sloped pieces but what about the curved ones?
Jason O
Jason O
Jason O
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement