URI:
   DIR Return Create A Forum - Home
       ---------------------------------------------------------
       The New DS computer forum!!
  HTML https://dscomp.createaforum.com
       ---------------------------------------------------------
       *****************************************************
   DIR Return to: C++
       *****************************************************
       #Post#: 538--------------------------------------------------
       Tutorial #9 - Guess My Number. Part #1
       By: Hondaman Date: June 21, 2011, 8:59 am
       ---------------------------------------------------------
       [center]Welcome to Tutorial No.9
       In this tutorial you will learn how to code the 'Guess Number'
       game.
       Part #1[/center]
       [font=trebuchet ms]About the game -[/font]
       The Guess Number game is a simple game between the computer and
       the user... the computer will randomly select a number and the
       user will try and guess the computers number in as few guesses
       as possible. This game is reasonably simple once broken down and
       is a rather fun achievement once complete.
       There are bits you have not learned so far on this tutorial
       series of C++ so I will teach you them using the game as an
       example, The first thing you will learn is two new library's you
       will need to include in the script.
       [code]
       #include <cstdlib>
       #include <ctime>
       [/code]
       [font=trebuchet ms]seeding  -[/font]
       These two library's are what gives us the random number...
       When a number is randomly generated, with the function "rand()"
       numbers that are generated by the computer are pseudorandom,
       basically they are not truly random.
       Basically, the function "rand()" will always generate the same
       chain of numbers continuously... so to avoid this we seed the
       random number generator "srand()" (defined in cstdlib). To get a
       number of any value, the number that is used as the seed must be
       different each time the program is run, so we use "ctime" which
       will allow us to use the time as a seed so that the number used
       is different each time.
       [font=trebuchet ms]Setting up the game -[/font]
       To set up the game simply (for now) add the library's and "using
       namespace std;
       so the script will look like this so far...
       [code]
       #include <iostream>
       #include <cstdlib>
       #include <ctime>
       using namespace std;
       [/code]
       Thats all for now, Remember to check out my next tutorial for
       the next part of the game.
       Thanks for reading this tutorial.
       If there was anything you didn't understand or anything is wrong
       PM me.
       Hondaman.
       [center]<< Previous
  HTML http://www.dscompforums.tk/c/tutorial-8-if-statements-within-if-statements/<br
       />  |   Next >>
  HTML http://[/center]
       *****************************************************