views:

443

answers:

7

I want to write a simple game like pacman in C# in order to learn the new language. However, I don't know how to make a circle move? Which part of knowledge in C# is needed?

+6  A: 

You should check out XNA Game Studio from Microsoft. It's a version of Visual Studio that's targetted especially for writing games. You use C# but get a lot of things for free - graphics, sound, timing...

Here's a tutorial for making a ball move in XNA.

bzlm
Remember he wants to learn the language from start, maybe pointing him at XNA will be a bad idea, don't know. Maybe understanding the fundamentals first would be a good idea! :)
Filip Ekberg
I was thinking about suggesting this, but having spent some time with it recently I'd have to say you need some background in C#, as well as other stuff like matrix transformations, in order to get going on it.
Will
+4  A: 

The simplest way would be to move your circle a small bit with every tick of a timer control.

Galwegian
aww.. this won't progress far from moving the circle only..
thephpdeveloper
+1 for actually answering the question, and not imposing an entirely separate framework on a learner who only wants to learn the language.
JimDaniel
first he needs to figure out how to render a circle...hehe
Stan R.
+1  A: 

You probably want to look into XNA - http://creators.xna.com/

Simply download the studio, install, then run Visual Studio C# (mine is Express Edition).

So when you run, you create a new Windows Game Project and you've created your first game.

Good to read up some books and articles on XNA.

Book: Microsoft XNA Game Studio 2.0: Learn Programming Now! by Rob Miles.

thephpdeveloper
Also check out Chad Carter, who I recently saw at a code camp: http://xnaessentials.com/
Will
A: 

Here's an answer to a question about a radar-type game that demonstrates generally how to do this in C#/WinForms using GDI+ (with a sample and source code):

http://stackoverflow.com/questions/1284694/what-would-be-the-best-way-to-simulate-radar-in-c/1321945#1321945

MusiGenesis
+1  A: 

if you mean how to move an object around in a circular movement, then you just need math knowledge:

 int circlePosX = centerX + Math.Cos(degrees) * radius;
 int circlePosY = centerY + Math.Sin(degrees) * radius;

radius is here how big you want the circle to be, and degrees is the position ion the circle the object is moving.

Toad
Aaaah, I remember the good old days where I plunked a quarter in a Pac Man machine so I could just watch him move around in a circle. Those were the good old days.
Will
hahaha... Thats what I was wondering too... (why would he want a circle movement in the game). I never realized he was referring to pacman. Who ever refers to pacman as 'that circle' :^)
Toad
+2  A: 

Well for a simple single player game like that some of the most important things you need to know about are data structures and GDI.

Data structures are important because you need to store information such as what does a map look like? Where are the walls? Can you go from one end to the other? How does the map draw itself?

GDI is used in C# to draw. This uses the Graphics context. You'll find lots of examples online, and I'd suggest checking out BobPowell.Net GDI+ FAQ to avoid some of the common mistakes.

Ian
+2  A: 

If you want to learn a new language stay away from all fuss and just look into the most essential parts.

Having knowledge about previous programming languages helps a lot, espesially if one of those are Java.

You don't need to look into XNA for this, all you really do need is to Start Visual Studio, create a new Windows Form, drag over an PictureBox and start playing with the KeyEvents.

Your game does not have to be awesome for you to learn the very basics of C# and .NET. And you certainly don't need to dig down in the deep jungle of XNA!

Once you have your form up and running with a PictureBox or two and you have conqured the Event-system, take a look at the other fundamental parts of .NET that makes your life easier. Properties, Generics, Data Sources and much much more.

Filip Ekberg