Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Want to learn to write 2d games

Tags:

c++

c#

2d

xna

directx

Hey stackoverflow Community! I learned the basics of C# (i can write some Form-Applications) and now I want to learn how to write 2d games. I don't know where to start. Is there a engine that's good for 2d games? After learning the basics of 2d I'll want to write simple games which work under windows and linux (that whould be cool, linux :) ).

I asked a friend who is into programming and he said I should use XNA with C# (but that would only work on windows). After googleing I found out that OpenGL with C++ whould be best to write games for linux, since there is no DirectX/XNA. And I haven't used C++ yet, that whould take some time to learn, again.

Is there something you can suggest? Maybe an other engine? I just installed XNA and took a look at the demo game (Platformer), that code isn't hard at all. Is XNA good for 2d games?

like image 572
CSharpBeginner Avatar asked Sep 26 '09 16:09

CSharpBeginner


2 Answers

Take one step at a time. When you're starting out you don't need your code to work on every platform. It doesn't matter whether it uses OpenGL or DirectX, because you're going to have your hands full creating a game to run on one platform with one graphics API.

Second, don't worry too much about "engines". You don't need an engine to make a game, and often, it'll be more trouble than it's worth. The whole obsession with "engines" is fundamentally a bad idea. If you try to get one single software component to support every bit of functionality you need for a game, then it's not going to be worth using for any of them..

All you need is:

  • a programming language you're comfortable with. It sounds like this is C#, so stick with that.
  • Some way to put graphics on the screen. The .NET library can do that to some extent, but some higher level library will probably make it easier. You could use XNA or SlimDX or another Direct3D wrapper. Or you can give SDL.NET a shot. Or you can write your own. The capabilities you're going to need are pretty basic and every graphics library, 2d or 3d, will let you do it.

You especially don't need anything which is "good for 2D games". XNA is able to put graphics on the screen, so it does what you need. If you also understand the code required to use it, then XNA is good enough. Don't bother trying to find the "best", or something that has "awesome for 2D games" as a selling point.

like image 200
jalf Avatar answered Sep 28 '22 21:09

jalf


Probably the easiest and most accessibly platform is Flash. Easily distributable and rather quick to learn for games (judging by the sheer amount of flash games available on the web).

I agree with jalf. Don't start thinking about engines. Engines are a complex beast and considering your programming experience is small, it can get very overwhelming very quickly. There's a lot of stuff that goes into games and the design patterns that are involved in them tend to be much different from those of say a typical application. And OpenGL type of stuff gets very complex when you start talking about things such as hit detection.

Another direction you could take is instead of starting your own game from the ground up, you could try making a mod to something like Half-Life 2, or Unreal. That gives you a basic platform that you can change and see how it behaves. In the mean time you'd be viewing other people's code and seeing the intricacies of game development.

Here are a quick links I pulled off of a Google search with regards to flash gaming. I'm sure there are probably quite a few books available online as well with regards to creating a game in flash and other languages.

  • http://www.flash-game-design.com/
  • http://www.tutorialized.com/tutorials/Flash/Games/1
  • http://blog.onemorelevel.com/?p=12
like image 43
MunkiPhD Avatar answered Sep 28 '22 22:09

MunkiPhD