Stop scrolling>>click here>>Real Time in dos games<<
Does anyone of you guys know any good tutorial on programming real time games under DOS?I use DJGPP c/c++ compiler and Allegro v3.1 game library.Im new in game programming so I need all the help I can get.
thaks();
waiting_for_answers();
Programmer.But beginner in programming games.
07.11.2000
Programmer.But beginner in programming games.07.11.2000
#define GAMESTATUS_QUIT 1
unsigned long dwGameStatus;
main ()
{
// Initialize all values, do menu stuff, that sort of thing.
InitGame ();
/* Here is the ''real time'' part. You do a big loop, and inside of it, you draw the frame you are currently on, get input,
move objects in the game, do collision detection, update score,
that sort of thing. then you erase and do all over, until the player wants to quit.
*/
while (dwGameStatus != GAMESTATUS_QUIT)
{
DrawCurrentFrame ();
GetUserInput ();
DoGameLogic ();
HideCurrentFrame ();
}
}
/* another thing, usually when you have a moving object, to do stuff real-time, you need to keep track of where he is, and where he is going. So you have x, y, and x, y velocities.
you get this:
struct MovingObject
{
float X;
float Y;
float XV;
float YV;
};
then, every frame, after X and Y have initial values, such as 0, 0, you add Xv to X, Yv to Y, and the Object has Moved!
that''s how they did pong, at least that''s one way of doing it. make a pong game, just to learn how, it''s easy, and fun! When the ball hits the wall, just negate the x or y value to bounce it in the other direction. So, if Ball hits right wall or left wall, do this.
Ball.Xv = -Ball.Xv;
if Top wall, or bottom wall do this:
Ball.Yv = -Ball.Yv;
gotta go.
*/
farmersckn
Yesterday is the past, tomorrow is the future. Today is a gift, that is why
we call it the present.
unsigned long dwGameStatus;
main ()
{
// Initialize all values, do menu stuff, that sort of thing.
InitGame ();
/* Here is the ''real time'' part. You do a big loop, and inside of it, you draw the frame you are currently on, get input,
move objects in the game, do collision detection, update score,
that sort of thing. then you erase and do all over, until the player wants to quit.
*/
while (dwGameStatus != GAMESTATUS_QUIT)
{
DrawCurrentFrame ();
GetUserInput ();
DoGameLogic ();
HideCurrentFrame ();
}
}
/* another thing, usually when you have a moving object, to do stuff real-time, you need to keep track of where he is, and where he is going. So you have x, y, and x, y velocities.
you get this:
struct MovingObject
{
float X;
float Y;
float XV;
float YV;
};
then, every frame, after X and Y have initial values, such as 0, 0, you add Xv to X, Yv to Y, and the Object has Moved!
that''s how they did pong, at least that''s one way of doing it. make a pong game, just to learn how, it''s easy, and fun! When the ball hits the wall, just negate the x or y value to bounce it in the other direction. So, if Ball hits right wall or left wall, do this.
Ball.Xv = -Ball.Xv;
if Top wall, or bottom wall do this:
Ball.Yv = -Ball.Yv;
gotta go.
*/
farmersckn
Yesterday is the past, tomorrow is the future. Today is a gift, that is why
we call it the present.
Yesterday is the past, tomorrow is the future. Today is a gift, that is why we call it the present.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement