Game programming for windows in C++ or C# - c#

I just learned the basics of c++ and c#,just the simple basics of the language.And I want to pursue game programming can anyone please tell me where to start off I read somewhere that Direct-X is used for game programming and I downloaded it from Microsoft's website but I just didn't understood it.From where did you people started your game programming when you were just beginners or do I need to have a deep knowledge about the language or can I just start now, please suggest me.And I am in the first semester of my cs undergraduate degree.

Start coding now. You won't get deep knowledge without, well, coding! I'd highly recommend XNA. XNA is basically a .NET wrapper for DirectX. It is very clean and well thought out (This means C# of course).
Have fun!

From reading your comments to the original question, it would seem that you have fallen into the trap of setting your sights far too high. The game 'World of Goo' did not happen overnight. It took a long time using lots of third party libraries to do the video/audio/physics/gameplay elements and a very good working knowledge of programming in general and an understanding of the restrictions doing a game often imposes.
Now, this may seem like a negative response but the point is it is better to achieve something small than to fail at something big. Failure generally puts people off doing what they really want to do.
Byron Whitlock's advice of "start coding now" is the best advice. But, start off with something simple: a text based version of Guess the Colours for example, then some easy, non-realtime graphics like Othello / Reversi / Sliding puzzles then try something realtime like Tetris and then branch out into physics, audio, 3D and so on.
The key to becoming a great programmer is to get code finished and working (shipping is a feature!), learn from the code - see if there are better ways to do stuff and so on. Start small, finish some programs, get a morale boost, firm up your foundations and gradually add complexity from there.

Introduction to Game Programming in C++ is a good start.
Introduction to Game Programming with
C++ explores the world of game
development with a focus on C++. This
book begins with an explanation of the
basics of mathematics as it relates to
game programming, covers the
fundamentals of C++, and describes a
number of algorithms commonly used in
games. In addition, it discusses
several libraries that can help you
manage graphics, add audio, and create
installation software so you can get
started on the path to making both 2D
and 3D games.
If you want to start with C#, which is recommended for beginners, you can use XNA, which is quite simple to learn, and a good book is Beginning XNA 2.0 Game Programming: From Novice to Professional
Would you like to create your own
games, but never have the time to dig
into the details of multimedia
programming? Now you don’t have to!
XNA makes it simple to create your own
games, which will run on your PC and
Xbox 360 console. Even if you don’t
know how to program at all, Beginning
XNA 2.0 Game Programming: From Novice
to Professional will teach you the
basics of C# 2005 programming along
the way. Don’t get overwhelmed with
details you don’t need to know— just
learn what you need to start creating
your own games right now!
The fast–paced introduction to XNA and
the C# language provides professional
developers a quick-start guide to
creating a commercial product using
XNA, as well as offering home
enthusiasts or hobbyists everything
they need to begin putting together
games in their spare time. You’ll
discover and understand all the key
concepts required to create smooth,
professional–looking results in a
range of gaming genres. Every reader
will come away with a firm foundation
onto which they can build more
advanced ideas.

I would recommend getting started with XNA, if you know a little C# it is an excellent way to get into game development and learn some important concepts that will help you out with other libraries. creators.xna.com There are several videos and tutorials to walk through, and it is all free when programming for the pc.

Maybe
www.gamedev.net is the best site of resources of game programming

I do not suggest XNA for learning how to do game programming. It hides many concepts that you need to have for a solid understanding of how it works from the inside.
First, learn thoroughly how to program in C++ and to understand how the Component Object Model (COM) works since this is what you will need to use in order to call the different methods in the DirectX SDK. Once this is done, learn how to create a window with C++ in Win32. After, find yourself some books on Direct3D for DirectX 9 SDK, game engines and architecture, multithreaded applications and design patterns. I would suggest DirectX 9 Graphics The Definitive Guide to Direct3D from Alan Thorn for Direct3D. This book is not a definitive guide, but rather a very good introduction to gain a solid base. Of course the book is a bit old, but the concepts remain very similar and it will be a good reference book for later on (plus it is cheap.. your budget might be tight with everything you have to pay for university :P) . Also, look at the documentation and samples from the SDK. Oh and before I forget, you will need some notions in maths (linear and vector algebra comes to mind)!

I suggest try using Silverlight as your game platform.
Check out this site http://dobbschallenge2.com/. It has a full functioning 2D platform game engine with source code and images. You can learn how parallax scrolling works, etc.
This way you can modify the game source code and slowly learn how it works. The game engine is quite simple yet the game is fun and includes awesome soundtrack :)

Check out the torque engine. It's inexpensive and takes care of a lot of the grunt work of making your game so that you can focus on making it fun. It's inexpensive and you can code in C#.

