What the heck is C#?! (I want to learn it!)

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

What the heck is C#?! (I want to learn it!)

Post by dandymcgee »

Okay so I have a basic idea of what C# is. I've been using C++ for a little over a year now, and I'm familiar with the IDE's interface for the most part due to Visual Basic experience (they made me do it!). I have no clue where to start though. I'd like to just jump right in, as I don't feel I need to read another 200 tutorials explaining what a function is, or a variable, etc. Rather I just need to learn the syntax.

The only projects I ever made in VB contained moving image boxes, labels, buttons, etc. so what I don't understand is how do I draw "real" graphics in a window created in C#? Is there some sort of "OpenGL" control that I just paste on my form, or do I initialize something in the code? For instance, Mar, how are you drawing tiles/levels in your new map editor, which API do you use and how?

Feel free to tell me how completely ignorant I am, as long as its in a way that helps me to understand C# better, even if it be just a smidgin'. ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: What the heck is C#?! (I want to learn it!)

Post by programmerinprogress »

I believe for shapes and images you use the GDI (graphics device interface)

In all honesty, when it comes to basic programming, the change isn't as odd as it switching to and from C++ to VB (easy but a royal pain in the ass if you're used to putting a semicolon after each statement)


I never got round to full blown C# excellence though, I made a few things in it, and then decided I want to use something a bit more low-level, and ch-ching! I switched to C++ full time ;)

Good luck with it anyway, I wish I could say I was tempted to try C# again... but if anything i'll be trying java because that's what they teach at my university in september (which believe me, after learning C++ for 2 years, i'm pissed about!)
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: What the heck is C#?! (I want to learn it!)

Post by MarauderIIC »

dandymcgee wrote:Okay so I have a basic idea of what C# is. I've been using C++ for a little over a year now, and I'm familiar with the IDE's interface for the most part due to Visual Basic experience (they made me do it!). I have no clue where to start though.
Microsoft Visual Studio -> File -> New Project... -> C# :)
I'd like to just jump right in, as I don't feel I need to read another 200 tutorials explaining what a function is, or a variable, etc. Rather I just need to learn the syntax.
It's pretty much VB + C++ = C# with a few conveniences and minor differences (as well as customary naming differences). Everything must be in a class. Which is fine, since your forms are a class of their own. If you really want a set of global functions, you can make a new class (add new item... class) and make it "public static MyClass". Then you can go MyClass.MyFunction().
The only projects I ever made in VB contained moving image boxes, labels, buttons, etc. so what I don't understand is how do I draw "real" graphics in a window created in C#? Is there some sort of "OpenGL" control that I just paste on my form, or do I initialize something in the code? For instance, Mar, how are you drawing tiles/levels in your new map editor, which API do you use and how?
The tiles in the tile controls are just drawn onto a PictureBox using a Graphics object. I load the tilesheet into a Bitmap, then I make a Bitmap of the appropriate size (depending on how many tiles the user wants to display longways) for the tile selection box and and "copy" tiles from the tilesheet into it (again using a Graphics object), then I Dispose() the tilesheet's Bitmap. I also have a List of Rectangles that denote what tile is where on my Bitmap. The main viewport is drawn using a User Control that is derived from OpenTK's GLControl.*

The map viewport is rendered using the OpenTK GLControl, which is able to run under The Mono Project. M_D_K wanted to use the Tao library, but I found OpenTK was easier to use with C#: the gl functions are in a C# style, whereas the Tao ones were in a C-style that was clunky and ugly and hard to use, in my opinion, when used with C#. If you want something fully developed and you don't mind it being windows-only, you can use XNA at this point, instead. So no: no built-in C# OpenGL. Needs XNA, DirectX, or some sort of OpenGL library (which is what OpenTK is).

I had originally done the same approach that I was doing for the tile controls, however, for large maps, it was too slow to load - 2s loadtime - and too slow to scroll around, as well as too much of a memory hog for any map. It was running at like 600k+ memory for our Big_lvl test map; now it's running at 20k.

*Most capitalized terms in this paragraph are type names that you may consider googling.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: What the heck is C#?! (I want to learn it!)

Post by dandymcgee »

MarauderIIC wrote:
dandymcgee wrote:Okay so I have a basic idea of what C# is. I've been using C++ for a little over a year now, and I'm familiar with the IDE's interface for the most part due to Visual Basic experience (they made me do it!). I have no clue where to start though.
Microsoft Visual Studio -> File -> New Project... -> C# :)
Excellent, now I feel I'm ready to get started on my new operating system! :lol:

I'll take a look at OpenTK. Thanks for all of the advice Mar, I really do appreciate you guys' willingness to respond.
Last edited by dandymcgee on Thu Jun 11, 2009 6:03 pm, edited 1 time in total.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: What the heck is C#?! (I want to learn it!)

Post by MarauderIIC »

dandymcgee wrote:Thanks for all of the advice Mar, I really do appreciate you guys' willingness to respond.
You're welcome.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply