Archived

This topic is now archived and is closed to further replies.

Moogle

Okaaay, Can anyone tell me...

Recommended Posts

Moogle    122
Can anyone tell me what I should do now I mean I know C++ and I know the SDL i need to know to load BMPs and put them on the screen but what about the acctaull GAME. It bugs me hard. I understand the game loop but what do you do in there !!! None of my books explains that !!! I want to make an actaull game. Argh!

Share this post


Link to post
Share on other sites
Kaijin    163
He''s right though, none of these so called games programming books actually show you how to make an actual game.

Quite often they just show how to write an engine and how to do a few bits of AI and physics here and there but they never show how to put it all together which personally I think should be a big part any general games programming book.

- Kaijin

Share this post


Link to post
Share on other sites
Promit    13246
Take a course in C++ data structures if you havent already and another in advanced OOP, or learn it yourself, its not that hard. Then buy The Zen of Direct3D Programming.

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites
Kaijin    163
That still won''t help him to write game code. I think he''s looking more for information about how to write game logic and putting it all together.

- Kaijin

Share this post


Link to post
Share on other sites
Xanthen    115
Programming isn''t about taking bits a pieces from this and that code putting it together and working computer magic. Eventually you are going to have to program some lines of code for yourself. Starting on something is actually one of the hardest parts of programming. Knowing where to start can be daunting when the whole project is ahead of you, but you can never get past that if you don''t make the leap and start it for yourself. Personally I usually start with a simple rotating cube or triangle display tutorial and start adding things. After you''ve added quite a few pieces you''ll already have a foundation you can work on. Thats when I go back and create my data structures and rewrite core management code such as texture loading and handling. But you have to start in order to get anywhere.

Share this post


Link to post
Share on other sites
zipless    122
Then go buy a book on how to make games. There are books that do this, they contain nearly no code or programming stuff but just rant on about how to design and plug bits together.

If the worst comes to the worst you could just figure it out yourself. It's not like you going to try and create Quake 4 (are you?) Aim small at breakout or somthing similar and put your design down on paper. Later think what you need to do every turn, check for collisions, move all the objects, animate stuff etc. Once you've got it all down on paper in front of you thing fit together much easier.

A good tip would be to keep you main loop simple, just call 10 functions or something similar and place all the complex code in there, if you do that it's far easier to track down problems.

I don't mean to sound harsh but if you don't think you can't manage to figure it out yourself then you might want to try learning a bit more programming first.


zipless

Edited by - zipless on January 3, 2002 11:07:19 AM

Share this post


Link to post
Share on other sites
Kaijin    163
quote:
Original post by Xanthen
. Eventually you are going to have to program some lines of code for yourself. Starting on something is actually one of the hardest parts of programming. Knowing where to start can be daunting when the whole project is ahead of you, but you can never get past that if you don''t make the leap and start it for yourself.



That''s very true but there''s nothing wrong with giving people a helping hand. While it''s good to learn things by yourself and from your own mistakes it''s also good (and often faster) to learn from others examples (and mistakes ). That doesn''t just apply to programming.

Games programming is quite different from other kinds of programming so some people find it difficult to adjust to the way of thinking.


quote:
Original post by untalkative_monkey
one...two...three...FOUR words, Game Architecture and Design.
(its a book)

...go on and live with no regrets, you only have one life...



Glad you learnt how to count Yeah, I have that book. It''s a very good book but my point is if a book has "Game Programming" in the title it should teach you how to put an actual game together not just an engine. Just my opinion.

And just for clarification, I''m not compaining that I don''t know how where to start. I''m just saying that these books that teach you how to make a game should live up to their claims.

- Kaijin

Share this post


Link to post
Share on other sites
Anesthesia    122
Hello Moogle,

A game loop usually consists of code to update and flip the screen from back to front in a double-buffer system, check the event status of the keyboard. Look up events in the SDL documentation to create an event loop using SDL_Event. Also for a crude way to slow down your game loop, look up SDL_Delay, which can be put at the end of your game loop. Here's a pseudo example

SDL_Event event;

while(!quit)
{

clear out sprite's last known coordinates;
show your sprites at new locations (SDL_BlitSurface);

switch(event)
{
case QUIT_DETECTED:
quit = true;
break;

switch(check the keyboard for keypresses)
case upkey:
decrease the sprites y-coordinate;
break;
case downkey:
increase the sprite's y-coordinate;
break;
}

SDL_Flip(screen);
SDL_Delay(some length of time);
}

Again, look up SDL_Delay, SDL_Flip, SDL_Event and keyboard input. A game loop is just a way of updating all of data in your game world and also checking for user input so that you know how to update aforementioned data.

All of this is available in the SDL documentation. That will get you started, but you need collision detection, physics engine, AI, etc.

To move a guy around the screen, simply check for keypresses up and down and key releases thereof. Turn keyboard repeat on (look through the list of functions) and program your loop so when you press a key it will update some variable corresponding to the sprite's location. Then erase the bitmap you drew on the screen and draw a new one at that location... It's a good way to start but probably not the best way to do everything.

Good luck!

Edited by - Anesthesia on January 3, 2002 4:53:32 PM

Share this post


Link to post
Share on other sites
Moogle    122
Thanx for all the great input!

But what I mean is things like collision detection and AI.
I can read up on A* and bounding boxes but how the hell do I put it in a game?

Share this post


Link to post
Share on other sites
Anesthesia    122
There are several ways you can do collision detection in your game loop. One is to organize your game objects into a collection and have each object check all of the other members of the collection for a collision using a simple group of if statements. This collision checking can be programmed into your objects in the code where they are displayed to start off with, but when the game becomes more complex you''ll want to put the code in its own member function; if you put it in the display code, checking will occur each time the bitmap corresponding to your game object is redrawn. You could put them directly in the code of the game loop, but I prefer the uncluttered approach to the game loop. After you have determined that your object has collided with another object, set a flag on that object like:

object[1]->state = HAS_COLLIDED. Then in the part of your object that displays your bitmap on-screen, check the state of your object and have it show the picture(s) corresponding to whatever state the object is in.

You can give an object multiple states simultaneously by using a bitfield with an OR (|) statement. Ex. Object[1]->state = HAS_COLLIDED|IS_FIRING;

Obviously you don''t want to actually "set" two states at once, but you do want to be able to allow your object to maintain more than one state at a time. What if, for example, your ship was firing at the same time it got hit with shields on? What if it was firing, using boosters, and got hit with shields on? If you use an integer, you can have thousands of states at the same time, if you so desire.

As for AI or pathfinding, you just check for mouse clicks instead of keypresses. For example, if you are doing a game like Warcraft 2 you want a unit to move to where you clicked on the screen. You would first check for a mouse click event in your game loop. Then you would locate in your game world (if your game world is bigger than a single screen) where you clicked. You would do this by getting your mouse x and y coordinates and adding them to your position in the world buffer. Then you add a member function to your Peon object that will update the Peon''s location member variables based on where your A* code suggests to move it to. The member function that shows your sprite will then be called in the game loop and the sprite''s position will be updated accordingly.

So basically, you''re just trapping mouse buttons and figuring out where the pointer was at the time in the game world and passing that information off to your A* algo, which will update your character''s location variables, which in turn will be redrawn automagically in the game loop...

It''s all a matter of putting the code where it belongs. For a more structured approach, you can make member functions to do AI, blitting, pathfinding, etc, and make one function in your object called Update(), which will be called from the game loop, which in turn will call all the other functions necessary for the upkeep of the object.

Later

Share this post


Link to post
Share on other sites