Jump to content

Search the Community

Showing results for tags 'guessing'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • RuneLocus
    • News & Announcements
    • Information Booth
    • Website Support
    • Introductions
    • Chat
    • Forum Games
  • RuneScape Development
    • RSPS General
    • RuneScape Private Server (RS2)
    • RuneScape Private Server (503+)
    • RuneScape Private Server (EoC 742+)
  • Other
    • Digital Art
    • Gaming
    • Webdevelopment
    • Computers
  • Marketplace
    • RuneScape Market
    • RSPS Market
    • Others Market
    • Freelance Middleman Services
  • Super Secret Club's Topics

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hey guys, didn't really know I was going to make a guessing game until I was done with the funky ass 2d array but anyways here is your basic, "Guess a number; too high or too low, until you guess right" game using a 2d array of 50 numbers. Then made it look a little nicer, and added the two error handlers. unfortunately I couldn't get row 0 and 1 to line up properly in console since I used a for loop to make the game board. Well here it is... [code]#include <iostream>#include <stdlib.h> #include <time.h> #include <Windows.h> using namespace std; int computerRow, computerCol, userRow, userCol, computerGridNumber, userGridNumber, randomNumber; int board[10][5] = { { 0, 1, 2, 3, 4 }, { 5, 6, 7, 8, 9 }, { 10, 11, 12, 13, 14 }, { 15, 16, 17, 18, 19 }, { 20, 21, 22, 23, 24 }, { 25, 26, 27, 28, 29 }, { 30, 31, 32, 33, 34 }, { 35, 36, 37, 38, 39 }, { 40, 41, 42, 43, 44 }, { 45, 46, 47, 48, 49 } }; void drawGameBoard(); void getComputerNumber(); void getUserNumber(); void SetColor(int value){ SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), value); } //12 is red //3 is dark teal //11 is bright teal //14 is bright yellow int main() { drawGameBoard(); SetColor(10); cout << "|------------------------------|\n"; cout << "| HELLO! PLEASE ENTER A NUMBER |\n"; cout << "| YOU SEE ON THE GRID. THE GAME|\n"; cout << "| WILL LET YOU KNOW WETHER YOU |\n"; cout << "| ARE CLOSER OR FURTHER AWAY, |\n"; cout << "| -----------------------------|\n"; cout << "| GUESS THE RIGHT NUMBER TO WIN|\n"; cout << "|------------------------------|\n"; getComputerNumber(); do{ getUserNumber(); if (userGridNumber < randomNumber) { SetColor(11); drawGameBoard(); cout << "Too low!" << endl; cout << "You selected " << userGridNumber << endl; } else if (userGridNumber > randomNumber) { drawGameBoard(); SetColor(11); cout << "Too high!" << endl; cout << "You selected " << userGridNumber << endl; } else if (userGridNumber == randomNumber) { drawGameBoard(); SetColor(11); cout << "You win!" << endl; cout << "You selected " << userGridNumber << endl; cout << "Computer chose: " << randomNumber << endl; } } while (userGridNumber != randomNumber); cin.get(); return 0; } void drawGameBoard() { SetColor(15); cout << " ||ROWS||\n"; SetColor(3); for (int row = 0; row < 10; row++) { for (int col = 0; col < 5; col++) { cout << "|" << board[row][col]; } SetColor(15); cout << " " << "|" << " ||" << row << "||"; SetColor(3); cout << "\n-------------------------|"; cout << endl; } SetColor(15); cout << "||0||1||2||3||4| |COLUMNS|" << endl; } void getUserNumber() { SetColor(13); cout << "|------------------------------|\n"; cout << "| PLEASE ENTER THE ROW |\n"; cout << "| NUMBER YOU WISH TO USE (UP & |\n"; cout << "| DOWN) USING 0 - 9 |\n"; cout << "|------------------------------|\n"; cin >> userRow; while (userRow < 0 || userRow > 9) { SetColor(12); cout << "|------------------------------|\n"; cout << "| ||ERROR|| |\n"; cout << "| ---------------------------- |\n"; cout << "| PLEASE USE NUMBERS |\n"; cout << "| 0 - 9 |\n"; cout << "| -----------------------------|\n"; cout << "| LEFT TO RIGHT ROW |\n"; cout << "|------------------------------|\n"; cin >> userRow; } SetColor(11); cout << "|------------------------------|\n"; cout << "| PLEASE ENTER THE COLUMN |\n"; cout << "| NUMBER YOU WISH TO USE (LEFT |\n"; cout << "| TO RIGHT) USING 0 - 4 |\n"; cout << "|------------------------------|\n"; cin >> userCol; while (userCol < 0 || userCol > 4) { SetColor(12); cout << "|------------------------------|\n"; cout << "| ||ERROR|| |\n"; cout << "| ---------------------------- |\n"; cout << "| PLEASE USE NUMBERS |\n"; cout << "| 0 - 4 |\n"; cout << "| -----------------------------|\n"; cout << "| UP AND DOWN COLUMNS |\n"; cout << "|------------------------------|\n"; cin >> userCol; } userGridNumber = board[userRow][userCol]; cin.get(); } void getComputerNumber() { srand(time(NULL)); //Gets the computers row number computerRow = rand() % 9 + 0; //Gets the computers col number computerCol = rand() % 4 + 0; //Gets the actual grid number to base our guessing off of computerGridNumber = board[computerRow][computerCol]; randomNumber = computerGridNumber; }[/code]
×