Related

Learn Actionscript 3.0+Flash Vs. C#

I have a background in python and I'm looking for a new language. I am almost only intrested in making games.
I have come to 2 languages. C# and Action Script.
C# because Microsoft allows you to make Indie XBLA games programmed in C# ONLY.
Action Script so I can make flash games for new grounds and ect.
What do you think is better to learn in the long run?
I would say C#. You'll learn the basics and then be able to write games for the Desktop (XNA), XBox (XNA), Mobile Devices (XNA and XNA Touch for the iPhone), the Web (via Silverlight), etc.
Flash only gets you limited exposure to each.
I have zero experience with C#, but I'll speak to AS3/Flash's #1 advantage:
For learning game development, Flash lets you make games very quickly, but more importantly lets you get feedback from a large number of users faster than any other environment (except possibly Ajax only). I started Flash programming a little over two years ago. In my first three months I learned AS3 and wrote a TD-style game that was eventually played by over a million people. During beta testing and after release I was getting constant feedback and tweaking the game mechanics and interface with multiple "releases" a day.
While not every game out there gets that much play, with Flash it is much easier to make something and have a large number of people actually play it and tell you what they like and what they don't. Learning how to make good games is harder than learning a different programming language.
To give a comparison of the two:
Action Script is useable only in Flash games (mostly run through web browser), which may be fun for some time, but it limits what you can do. On the other hand, it is probably the best way for developing web-based games.
C# and .NET allows you to write all sorts of different games (and is also more generally useful language in case you wanted to switch from game development to some other field, including web site development and various business applications). Regarding games, you can use it on:
Web based games (similar to Flash) using Silverlight
Desktop/XBox/Zune games using XNA Game Studio
iPhone games using MonoTouch (although there are some licensing issues recently)
By learning C#, you'll also learn .NET Framework (in general), which is (I think) a useful knowledge that you can benefit from in many situations (e.g. when looking for a job :-))
Why not learn both? I think programming a good game is harder than adapting to a new programming environment.
Also, if you get into Flash game dev, you'll probably want to check out Flixel.
C# is the nicer language (although AS3 and C# are similar) and has a wider range of uses than Flash but since you mentioned games only I would tend to say start with ActionScript 3.0 then move to C#.
Firstly we can ignore the fact that C# is useful for writing business apps since that is not relevant to this question.
C# offers game programming via XNA, SilverLight, and Unity3D compared to ActionScript 3.0 with Flash.
So why do I recommend AS3 to start with? Firstly 2D games are where you should start off and I think this is where Flash excels. The development lifecycle of 2D games is much shorter and tend to produce better gameplay. A lot of indie 3D games suck since they fall short of realising what they started out developing. It is relativly simple to get a 2D game up and running and there is a lot of game engines, physics engines and tutorials available. It is also the platform of choice for artists (that can make all the lovely looking levels, characters etc). Second, the flash platform is the most accessible to your audience. No point making a great game that people never play. Third, AS3 is faily simple to come to terms with.
From my experience the web games that I come across that I think are noteworthy tend to be made in Flash. Checkout Scary Girl and Machinarium.
For 3D or anything that you need the power of the GPU then C# with XNA or Unity3D is what you should be looking at.
I will add that if you are interested in very fast action style 2D games then avoid Flash.

2D game programming tutorials in C#

I want to learn about programming 2D games in C#. What are the best tutorials that are beginner oriented, written for C#, and preferably use GDI+ (or something equally simple)? I am relying on the experience this community has to direct me towards the best.
Books
Beginning .NET Game Programming
Beginning C# Game Programming
Links
Coding 4 Fun is a great .NET resource that has quite a few user-created games. They also have a book and a 2-D game primer
Tutorial Listing at C# corner
C# Game Tutorial for Beginners (video)
Link to more game programming e-books
Advanced Topics
The Farseer Physics Engine on Codeplex would be a good next step once you get comfortable with programming games. You could even end up contributing to the project if you like it enough. I'm sure they'd appreciate the help.
I watched these DNR TV episodes recently and thought they were very well done and informative.
http://www.dnrtv.com/default.aspx?showNum=165
http://www.dnrtv.com/default.aspx?showNum=166
These focus on XNA, which is definitely where I'd start if I was planning on creating a game. Their tutorial take you through:
creating a 2D game with:
collision detection
texture creation and usage
geometry creation
physics simulation (They use an open-source physics engine and show you how to use it)
If you haven't heard of XNA:
The framework runs on a version of the Common Language Runtime that is optimized for gaming to provide a managed execution environment. The runtime is available for Windows XP, Windows Vista, Windows 7, and Xbox 360 [also can be played on Zune HDs].
XNA attempts to free game developers from writing "repetitive boilerplate code" and to bring different aspects of game production into a single system. wikipedia
Even if you don't want to use XNA, I think these videos will help learn about the concepts and techniques common to most (if not all) game dev. Oh, and it's all C# :)
Good luck!
This link seems reasonable ( if a little verbose ) - it's takes you through how to code a simple tetris-like game in c# using GDI+. I has code listings and links to download the source code.
I would start with learn a little object oriented architecture - this is a key to your ultimate success.
Then learn how to design the model - the entities in the game (characters and etc) in code
and the view - the 2D representation of them, and how to connect the two (data and command binding).
I would try using WPF and not GDI+.
The code project has a lot of good articles for beginners.
I would take a look at SDL.Net it's a pretty good games library for .NET (well a binding to a good library for the pedants ;))
It has a lot of resources on its pages right from beginner stuff to more advanced things like isometric engines etc.
It doesn't seem to have been very active for a while however what is there already is more than enough for even complex 2D games.

