# Off-Topic Discussion > The Lounge > Tech Talk >  >  C++ for sprite based game?

## slayer

Alright, so I just found out about this thing called XNA Game Studio. It's used to make community games for the Xbox. It comes with a beginners tutorial and such, but I think it would help to learn some C++ or C# to help make the game I want.

Where is a good place to learn C++ or C# to make a sprite based side scrolling game? What kind of books should I look out for?

I want something specifically for making games. Something that has easy to follow beginner tutorials.

----------


## mrdeano

http://www.youtube.com/watch?v=tyVhn...eature=channel

Start there and follow every video. By the end of it you will be a Wizz.
Too bad there's like 60+ videos all around 9 minutes long.

----------


## ninja9578

http://nehe.gamedev.net/lesson.asp?index=01

----------


## Ynot

> Where is a good place to learn C++ or C# to make a sprite based side scrolling game?



C++ & C# are two very different languages
It grates when you bung them together like that

I mean, C/C++ I can understand (as the two are 80% the same syntax, and while different languages both will probably compile equivalent code down to the same assembly

but C# isn't even meant to produce binaries
it's meant to produce byte-code

Just thought I'd mention it

----------


## ninja9578

> but C# isn't even meant to produce binaries
> it's meant to produce byte-code



C# produces binaries, I've written many a dll for C# programs running our servers.

----------


## khh

> C# produces binaries, I've written many a dll for C# programs running our servers.



To quote wikipedia 
"By design, C# is the programming language that most directly reflects the underlying Common Language Infrastructure (CLI). Most of its intrinsic types correspond to value-types implemented by the CLI framework. However, the language specification does not state the code generation requirements of the compiler: that is, it does not state that a C# compiler must target a Common Language Runtime, or generate Common Intermediate Language (CIL), or generate any other specific format. Theoretically, a C# compiler could generate machine code like traditional compilers of C++ or FORTRAN. In practice, all existing compiler implementations target CIL."

----------


## Ynot

> C# produces binaries, I've written many a dll for C# programs running our servers.



Didn't say "couldn't"
said "not meant to"

the C# compiler for Linux _can_ compile to binary,
but if you want to do that, why the hell are you using C#?
better to use a more mature language, with better optimized compilers, greater library of code available, and wider platform support

----------


## slayer

So I should be using C++? Or should I do the OpenGL like Ninja posted?

----------


## Sornaensis

OpenGL is a library written in C.

Use allegro: http://www.allegro.cc

It has built-in functions for loading images, making GUIs, et al.

----------


## slayer

The program I'm using is the Visual C# 2008 Express Edition. I got it from http://creators.xna.com/en-US/

It's used to make community games for the Xbox 360.

Edit: Does anyone wanna be like my personal tutor? :x

There's no way I'm going to read all this crap.

----------


## The Invisible Man

> OpenGL is a library written in C.
> 
> Use allegro: http://www.allegro.cc
> 
> It has built-in functions for loading images, making GUIs, et al.



I wondered if I was the only Allegroite on this forum.

----------


## ninja9578

Allegro is good, but it's largely high level, you can't optimize it to the same level as OpenGL.

OpenGL isn't a language, it's a library, you use with with C++ or C.

----------


## Replicon

To just get into C/C++ programming, check out http://cprogramming.com/

For basic 2D sprite stuff, I recommend SDL http://www.libsdl.org/ (you can also set up OpenGL through it).

For openGL, you can go to NeHe like linked earlier, HOWEVER: His code tends to look like crap. But that's for a reason (I don't actually know what the guy's actual production code looks like).

That's something important to be aware of when reading random/any tutorial online. They write hacky, poorly-laid-out code because they're there to demonstrate how the library works. However, you should never confuse tutorial code for well-designed, scalable, high-quality code.  :smiley:  It's usually some piece of shite that is NOT meant to be expanded upon as is.

Sooooo, to remedy that, don't do what most people do. Most people do this:

1) Learn language basics (enough to write something that takes input, and prints basic output)
2) Start learning openGL through NeHe or whatever other tutorial
3) Decide that they will code a "game engine"  ::lol::  laughable

Instead, do realistic, small projects that you can drive all the way through to completion. When you're more comfortable with code, and moving it around and stuff, read up on design patterns so you start having a better idea of how this stuff should be laid out.

Also, if you're serious about C++, look up "Effective C++", "More Effective C++" and "Effective STL" by Scott Meyers, who will also give you some fantastic tips on how not to write shitty-ass code.  :smiley: 

Same goes for Java - you should not be doing any serious Java work without skimming through "Effective Java" first.

(note: all my advice above is more for the point of view where you'll be eventually doing work that you'll distribute and others will have to update, so don't feel discouraged or anything - just know how deep the rabbit hole goes, and don't be too ambitious with your projects too early)

----------


## slayer

Ok well, so far, I've managed to draw my own background.

Next I'm going to learn how to make a person on the screen and move him around with the arrow keys.

Then I'm going to try to add blocks with collosion and then add gravity.

Edit: Yay I made a square :3

How would I make the square tile across the bottom of my screen?

----------


## Needcatscan

> Ok well, so far, I've managed to draw my own background.
> 
> Next I'm going to learn how to make a person on the screen and move him around with the arrow keys.
> 
> Then I'm going to try to add blocks with collosion and then add gravity.
> 
> Edit: Yay I made a square :3
> 
> How would I make the square tile across the bottom of my screen?



Did you decide on a language?

BTW, easiest collision detection if you are using C# is using the Rectangle Struct and the IntersectsWith function.

----------


## ninja9578

Pixel collisions is easiest.

----------

