Results 1 to 2 of 2
  1. #1
    samlarenskoog's Avatar
    Join Date
    Apr 2016
    Gender
    male
    Posts
    104
    Reputation
    25
    Thanks
    57
    My Mood
    Cheerful

    Horse Betting Game

    Hello guys i am back again. This time I am in need of some help with this game I am creating using functions again.
    #include <iostream>
    #include <Windows.h>
    #include <ctime>
    #include <cstdlib>
    #include <stdio.h>
    #include <time.h>



    using namespace std;

    int menu(void);
    int rand(int x);


    int horse;
    int randHorse;


    int main()
    {
    int z;
    cout << "Welcome, bet on your horse";
    int menu(void);
    int rand(int z);

    if (horse == z)
    {
    cout << "You win\n";
    }
    else
    {
    cout << "You lost\n";
    }
    system("PAUSE");
    }

    int menu(void)
    {
    switch (horse) {
    case 1:
    cout << "You chose horse 1\n";
    int horse = 1;
    break;
    case 2:
    cout << "You chose horse 2\n";
    int horse = 2;
    break;
    case 3:
    cout << "You chose horse 3\n";
    int horse = 3;
    break;
    }
    }

    int rand(int x)
    {
    srand(time(NULL));
    return x = rand() % 3 + 1;
    }

  2. #2
    Sammy's Avatar
    Join Date
    Mar 2016
    Gender
    male
    Location
    Vaero
    Posts
    1,102
    Reputation
    224
    Thanks
    228
    Quote Originally Posted by samlarenskoog View Post
    Hello guys i am back again. This time I am in need of some help with this game I am creating using functions again.
    Your int horse is uninitialized. In fact nowhere does it give any input on what horse you are going to bet.

    change this part:
    Code:
    int main()
    {
    int z;
    cout << "Welcome, bet on your horse";
    int menu(void);
    int rand(int z);
    to this:
    Code:
    int main()
    {
    int z;
    cout << "Welcome, bet on your horse: ";
    cin >> horse;
    cout << "You chose horse " << horse << endl;
    int rand(int z);
    and remove this:
    Code:
    int menu(void)
    {
    switch (horse) {
    case 1:
    cout << "You chose horse 1\n";
    int horse = 1;
    break;
    case 2:
    cout << "You chose horse 2\n";
    int horse = 2;
    break;
    case 3:
    cout << "You chose horse 3\n";
    int horse = 3;
    break;
    }
    }
    I think you'll be on the right track then.

    - - - Updated - - -

    Now obviously you'll still need to add some securities like that you can only choose number 1 to 3 for example.
    Last edited by Sammy; 06-08-2016 at 12:13 AM.

  3. The Following User Says Thank You to Sammy For This Useful Post:

    samlarenskoog (06-13-2016)

Similar Threads

  1. Replies: 28
    Last Post: 04-01-2011, 02:13 PM
  2. games that suck
    By gothgod in forum General Game Hacking
    Replies: 50
    Last Post: 07-09-2006, 06:41 PM
  3. frag/game music video's
    By kyo in forum General
    Replies: 12
    Last Post: 06-20-2006, 08:55 AM
  4. Connection About for Annomalation in Game
    By asdasd in forum WarRock - International Hacks
    Replies: 7
    Last Post: 12-30-2005, 08:17 PM
  5. What type of games
    By djraziel127 in forum General Game Hacking
    Replies: 11
    Last Post: 12-30-2005, 03:22 PM