Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Nice and simple C# programs for beginners?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 DoctorChrono   Members   -  Reputation: 114

Like
0Likes
Like

Posted 10 August 2014 - 08:10 PM

I'm reading through a rather extensive C# tutorial online, and I wrote the "Hello World" program, naturally. But they're throwing concepts at me, and I have no place to apply them. What are some simple program ideas to test the concepts I am learning? Or is this even a good idea?



Sponsor:

#2 Washu   Senior Moderators   -  Reputation: 6608

Like
3Likes
Like

Posted 10 August 2014 - 10:35 PM

It is always a good idea to program more. You won't learn unless you continue to challenge yourself.

As for simple programs to write, just pick a problem and aim to solve it. One idea for you: Create a pick a number game, then refactor and refine it unto a choose your own adventure game. Keep going until you've got a whole little SUD written.

You will need things like conditionals, loops, string parsing, and more as you continue to grow what started out as "hello world" into a fully fledged game.

Edited by Washu, 10 August 2014 - 10:36 PM.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#3 Endurion   Crossbones+   -  Reputation: 3963

Like
0Likes
Like

Posted 10 August 2014 - 10:35 PM

If you don't have any other programming experience I'd guess the language's basic constructs will help:

 

Variables. Loops. Calling methods. Calling methods with arguments. Make a simple class and use it. Put class instances in containers and access containers.


Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

#4 Washu   Senior Moderators   -  Reputation: 6608

Like
5Likes
Like

Posted 10 August 2014 - 11:00 PM

To add to my initial post:

Start with your basic hello world application. Then make it a "choose a number" game, where the program has a nice hard coded random number (lets use 42). Then once you've met System.Random, you can make it pick a random a random number every time the program starts. But, still, when you get it wrong the program exits.

 

So the next stage will be to make your pick a number game run until the user picks the correct number. This will involve loops. Once you've got the basic loop in place (this is your game loop), you now want to add some exit conditions, so that a player might quit the game at any time. Other things you will want to do is ask the player if they wish to play again, after successfully picking the right number.

 

Now we've got some basic conditions and loops out of the way, time to go a bit more complex. Write an Arena game. This is a game where the player picks a monster or difficulty and then enters an arena and fights the monster. They use simple commands to do so, in fact, your first time around you'll probably just make it "attack" or "retreat." Defeat is when the player's HP (which you need to track) reaches 0. Winning is when the monster's HP reaches 0.

 

An arena game has a HUGE amount of potential for growth. You can start adding complexity by allowing the players to earn XP every time they win, leveling up, increasing their damage. You can randomize the stats of the monsters (within certain ranges) so that each fight is different. You can start adding abilities and new choices (so its not just "attack" or "retreat"). You can grow this out quite a lot.

 

Once you've gotten this far, you have a basic game running. But you can go farther. So far we're dealing with things you can easily write into source code. Lets add another dimension and start driving it with data. We can start by storing player data in files and monster data in files. Now you can save your progress between games. Then we can refactor the arena game a bit further and now you have multiple rooms you have to traverse, and the rooms link to each other, and the monster can move between rooms. So now your monster needs to think a bit more. It no longer simply advances or attacks. It must now choose if it wants to flee or chase... etc. Now you're starting to get into the basics of a single user dungeon game.


In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
ScapeCode - Blog | SlimDX


#5 DoctorChrono   Members   -  Reputation: 114

Like
1Likes
Like

Posted 11 August 2014 - 09:06 PM

Thank you Washu, that is exactly what I was looking for.



#6 Eck   Crossbones+   -  Reputation: 3811

Like
0Likes
Like

Posted 11 August 2014 - 09:23 PM

Very nice writeup Washu.

 

- Eck






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS