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

Started by
3 comments, last by Iderik 16 years, 2 months ago
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
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.
Thanks alot for you tips gharen2! :)

Could you explain some more about setting intervals?

Thanks again!
/Iderik
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   endend loop

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


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

This topic is closed to new replies.

Advertisement