Jump to content
  • Advertisement
Sign in to follow this  
Portishead

Understanding 2D game programming terms.

This topic is 3610 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

I started reading articles about 2D game programming today, and I wanted to see what I understand and if I understand correctly. Game Loop - What I understood from the articles is that the game loop is run as long as the game is running. Each second the loop draws the game again, changing what's needed to be changed(animations?). Also, the game loop always gets any events that are made by the user. (Keys, mouse presses). Each time the loop gets the events, it draws the game again according to the events. The engine - Every 2D game has an engine that it rellies on. It uses functions from the engine to draw the game and to handle events from the user. My question is - what engine is used for 2D games? How does the whole thing of using an engine works in programming(C#)? Did I understand the terms correctly? Am I missing any information about the terms that I must know to program a 2D game? Sorry for all the questions. : Thanks in advance for the helpers. :)

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Game Loop - What I understood from the articles is that the game loop is run as long as the game is running. Each second the loop draws the game again, changing what's needed to be changed(animations?). Also, the game loop always gets any events that are made by the user. (Keys, mouse presses). Each time the loop gets the events, it draws the game again according to the events.

Yes, it is an infinite loop where you:
1. Erase
2. Animate
3. Draw

Quote:
The engine - Every 2D game has an engine that it relies on. It uses functions from the engine to draw the game and to handle events from the user. My question is - what engine is used for 2D games? How does the whole thing of using an engine works in programming(C#)?

Well, I'm not 100% sure but an engine could be a set of functions that make your life easier when programming, in this case, a 2D game. You could rely on a Math engine (that handles all the math stuff in your game such as Matrix multiplication, inversion, etc), a Physics engine (that takes care of collision & response), a (2D) graphics engine (that takes care of the graphics initialization, shutdown, etc).

But there are also "game engines" such as XNA (C#) that handles for you all the stuff mentioned above and you can concentrate on the game logic.

Share this post


Link to post
Share on other sites
The basic "game loop":

while( running )
{
//Handle Input
//Update game logic
//Draw screen
}

As for "game engine", don't bother trying to define it or make one or probably even use the term. It's such a vague and nondescript term that it could refer to anything from manually drawing pixels to the screen to a programing-lite game-making tool (like Game Maker). Do not think that you need something called an "engine" to write a game. Do not try to write something called an "engine". Do not bother googling tutorials or anything about "game engines". Just go ahead and write the game already.

Share this post


Link to post
Share on other sites
Oh, sorry, I'm new to 2D games, didn't know much about engines.

So in the game there will be this three main functions:
-Drawing(Drawing the background, the player)
-Animating(Doing the animation - example - taking a line across the screen?)
-Events(Getting events from the user. Key-pressed events, click events and such)

Is that the way it works? [Generally]

And thanks for the help so far.

Share this post


Link to post
Share on other sites
They are all things that you may do in your game loop. You may also do more.

Think of the game loop as the driver for your game, that continues to execute until your game is finished. But the loop could easily be applied to a monitoring appication. Take input, calculate stuff, display readings, repeat.

I wouldn't get to caught up on it, once you get in and write some simple games the idea of using a loop will come naturally.

Share this post


Link to post
Share on other sites
Quote:
Original post by Portishead
Oh, sorry, I'm new to 2D games, didn't know much about engines.


Yeah, I didn't mean to sound angry, it's just that bothering with thinking about "engines" is almost always a waste of time. It's much better to just buckle down and program the game.

Share this post


Link to post
Share on other sites
Um, ok.
So how can I practice the game loop? What project should I learn to make to practice the use of game loop?

Another question -
I saw people talking about SDL in other topics. What is that?

Share this post


Link to post
Share on other sites
Pong or Breakout or Space Invaders are all great first projects.

SDL is "Simple DirectMedia Layer". In other words, its a library that provides you with a pleasant interface to many necessary things for making games. These include making windows, getting input, drawing, sound, loading images. It's also cross platform, so you can write code once (in theory, at least) and have it work on Windows, Mac, Linux, and some others. It's very nice, but it's written in C. You are using C#, right? There's Tao.Sdl which is a C# wrapper for SDL, but I can't say I'm real happy with it.

For C# on Windows, Microsoft's XNA is a good choice, though IMO I don't think it's quite as easy to just jump into as SDL. It's still very nice, and better than SDL in numerous ways.

But have you made several command-line programs yet? Those should be your first step, since they really are considerably easier.

Share this post


Link to post
Share on other sites
A game loop and engine are part of any game not just 2d

The game should redraw the scene every time it changes, which is quite often, because of animations and sprite movement.

Events (user input, this is usually done first)
Update (animations, movements, game logic, ai... )
Draw (background, characters, anything visible on screen)

For me an engine is the general code that can be used in more than one game. For example: sprite can be part of an engine, but code for a troll/ogre/spaceship/helicopter wouldn't.

Share this post


Link to post
Share on other sites
Ok well first i'd ask yourself do you know what a loop is, in a far as programming is concerned? Heard of 'for' and 'while' loops?

If not you should really start learning a language like C#, C++, Java or Python. Games are written in languages like these. You really need to be able to program, before you can write games. I would recommend browsing this site for ideas on which language to learn first, and finding a good book about it. Read up and then give it a go.

(Note i might not get this as accurate as possible) SDL is an API (Application Program Interface). Its basically a collection of functions and libraries to assist you in getting things to display on screen. Others include DirectX and OpenGL. If i'm right SDL is primarily a 2D API where as the other two i mentioned are mainly for 3D programming.

Edit: Man you guys are fast, maybe i'm just slow!?

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!