Page 1 of 1

Questions about C# that I have

Posted: Mon Jan 16, 2012 11:34 pm
by mattykins
This is more of a list of problems I am running into with C#
I would greatly appreciate some help on any one of these issues.

1.How would one go about getting graphics and animations in C#
For example lets say I want my game to have a title screen with an animated background, and buttons that light up when you highlight them. I'm stuck coding text-based and conosle games/applications because I can't figure out how to get graphics and animations into my program.

2. Could someone please explain to me the random number function that is gone over in Hall's tutorials?
I just don't really understand what is going on in the part where he explains randoms etc.

3.How would you save and load progress in C#
I was thinking maybe that the program would write a .txt file that would contain certain parameters.
Lets say you have a farm game and in the .txt file it would show what crops were planted where, etc.
How would you go about doing that?
If there is a more efficient and better way of doing that, i would love to know as well :)

Those are the main things that I am struggling with right now, They are all extremely noob questions but then again, I am an extreme noob :)

Re: Questions about C# that I have

Posted: Tue Jan 17, 2012 12:23 am
by Jackolantern
1. Take your pick! Graphics is one place where .NET absolutely shines. For games, do a search for XNA. For Windows applications, you can go old school and use Windows Forms, which is more the pick-up-and-go GUI builder. WPF is the more heavy-weight, do-anything-at-all-although-the-learning-curve-is-huge GUI builder. For the web, look ASP.NET or ASP.NET MVC (although MVC is more complex) for webpages, or Silverlight for Flash-like apps.

2. I have not watched Halls' tutorial, so I can't comment on how it is done there. But here is a really brief tutorial that shows you how to generate random numbers. If this doesn't clear it up, post your code and I will explain it!

3. Take your pick! You can store it in text files (not optimal if you are storing many rows of data, since it all must be parsed, making nasty code), XML files, YAML (I can't suggest using that), SQLite (more complex since it must be on the client-side, but very nice when you have a ton of related data), or really anything else you want to use. If it is important data you don't want people to tamper with, I would suggest using a two-way encryption algorithm and storing it in a .data file. You can google any of these methods here, and if you have any questions, let me know!

C# and .NET, like Java, C++ and others, is a wide-open, general-purpose language. You can really do almost anything you want to do, provided you can find an API to do it (and C# has APIs to do almost anything you could want, from interpreting Kinect video signals to writing to Oracle Databases to controlling robots!).

Re: Questions about C# that I have

Posted: Tue Jan 17, 2012 12:31 am
by Xaleph
Yarr, i second that. Do look in to XNA, it`s very easy to get a game up and running in there and download the demo`s and tutorials to help you get started. I too didn`t watch the tutorials Halls created, but do a quick google search for Random in C# and you should find anything you want.

On the last part, I however, do recommend using .txt files, or rather hex files, which can be stored in .txt files. it`s the flattest filesystem there is and if you have the good offset, seektimes are very, very, very fast. Nothing to beat those times, in fact, seek times are based on the speed of your platter. Whatever you do next is up to you, store as .dat files or whatever.

And yes, C# can be used for pretty much anything. Except that it only runs on Windows, well mostly. Then again, so are most games :)

Re: Questions about C# that I have

Posted: Tue Jan 17, 2012 12:35 am
by mattykins
Thanks, so much guys! I will definantly do a search for XNA. And I like the different types of save/loading methods you guys mentioned.