Jump to content
  • Advertisement
Sign in to follow this  
Iderik

Noob question (Console app game, xp, c++) Collsion detection and map drawing!

This topic is 3932 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, this is my first time to post here :) I am making a game in console app with c++ (Win xp). I am really new to this so please don't give out some really advanced stuff, incase you are, please explain detailed :) I was making a game when you see from the side, using gravity function, jumping on blocks and shit. Didn't finish becous it was too fucked up in the code. So now I decided to make a simple game when you see from above, just simple to understand the functions in games when i'm going make more advanced stuff. This game would be like snake, but with blocks around in the map so you have to avoid. Stuff I got done: Walking around (works fine) points, highscore and increasing worms tail with getting points (works fine) Drawing map (just using simple cout output in the code, i know! its the worst shit ever) Blocking/ collision decetion (checking cursos pos and comparing with map blocks from the source) What is the best way to draw the map? - Reading from a txt file? (thought maybe easiest to create more levels, its faster and easier to design them) Should I use any other function when drawing the map instead of drawing the map everytime the cursor is moving? How should I inplant a collision detector in my game? - I mean maybe it should be easy to just draw lines in a square as walls and just check if my cursos is on some of those position, but i want to use obstacles. Please give me a push :) Some samples, tips, guides or something! Thankful for answers

Share this post


Link to post
Share on other sites
Advertisement
Firstly, let's try to keep an air of professionalism here. So how about watching the language :)

Reading map data from a text file is a very good idea, for the reason you gave.

Instead of drawing each time the cursor moves, you could draw at set intervals.

If you've got your map data loaded from a file and stored in memory, doing collision detection is easy. Any time the player tries to move in a direction, see if there's an obstruction in the map at the destination. If yes, don't allow the move, if yes, allow the move.

Share this post


Link to post
Share on other sites
Thanks alot for you tips gharen2! :)

Could you explain some more about setting intervals?

Thanks again!
/Iderik

Share this post


Link to post
Share on other sites
Quote:
Original post by Iderik
Could you explain some more about setting intervals?

He means only draw it every x millisconds, regardless if you've taken input or not. Ie, draw it 30 times a second will 'lock' your fps at 30. However, since it is just console based, perhaps drawing it 10 times will be sufficient. You'll have to experiment.

To implement this, your game loop ends up looks like

start loop
start timer
take input
AI, etc
end timer
if start time - end time < than some criterion
wait until criterion is fufilled
end
end loop


Something like that will do no more than x loops (or x fps if you will) in a second.


Share this post


Link to post
Share on other sites
Thanks alot!

I will change this after the weekend, and I'll show you my work :)
Got any ideas what I should do after that? to increase my experience.
I want to make 2D games in the future (no 3D, just 2D sprite games. mmorpg if i will contuine that far), should I start with SDL, AI or what it is called directly, or should I contuine with the basics?

sorry for my english and bless everyone! :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!