Xbox programming [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am learning the language c. After c I will probably move onto objective c and develop some iPhone applications. Then I was thinking about learning c# and xna.
How long do you guys think it will take before I can develop a pretty decent hitting or roleplay game for the xbox?
My friend is also learning game design s I will have a game designer and my other friend is going to learn code like me.
How long do you guys think it will take before we can develop a game like I said .
Any tips on books or? What kind of game engine we hould use? Anything at all so we can stratup and learn that you know of.
It depends on so many things that it's impossible to say. One tip is though that start small and finish your projects. It's easy to start too big projects that never gets finished.
12 is the right age to start - most of the good programmers I know started out young. I look out for it on CVs when hiring.
I started on a Spectrum 128k writing in BASIC.
A fully fledged game is a lofty goal, a worthy one, but one a fully fledged professional would struggle to attain.
I'd start with a simple game - a Tetris or Breakout clone, or maybe even something text based. Something simple will be better for learning the basics. You're learning the language as you go, so expect:
It will often be slow - you will regularly have problems that it takes a while to figure out. It's good that you have a friend leaning the same thing.
The code you wrote at the start will look rubbish later - be prepared to re-write as you get better. You'll start out making naive mistakes, but you learn from them.
That second point applies even to the best professionals when working with something new. No one gets everything right first time and you learn more from mistakes than successes.
And have fun!
Glad to see that you are enjoying programming. I think there will be a lot of different answers to this question ("Should I do C or not?") But I think its a good thing that you start by writing code in C. You will learn a lot of basic stuff that you might have passed if only going for the XNA framework right away.
BUT! Don't wait to long. The XNA framework is quite powerful and it makes it very easy to get started. I think you should ask yourself (including your friends) "what you think is the most fun part of developing a game?"
Is it the game design? graphical programming? just programming? making graphics?
Perhaps that answer will give you a hint about what to focus on.
Cause private projects should be about having fun.
This entirely depends on your talent and passion for the work.
Good to see some people getting enthusiastic about programming - and better still playing about with C. Starting out with C, even if it's to do basic "Hello World" style programmes, will give you a good basic understanding of concepts like memory management etc.
But as others have said - don't wait too long to jump over to C# and XNA: yes the frameworks are quite big and scary, but you'll be amazed at how quickly you can get things done once you get a basic grasp of the language.
A few points I'd like to point across:
Firstly, do not be discouraged or disheartened when something doesn't work, or when something breaks, or if you receive negative feedback (the proverbial "it sucks" review). If you are confident in your idea and more importantly, if you are enjoying it, keep going.
Don't expect to be producing awesome graphics and FPS style games from day one: but don't let that worry you. For big budget games, the "media" side (3D models, artwork, audio) are at least a big a job as the actual game programming, if not more.
Start with a good idea and be confident in it. Don't worry about graphics: if the game is good people will enjoy it. Look at the vast majority of "market place" games (iPhone, Android Marketplace, XBox, Facebook): they all have fairly basic graphics but are based on good solid concepts. And some of them make money, lots of it.
If you stop enjoying a particular task / project, don't worry about parking it for a while and moving on. More often than not you'll have an "eureka moment" (probably at 3am if you are like me) and come back to it with renewed enthusiasm.
RPG Maker is something cool you can try out. It'll let you make RPGs without programming, which will give you an idea of how games are designed. It'll also be easier to start on a PC than an xbox if you're learning.
I have a mate who is a game developer, working on state of the art games like "Call of Duty". Im not sure if the language is as important as learning the concepts and being active in the community.
My friend made it big by developing content for existing games and getting known that way. Its really hard to made a game that can compete these days but its not impossible. As Keith mentioned its important to start simple and learn the basics but its also equally as important to contribute online and to surround yourself with like minded people. That is how you will make your first break in, and thats all you need.
I have been a programmer for years now and I would say that I learnt 90% of what I know from others or online not from reading books. Books are great for reference. Take what you learn and apply it.
Im sure if you work hard and contributte online you will make it.
Good Luck!
This might be able to help you while you learn XNA and C#. I am trying to spread the word about my free open-source project called 'XNA Debug Terminal'. It creates a display on top of your game and allows you to look up values, invoke methods, or even watch values change in real-time while your game is running. I'm sure this could be of some help to you in learning what is going on in your game at various points. The website can be found here:
http://www.protohacks.net/xna_debug_terminal
If you like it, please tell other people. I, myself, have found it quite helpful in my own projects. The website tells you all you need to know about it.
Here's some good advice: LEARN to code in C (i.e. read a book on it or whatever) but thats as far as you should go with C. Learning C teaches you things you'll never learn in another language, and it helps you understand things you wouldn't fully understand without learning it, but it's not gonna be useful to you for much longer.
C++ is taking over C in the game world quickly (in fact, you could get away with saying that it already happened), and I have a feeling that we may see C# become a big player in the game world too, as computers are getting faster.
But like I said -- learn C, then move to C# or java (I'd go with C# for sure), and then pick up on XNA.
Also, when learning c#, look into the book, "Head First C#." It's a good one, and it does quite a bit of stuff with gaming.

Want to learn to write 2d games

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?
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.
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
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.
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.
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.
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
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.

What's the best way to get started in modern game programming and application programming? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to get started game programming in C/C++, or C# with DirectX or OpenGL. I'm not really sure what I want to get started, but a smallish project like a simple engine would be nice to get started with. Additionally, I would like to learn about designing applications in Windows with C#, .NET 3.5, and WPF. Utilizing C# and .NET, I intend to create a reasonably large project that would integrate with the windows shell. However, I do not really know where to start. Moreover, I'm well versed in C/C++, JAVA, and I'm taking an advanced Computer Science class focused on Algorithm Complexity and Classic Computer Science problems. Any help on where to get started would be appreciated.
Modern game programming is tremendously complex as a whole but it is also very fractionated in terms of division of labor which helps reduce this complexity. Modern games are usually too complicated and large for one person to have a detailed and in-depth knowledge of the entire process. There are a lot of specialties within game programming that you might want to familiarize yourself with and decide if there is a particular aspect you really like doing:
Game Physics Programmer
Artificial Intelligence Programmer
Graphics Programmer / 3D Modeling
Sound Programmer
Scripter (using in-house scripting for nearly all of the in-game events)
UI Programmer
Network Programmer
Tools Programmer
... and more.
Recently, for my Computer Graphics course in College we used the open source OGRE 3D engine. Not only is this an extremely robust 3D engine but it was a blast! Develop a medium sized game using it and you will get a good taste of many of the above mentioned game programming specialties. You'll find yourself doing 3d modeling, sound effects, physics programming, AI, the works.
Screenshot of a recent OGRE 3D Game:
alt text http://www.ogre3d.org/gallery/albums/album76/snapshot20081030015244.jpg
There are some caveats to the Game Programming world. I've often heard and read articles surrounding the industry talking about the long hours, the crunch time, the unpaid overtime and the relatively lower pay when compared to other types of programming. But honestly, if this is something you want to do then don't let those things get you down. I like to think that good pay and working conditions will come to most people who are sufficiently driven.
As far as school, you mentioned you were taking some CS courses. Take some math courses as well! Game programming is one area where Math is used extensively in several phases of development.
Most of the articles I have read involving the industry suggest that someone with no professional experience looking to get break into gaming should put together a portfolio of small games you have written demonstrating your abilities.
It is also fairly typical for junior game programmers to start out as the Tools Programmers writing in-house software for the rest of the game development team. Things like Map-Making programs, diagnostic tools, format conversion, etc. You can then work on advancing beyond this.
Good luck!
You might want to check out
https://stackoverflow.com/questions/174830/learning-game-programming
https://stackoverflow.com/questions/332650/open-game-dev-projects
If you want to learn about developing an engine, I recommend this book
:)
With C/C++ I'd say the NeHe tutorials are a great place to get started (OpenGL) and DirectXtutorial.com for DirectX. If you are leaning towards the C# category, XNA is the way to go.
A great site to help you further on the subject is GameDev. There are tons of aspiring developers just like yourself and a lot of people willing to help you in just about any aspect of game programming, good luck!

Categories

Resources