Want to learn to write 2d games
Asked Answered
L

7

8

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?

Lohr answered 26/9, 2009 at 16:27 Comment(1)
Take a look at Tao, mono-project.com/TaoGaff
P
20

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.

Polyhymnia answered 26/9, 2009 at 16:58 Comment(6)
Add the Tao Framework for making OpenGL and some other cool cross-platform APIs to available to .NET languages, that almost brings cross-platformness for free ;)Genisia
Tao is nice... here's one of the nicer tutorials for XNA and old Managed DirectX for C# I've found: riemers.net/eng/Tutorials/xnacsharp.phpCowshed
Well, my point was that cross-platofrmness doesn't matter. Is Tao easier to use than other platform-specific frameworks? if yes, then that is why he should use it. If not, then he shouldn't use it no matter how many platforms it'd run on.Polyhymnia
In principle, yes. assuming you stay within the bits of .NET that are supported by Mono. And of course, graphics code can be very fickle. You'll probably have to spend quite a bit of time debugging it because it mysteriously renders differently on Linux than Windows. But let me ask again, why do you need this, your very first, game to be cross-platform? Did you also translate everything you read in first grade to Spanish, Russian and Chinese?Polyhymnia
Thanks, I think I'll use XNA. Already wrote a small game, nice framework :)Lohr
Cool. I've heard good things about it, and it's well supported. And later on, once you have a game, by all means make it run on all the platforms you like. But make it run on one platform before you worry about two or three platforms. you're going to have your hands full as it is ;)Polyhymnia
A
4

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.

Aspirin answered 26/9, 2009 at 17:7 Comment(2)
Are there any good, free tools for this (Flash) like Visual Studio Express for C#? I'd really like to know, as Adobe Flash CS seems a little bit expensive.Genisia
There's Flash Develop and FDTNoncooperation
T
4

Someone mentioned Flash, which is a good suggestion, but a bit expensive. If you'd like to do some Flash/AS3 development for free, I'd recommend playing with Flixel. You'll also need FlashDevelop, which is a nice (also free) IDE. The Flixel site has a lot of good resources to get you started.

Tharp answered 2/10, 2009 at 16:10 Comment(1)
Flixel is great, perfect for 2D games. You can use FlashDevelop, but also FlexBuilder or even just your favourite text editor like Emacs: just use the free Flex SDK command line tools. If you go the text editor + command line way though, you'll have to use a build system like Make, Ant, or Rake.Alongside
H
2

If you're thinking about pursuing a future in graphics programming, I would pick OpenGL for the following reasons:

  • OpenGL is implemented on Windows, Mac, Linux, and even PlayStation 3. (extremely versatile)
  • Once you're comfortable with 2D programming, you can move onto 3D and stay with OpenGL.
  • OpenGL is equally as fast in terms of performance compared to DirectX.
  • C++ is a part of every collegiate-level programming curriculum.*
  • I think employers respect knowledge of C++ more than any other language.

The learning curve may be higher, but your time will be well-spent.

* If your college doesn't have C++ as a part of their programming curriculum, you are an outlier.

Historiated answered 26/9, 2009 at 18:5 Comment(4)
Don't you think it should feature as a consideration that 99.99999% of all PC games use DirectX, not OpenGL? And virtually no games on PS3 use it, because Sony's OGL wrappers suck and developers generally work directly against the GPU instead.Polyhymnia
I'm sorry, your point is? That over the last decade (the list includes the original Unreal, from 1998), a whopping 73 games have been made which support OpenGL? (Note that many of the ones on that list also support DirectX). Are you seriously suggesting that this list constitutes the majority of games? That your average game developer uses OpenGL for their PC development? That OpenGL is what you should go for if you want "a future in graphics programming"?Polyhymnia
If OpenGL is so bad, why did you include it as an option in your answer? "It doesn't matter whether it uses OpenGL or DirectX"Historiated
To answer your last question, yes. The list of software also includes massively prevalent modern titles such as Google Earth and Photoshop CS4. Anyways, if you read wikipedia's comparison on DirectX vs. OpenGL you will see that they are equivalent in terms of Ease of Use and Performance. By choosing DirectX you stand to gain nothing and only expose yourself to vendor lock-in.Historiated
F
1

From my experience it's far better writing the basis of your game first in a form of simple application (perhaps text based) and then building graphics on top of that just by trying out bits and pieces from tutorials. That way you will always have a working skeleton that you can play around with and you don't immediately complicate yourself with all the graphics calls.

Other point is motivation: if you always have a working app it's far more satisfying to watch it slowly grow and develop rather than being frustrated by constant "works/doesn't work transitions" and always awaiting all the bits to come together to form something remotely complete.

As far as engines go: DirectX and OpenGL these days are kind of engines themselves. They let you do a lot of primitive work very easily (get a model from 3ds Max and load it into your app in 1-2 lines of code), for a small game you won't need anything else.

I also agree with MunkiPhD: Flash would be a very good platform for a 2d game. It's very simple and lets you get away with all the boring graphic programming. However, ActionScript-programming is not anywhere near "heavy-duty" programming with C-family languages and proper dev. platforms. ActionScript frustrates me every time I see it.

Fiery answered 27/9, 2009 at 5:25 Comment(1)
I'm not new at programming, I program php for 5 years and started windows/linux prog. half a year ago. I wrote some progs in Delphi (I hate it's syntax) and C#. So it would not be a problem to write a game. I asked here to find out, which engine/framework/whatever I should use. I know that Flash is not hard to code, but I want to code in C# :) Thanks so far..Lohr
C
1

If you want to focus on 2D games and keep using C# for now, AND be able to have your friends play your games on Mac and PC, had you thought about using Silverlight?

Using Silverlight would get around some issues such as installation.

You might try a creating a few games in Silverlight and then after getting your feet wet you'd be in a better position to decide what other tools you'd like to learn next. With Silverlight 3.0 being recently released there is actually an influx of people trying to see how far it can be pushed for gaming, which might help you get questions answered. If you decide on this route you can post here or on sites like Silverlight.net

DISCLAMER: I'm not sure what the status of Silverlight for Linux

Capparidaceous answered 27/9, 2009 at 9:6 Comment(0)
A
1

Flixel does rock - you can get a 2D game up and running with a minimal amount of code. You can find a detailed tutorial that steps you through the process of creating a simple platform game using Flixel here.

alt text

Anapest answered 7/12, 2009 at 3:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.