lines

Started by
6 comments, last by Telastyn 11 years, 5 months ago
Hi there

I have been reading a book on C# for a while now and i think im beginning to have a somewhat rudimentary understanding of how it works, but so far the only things i have learned are console applications and different ways of making fancy methods and stuff. Before C# i learned Dark Basic mainly by trial and error by doing small graphics programs that looked cool.
So to the point. How do i do small graphics programs in C#? In Basic there are commands like line(x1,y1,x2,y2,color) and i assume that such stuff doesnt exist in C# so how do i do this? I checked the book and it only tells me how to use C#, not how to actually do things with it that anybody would like to use.

Thank you
Advertisement

not how to actually do things with it that anybody would like to use.


Even in games, graphical output is a very small percentage of the entire program. Knowing how to solve problems and make the code do what you want is what people want to use.

That said, the System.Drawing namespace has some things to do that. Not great things, and not things that can be used too much for games; but enough to get your feet wet. After that, you'll need to pick and use some API dedicated to graphical rendering. But learn the language first. It'll give you a good foundation once you start trying to use the APIs.
1. Make a "Windows Forms Application"
2. In the file "Form1.cs", add the following method:


protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);

e.Graphics.DrawLine(Pens.Black, 0, 0, 100, 100);
}


(This assumes you're using some version of Visual Studio)

If you've never written a WinForms app in Visual Studio before, you will have to right click on the Form1.cs item in the solution explorer and select "View Code" in order to view the C# (by default it will display the visual form designer).

ProTip: You can use the code viewer by default by right clicking Form1.cs, clicking "open with...", selecting "CSharp Editor", and clicking "Set as Default".
Dark basic is a language dedicated to game programming, so it has some graphics command built in.
But c# is more like a general purpose language so it doesn't have a nice graphics tool designed for game.

You should start looking at XNA after getting comfortable with C#
An invisible text.
Thanks for the quick replies.

@ Telastyn : I know, but i just think that doing programs that you are interseted in is a good way to learn the language, instead of just doing endless examples of different method attributes etc. that just show you what it does. Of course this would only help me get comfy with C# basics as it is not like i would ever come up with something like abstracts or such except by reading it in the book. System.Drawing, okay thanks, but how do i use them, i cant just draw a line in the console. Are they used on windows forms?

@Nypyren : Thanks! will try it out

@Iride : Yeah, thats why i moved to C# from Basic.
you should search gdi and gdi+ for windows form applications .
my map aplications http://haritaaraci.com
Hi,

It sounds as though you are a few months from getting good simple results from the graphics engine of your choice, probably by an existing game development system like XNA.

After you are good at basic programs, worked with XNA for a while, then look at SharpDX or MonoDevelop/Mono. Knowing that the communities which support these development environments have the knowledge and experience is your key, so once you get there put the key in the proverbial hole and open it.smile.png

Clinton

Personal life and your private thoughts always effect your career. Research is the intellectual backbone of game development and the first order. Version Control is crucial for full management of applications and software. The better the workflow pipeline, then the greater the potential output for a quality game. Completing projects is the last but finest order.

by Clinton, 3Ddreamer


i just think that doing programs that you are interseted in is a good way to learn the language


And I think that having seen beginners bite off more than they can chew for more than a decade now, you should err towards getting a good foundation.

This topic is closed to new replies.

Advertisement