I'm looking for a nice C# tut

i think the name of the topic explains it all. I’m new to programming and all the tuts I find completely emerge me in it, while I don’t understand some aspects. I want one that will gradually teach me how things in C# work. Can anybody help?

Found this:
It’s an online C# book. I don’t know if it’s any good.

I would recommend finding someone who knows C#. Sometimes books will not explain things well enough (as if they were a review to people who already know the language instead of teaching it to complete beginners), so it’s very helpful to be able to ask someone a quick question occasionally. Just don’t rely on them to help you through everything in the books you’re learning from, because you’ll get a better understanding if you figure things out yourself and they probably won’t like to be bugged.

Also, don’t think that by reading the lessons you’ll have them mastered enough to make something practical. They’re teaching you the details and workings of the language and nothing more, so the first few examples will probably just show you 10 different ways to write “Hello world” on the screen. Actually applying the different parts of the language to make a program you want to make isn’t what books teach, and that takes a lot of practice and understanding. Just like how reading a book on how to use Photoshop won’t make you an artist.

I use C# first you need a good compiler, (the only one in existence to my knowledge comes with the .NET framework) Notepad, and some patience.
First ALL programs MUST be in a class for example

class _TEST
 static void Main()
   System.Console.Write("Hello ");
   System.Console.WriteLine(" World\n");

I suggest starting small, for example a simple Calculator app, or if you’re interested in game design a Breakout clone

If you want and IDE i suggest Visual C# Express Edition 2005

sorry for the late reply, but thanks for the link! i’ll be sure to check it out :smiley:

thanks, also for the help, although i already have visual c# from mason’s topic (thanks mason!).

so class is another name for a program?

what does static void Main() do?

Ignore the wrapper code around the program (for now). Just know that within the “static void Main()” method of some main class should go the instructions for your program. Follow the beginning examples that the book gives to see what kind of instructions that generally means.

If you want to know ahead, though, “classes” don’t mean programs, but instead object types. For example, you might have a class named “Bomb”, and then your program (inside the Main() method) places instances of that class around and calls their “Explode()” method. The method “static void Main()” appears to be the required method by the language that’s called once everything is ready when the program loads. Think of it as just “where stuff happens”. It does what you tell it to. If it’s like C, the program won’t compile without it.

Edit: Looking at that online book I posted again… there doesn’t seem to be much of an order to do the sections in, and the introduction to the basics of the language is extremely brief. Hmm. Do they expect you to know BASIC or what? Well, keep asking any questions you have and try to search for a better online book. :stuck_out_tongue:

so if i were to make a simple space-shooter the game would go something like this?-

class enemyship
.....method attack
..........if timer = 100, then new bullet enemyshipx+5,enemyshipy
.....method hit
..........if collision with bullet, then hit = hit + 1
..........if collision with bomb, then hit = hit + 3
.....method destroyed
..........if hit >= 3 then delete enemyship
..........new explosion
.....method bomb
..........if timer = 500, then new bomb enemyshipx+5,enemyshipy
class yourship
.....method attack
..........if keyzdown = 1, then new bullet yourshipx-5,yourshipy
.....method destroyed
..........if collision with bullet then delete ship
..........new explosion
..........if collision with bomb then delete ship
..........new explosion
.....method bomb
..........if keyxdown = 1, then new bomb yourshipx-5,yourshipy
.....method moveship
..........if keyleftarrowdown = 1 and yourshipx > 10 then yourshipx = yourshipx - 5
..........if keyrightarrowdown = 1 and yourshipx < 230 then yourshipx = yourshipx + 5
..........if keyuparrowdown = 1 and yourshipy > 200 then yourshipy = yourshipy + 5
..........if keydownarrowdown = 1 and yourshipy < 230 then yourshipy = yourshipy - 5
method bullet
..........bullet = bullet + 5

class spacefightergame
.....method main
.....activate class enemyship
.....activate class bullet
.....activate class yourship

i hope thats at least close to what it’s supposed to be like -.-

considering that is psuedo code you have a basic idea about how it works, C# however is more complex yet surprisingly easy to implement, Treat a class like a cookie cutter, A snowman cookie cutter will make a snowman shaped cookie. So if I had a player class I would have it store things like X, Y coords, delta time and other mumbo jumbo that a player class would need and have it inherit from a sprite class that has things like the filename for a sprite, frame count, origins, and offsets.

Oh another important thing to note. Overloading a function is a good way to get more for your money without having thousands of different functions that do basically the same thing.

So if I a had a function that drew text to a screen already and I wanted to add scaling to it all I would do is copy the current function and add the routines to scale the text call the same functions as before but also add the scale like so:

drawText("This is text", 100, 250) // Unscaled
drawText("This is text", 100, 250, .5, .5) // scaled

Note that I used the same function BUT add two other arguments. That is because of overloading. I’m sure that the book covers it in more detail. It’s after 9 here and my mind isn’t up to snuff atm

Oh and the style that I wrote this psuedo code in is called Camel Notation because of the capitalized letter on the second word

HP: Actually, you’re pretty close. You could probably get that to work when you convert it to C#, with some alterations and additions.

Just keep in mind, however, that games are slightly different from the traditional programs you’ll make when you learn the language. They still read from top to bottom incredibly quickly, but they have “game loops” and OS-specific sleep() functions/methods to get a framerate set. In other words, that’s what your Main() method is missing–after initialization of objects and variables, it should begin a fast loop to update the game’s current state 30 or 60 times a second. Don’t ask me how to do that in C#… but if I were you I wouldn’t try that quite yet, as it’s a mess to try to get into OS, graphic, and game stuff. I would learn more of the language first and build a few text-based games.

However, you have the idea of how the game logic would work instruction-wise correct. Timing, destruction, key checks, simple, boundary collision, etc. You’ve got it all down pretty nicely in pseudo-code; now your goal is to learn how to translate it to C#. :stuck_out_tongue:

hehe. thanks, but that seems to be the part i have the most trouble on. heh.

this has nothing to do with C#, but i didn’t want to make another thread. When you create a 3d model, you have to apply a 2d texture to it, called UVW mapping. The textures I’m coming up with look too much like sprites and I want to make a more “WoWie” style of it, like
(although this one’s from WC3)

would C# for dummies provide a useful reference book for me? have any of you all gotten it that could give me some info on it before i go scout it out?

happy new years everyone (this is a hidden bump xD)

this teaches how to make console programs. does the same thing apply for game programs?

Um, I don’t think so, isn’t a console app in the MSDOS box thing?
Have you downloaded the PSDK?

Well, making games would be quite different than making a console application, especially since you have to instantiate a window on your own, but at least you can learn some of the keywords when making a console app.

It depends on what you’re doing in the console app. If you’re making text-based or ASCII-based games in it–like black jack, poker, the quest for ye flask, or tic-tac-toe–there’s a lot more in common with real-time graphic games than if you’re making, say, a demonstration of how to find the sum of two variables and display that number to the console window, chapter 1, example 1.4, page 13.

Two main differences are input and output. There isn’t a console anymore, so there’s no Console.Write() or Console.Read(). Instead you use other library-specific functions to get stuff on the screen and get user input. Algorithms, math, logic, and the language itself don’t really change… At all. There’s just a lot more you have to do to get a game with graphics working, especially real-time.

well, i bought it today. i read the first little bit. it looks like it will be very helpful =D

also, i know the blitz BASIC language but i dont have a compiler (just a reader). Does anybody know a free blitzBasic compiler that i could download? ^^

I think that this will be very useful for me this summer once when I graduated form High School. Then I wll have penlty of time to get more money and work on C#.

it can be complicated, but very rewarding =]