Jump to content

  • Log In with Google      Sign In   
  • Create Account

Brian Sandberg

Member Since 10 Oct 2003
Offline Last Active Yesterday, 02:55 PM

Posts I've Made

In Topic: The Point and Click Jam...

30 September 2014 - 11:06 AM

It sounds like good fun!


I do wish there'd been some set of graphics elements we could all use as a starting point, so us programmers could concentrate on code and story.

In Topic: To Day I had to Resort To a FileBack Up

25 September 2014 - 07:33 AM

One more reason to buy server class drives.


No.  One more reason to use 3 or more drives in a raid, as well as keeping your work files in version control on a remote machine.


Every single-point-of-failure will eventually bite you in the ass.

In Topic: What can be scripted and what should not in a server?

18 September 2014 - 11:05 AM

Ask yourself what flexibility you get from keeping that logic as scripts, and if you actually need that.  You could just as well keep the same logic as plugins, swapping out dll's instead of text files.

In Topic: C++ to Java/C#

10 September 2014 - 10:59 AM

Like they say, the main difference between C++ and C#/Java is that the STL is tiny, and the .NET and Java class libraries are huge.  With your C++ experience, you should be able to learn the various language features of Java or C# (which is a fair bit more advanced), or indeed any language, in a few days,  Learning the frameworks, or even getting a coarse mental map of them, is a different matter.  For example, the standard .NET framework is 300+ namespaces, 10.000+ classes with a total of 100.000+ members (each with 1-10 overloads).


Obviously no one memorizes a million function signatures, that would be meaningless, but anyone who calls themselves "well versed" should be roughly familiar with the majority of namespaces, and perhaps 1000 of the most used classes - and intimately familiar with a few hundred of the core classes.  


Each platform will have a number of little design patterns and ways of doing things that you'll only become aware of (and make second nature) over time and by reading/writing a lot of code.  Until then, you'll be writing the equivalent of a bastardized version of "C with classes" in any language :)   The first thing that springs to mind about C# is proper use of events and callbacks and lambda expressions and asynchronous code (and they added some juicy stuff with C#5 that your book won't cover), and things like LINQ (not necessarily the language feature, but the extensions in the System.Linq namespace) and Rx (the System.Reactive namespace) for dealing with push/pull datastreams, and perhaps how reflection plays a central role in many parts of the framework.  Dependency Injection and Inversion of Control is another pattern that's very common in the managed world, but (afaik?) not really used in C++.


Each platform will also have an ecosystem of tools, with the Java ecosystem being a nightmarish jungle because, like Glass_Knife writes, you have countless competing application servers and build systems and whatnot.


So to round it off, when you've read a couple of books on either platform, you'll still be an experienced programmer, but a novice in that particular platform.  Kind of like how someone who'd read a "Beginning Game Development WIth OpenGL" would be a novice game/graphics programmer, no matter what other experience they had.  And that's fine.

In Topic: Stuck in C#......

15 August 2014 - 11:43 AM

When the user enters something, you get a piece of text back.  What you need to do is to find out if they actually wrote a number, and then determine what number that is, so you can use it to retrieve an element from your list of pokemons. Luckily, the built-in number types have methods for parsing text.  To convert text to an integer, you might use Convert.ToInt32() or Int32.Parse() or Int32.TryParse().


You also want to do some sort of error handling; if the user didn't enter a number, or they wrote a larger number than you have pokemons, then you should ask them again until they enter something valid.


Here's a simple loop to do that.

Pokemon SelectedPokemon = null;
do {
	Console.WriteLine("Please choose your Pokemon: (1,2,3)");
	Console.WriteLine("1. Blastoise, 2. Blazekin, 3. Meganium");
	string myChoice = Console.ReadLine();

	if (myChoice == "1")
		message = "Blastoise, a water Pokemon, with lots of health. Good Choice!";
	else if (myChoice == "2")
		message = "Blazekin, a fire Pokemon, with lots of Power. Let's do this!";
		message = "Meganium, a plant Pokemon, with lots of health. Best of luck!";


	int SelectedPokemonNo = 0;
	if( !Int32.TryParse( myChoice, out SelectedPokemonNo ) )
		// uh oh, myChoice wasnt a number
		Console.WriteLine( "That's not a pokemon! Try again" );
	SelectedPokemonNo--; // make it a 0-based index
	if( SelectedPokemonNo < 0 || SelectedPokemonNo >= myPokemon.Count )
		// uh oh, myChoice out of range
		Console.WriteLine( "That's not a pokemon! Try again" );

	SelectedPokemon = myPokemon[SelectedPokemonNo];
	Console.WriteLine( "You selected {0} with {1} health.", SelectedPokemon.Name, SelectedPokemon.Health );

while( null == SelectedPokemon );

Something else you might think about is how you have built the pokemon names and descriptions directly into the code that asks to choose between them.  A better design would be to put the descriptions ("a water Pokemon, with lots of health") into another field in the Pokemon class, and have the menu retrieve it from there.


I think it would be good for you to read some tutorials on C#; they would have taught you about converting texts to numbers, and using lists, and countless more details.  I just googled up this one; there are 23 pages and it looks decent - if you go through all those those, you'll be much better prepared.  Enjoy smile.png  http://www.csharp-station.com/Tutorial/CSharp/Lesson01