Sign in to follow this  
noobnerd

lines

Recommended Posts

noobnerd    128
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

Share this post


Link to post
Share on other sites
Telastyn    3777
[quote name='noobnerd' timestamp='1352131111' post='4997609']
not how to actually do things with it that anybody would like to use.
[/quote]

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 [url="http://msdn.microsoft.com/en-us/library/system.drawing.aspx"]System.Drawing[/url] 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.

Share this post


Link to post
Share on other sites
Nypyren    12063
1. Make a "Windows Forms Application"
2. In the file "Form1.cs", add the following method:

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

e.Graphics.DrawLine(Pens.Black, 0, 0, 100, 100);
}
[/code]

(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". Edited by Nypyren

Share this post


Link to post
Share on other sites
lride    674
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# Edited by lride

Share this post


Link to post
Share on other sites
noobnerd    128
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.

Share this post


Link to post
Share on other sites
3Ddreamer    3826
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.[img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Clinton

Share this post


Link to post
Share on other sites
Telastyn    3777
[quote name='noobnerd' timestamp='1352149666' post='4997729']
i just think that doing programs that you are interseted in is a good way to learn the language
[/quote]

And[b] I think [/b]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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this