Text based game challenge

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

87 Replies - 42223 Views - Last Post: 24 October 2011 - 06:43 AM

#1 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Text based game challenge

Post icon  Posted 10 September 2011 - 01:28 PM

*
POPULAR

Text based game challenge:

The idea is fairly simple; you make a game which has a text based interface. People often use “the guessing game” as an example of a basic game. Given that the interface is text (as it often is), even something as simple as that is a text based game. I would hope you would make something a bit more complex than that however ;)

The games will be scored on scales of 1-10 based on the following criteria:
  • Creativity – The uniqueness of the game. What amount/quality of thought went into the game?.
  • Game Play – How fun is it to play? How smooth is the interface? Isn’t that what games are about anyways?
  • Quality of code – How well structured the code is. How easy is it to maintain and add on to. How well "good" practice was followed.


Game play and Quality of code will each be worth 40% of your score while Creativity will be 20%. I am allowing a few Third party libraries (listed below) to be used and you can ask me if you would like to use something else. Full source code is required and should be in C or C++(along with any necessary files);There is not a current due date set but I’m guessing around a month (4 weeks) from now as a general due date. The projects will be due October 15th by 12:00 midnight US central time.

The following libraries are allowed:
  • Boost 1.47.0 – all of it, anything in it is fair game
  • Ncurses 4.0 and PDcurses 3.4 – I’m allowing both so that almost all platforms can have a curses library
  • Lua 5.1.4 or Lua 5.2(beta) – You can use either but it has to be embedded, this is a C/C++ programming challenge so you can’t just use pure Lua; it should be used as an extension.


A runner up will be declared along with the Winner; they will each get an award in DIC’s new award system. An honorable mention will also go to the most creative submission as well; this user will also get an award. If enough people get involved then I can talk to Skyhawk about getting an actual prize for the winner! Most importantly, have fun!!

This post has been edited by ishkabible: 17 September 2011 - 11:10 AM


Is This A Good Question/Topic? 9
  • +

Replies To: Text based game challenge

#2 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: Text based game challenge

Posted 10 September 2011 - 02:15 PM

When does the challenge end? or start :o
Was This Post Helpful? 0
  • +
  • -

#3 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Text based game challenge

Posted 10 September 2011 - 03:53 PM

it starts now; the end is not yet set. it will be about 4 weeks from now but i don't have an exact date just yet.
Was This Post Helpful? 0
  • +
  • -

#4 .Aaron  Icon User is online

  • Rock, paper, scissors, lizard, Spock
  • member icon

Reputation: 61
  • View blog
  • Posts: 2,875
  • Joined: 04-August 09

Re: Text based game challenge

Posted 10 September 2011 - 09:01 PM

Hmm.. may try and do this on the side. Depends how much time I have and how my XNA challenge project goes.
Was This Post Helpful? 0
  • +
  • -

#5 hulla  Icon User is offline

  • Writing Lines


Reputation: 49
  • View blog
  • Posts: 732
  • Joined: 05-March 11

Re: Text based game challenge

Posted 10 September 2011 - 11:12 PM

Here is my text-based RPG game. I wrote it in two header files and one .cpp file.


Here is main.cpp . . .
#include "Libraries.h"

int gameOver()
{
    cout << "You were killed!"    << endl << endl;
    cout << "GAME OVER"           << endl << endl;
    cout << "Press enter to exit . . ." << endl;
    ofstream outFile;
    outFile.open("C:\\Documents and Settings\\myUserHere\\My Documents\\TG Save Loc.txt");
    outFile << "10" << endl << "-1" << endl;
    outFile.close();
    cin.sync();
    cin.get();
    exit(0); // No major memory losses will be occurred with this exit()
}

int flee()
{
    cout << endl << "Fleeing . . ." << endl << endl;
    Sleep((((time(0)%2)+1)*1000-400));
    int iEscapeChance = time(0)%3;
    if(iEscapeChance == 0)
    {
        cout << "You successfully escape!" << endl << endl;
        system("PAUSE");
        system("CLS");
        cout << "You continue roaming the forest . . ." << endl;
        return 0;
    }
    else
    {
        cout << endl << endl << "The creature catches you from behind while you are fleeing . . ." << endl;
        gameOver();
        exit(0);
    }
}

int attack(int *iHealth)
{
    system("CLS");
    int iHitDamage = time(0)%11;
    *iHealth -= iHitDamage;
    if(*iHealth <= 0)gameOver();
    return 0;
}

void save(int health, int survivals)
{
    ofstream outFile;
    outFile.open("C:\\Documents and Settings\\myUserHere\My Documents\\TG Save Loc.txt");
    outFile << health << endl << survivals << endl;
    outFile.close();
}

void incorrectPass()
{
    cout << "Your entry is invalid." << endl;
    cout << "Press enter to exit."   << endl;
    cin.sync();
    cin.get();
}

int main()
{
    bool saveAlert = false;
    bool correctPass = auth("myPassHere");
    if(!correctPass)
    {
        incorrectPass();
        return 0;
    }
    int iHealth = 583558; // iFish = 3;
    static int iCreaturesSurvived = -3;
    ifstream inFile;
    inFile.open("C:\\Documents and Settings\\myUserHere\\My Documents\\TG Save Loc.txt");
    if(inFile.fail()) cout << "There was an error in accessing data from the save file . . ." << endl;
    inFile >> iHealth >> iCreaturesSurvived;
    if(iHealth == 583558) cout << "There was an error in retrieving the player-health from the save file . . ." << endl;
    if(iCreaturesSurvived == -3) cout << "There was an error in retrieving the player-survivals from the save file . . ." << endl;
    inFile.close();
    short int iChoice = +3;
    system("CLS");
    cout << "Press enter to start your adventure . . ." << endl;
    cin.sync();
    cin.get();
    system("CLS");
    cout << "You roam some random forest, seeking riches and jewels . . ." << endl;
    do
    {
        iCreaturesSurvived++;
        if(!saveAlert)
        {
            int iTime = time(0)%10;
            {//Operations being done on iTime . . .
                if(iTime == 1)      iTime = 5;
                else if(iTime == 2) iTime = 5;
                else if(iTime == 3) iTime = 4;
                else if(iTime == 4) iTime = 3;
                else if(iTime == 5) iTime = 2;
                else if(iTime == 6) iTime = 2;
                else if(iTime == 7) iTime = 3;
                else if(iTime == 8) iTime = 2;
                else if(iTime == 9) iTime = 4;
                else                iTime = 2;
            }
            iTime = iTime%10+1;
            iTime = iTime*1000-1000;
            Sleep(iTime);
        }
        cin.clear();
        cin.sync();
        system("CLS");
        static int iAnotherCreature = 0; // This variable checks if you have encountered your first creature or not
        if(iAnotherCreature == 0 && iCreaturesSurvived == 0)
        {
            cout << "You encounter a strange creature!";
            iAnotherCreature++;
        }
        else cout << "You encounter another one of those strange creatures!";
        if(iCreaturesSurvived != 0) cout << endl << "You have encountered and survived " << iCreaturesSurvived << " creatures so far.";
        if(iHealth != 1) cout << endl << "You're health: " << iHealth << " points." << endl;
        else cout << endl << "You're health: 1 point." << endl;
        cout << endl << "Enter the number for the action you would like to perform." << endl << endl << "1 - Attack it" << endl << "2 - Flee" << endl << "3 - Save game" << endl << "4 - Exit game" << endl << endl << "> ";
        string sSafetyNetConversion;
    invalidChoice:
        cin.sync();
        getline(cin, sSafetyNetConversion);
        if     (sSafetyNetConversion == "1") iChoice = 1;
        else if(sSafetyNetConversion == "2") iChoice = 2;
        else if(sSafetyNetConversion == "3") iChoice = 3;
        else if(sSafetyNetConversion == "4") iChoice = 4;
        else /* If the entry is unknown */   iChoice = 5;
        switch(iChoice)
        {
            case 1:
            {
                int iCopyOfHealth = iHealth;
                attack(&iHealth);
                if(iCopyOfHealth != iHealth && iHealth != 1) cout << "You kill the creature with " << iHealth << " health points remaining." << endl << endl;
                else if(iHealth == 1) cout << "You kill the creature with 1 health point remaining." << endl << endl;
                else cout << "You kill the creature, unscathed." << endl << endl;
                system("PAUSE");
                system("CLS");
                cout << "You continue roaming the forest . . ." << endl;
                break;
            }
            case 2:
            {
                flee();
                break;
            }
            case 3:
            {
                system("CLS");
                save(iHealth, iCreaturesSurvived);
                iCreaturesSurvived--;
                iAnotherCreature--;
                saveAlert = true;
                cout << "The game has been saved." << endl;
                cout << "Press enter to continue." << endl;
                cin.sync();
                cin.get();
                break;
            }
            case 4:
            {
                system("CLS");
                save(iHealth, iCreaturesSurvived-1);
                cout << "The game has been saved." << endl;
                cout << "Press enter to exit."     << endl;
                cin.sync();
                cin.get();
                return 0;
            }
            default:
            {
                system("CLS");
                cout << "Unrecognzed command." << endl;
                goto invalidChoice;
            }
        }
    }
    while(true);
}




Here is Libraries.h . . .
#ifdef __STRICT_ANSI__
#undef __STRICT_ANSI__ // I don't want strict ANSI now . . .
#endif
#ifndef LIBRARIES_H_INCLUDED
#define LIBRARIES_H_INCLUDED
#include <iostream>
#include <fstream>
#include <limits>
#include <string>
#include <cstdlib>
#include <windows.h>
#include "authentication.h"
#include <time.h>
#include <conio.h>
using namespace std;
#endif // LIBRARIES_H_INCLUDED




Here is authentication.h . . .
#ifndef AUTHENTICATION_H_INCLUDED
#define AUTHENTICATION_H_INCLUDED
#include <iostream>
#include <string>
bool auth(std::string desiredPass)
{
    std::string password;
    std::cout << "Enter the password." << std::endl;
    std::cin >> password;
    std::cin.sync();

    if(password == desiredPass)
        return true;

    else return false;
}
#endif // AUTHENTICATION_H_INCLUDED





Thanks for the challenge ishkabible. It was fun. :)

It has a save option as well where it writes to a .txt file and reads from it to get the current game data.

This post has been edited by hulla: 10 September 2011 - 11:13 PM

Was This Post Helpful? 0
  • +
  • -

#6 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Text based game challenge

Posted 11 September 2011 - 10:26 AM

you still have a month to work on it :P
Was This Post Helpful? 0
  • +
  • -

#7 saimanoj  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 14
  • Joined: 19-August 10

Re: Text based game challenge

Posted 11 September 2011 - 10:29 AM

is the usage of conio.h allowed, ishkabible?
Was This Post Helpful? 0
  • +
  • -

#8 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Text based game challenge

Posted 11 September 2011 - 11:20 AM

defiantly not, it's non-standard. im not even sure where i would find it.

edit:
hulla: conio.h? goto? function definition in header? #undef __STRICT_ANSI__? system calls? you can do better than that!

This post has been edited by ishkabible: 11 September 2011 - 11:23 AM

Was This Post Helpful? 2
  • +
  • -

#9 alias120  Icon User is offline

  • The Sum over All Paths
  • member icon

Reputation: 122
  • View blog
  • Posts: 700
  • Joined: 02-March 09

Re: Text based game challenge

Posted 11 September 2011 - 01:29 PM

Sounds fun, I will more than likely have a submission.
Was This Post Helpful? 0
  • +
  • -

#10 Zerro  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 17
  • Joined: 16-November 07

Re: Text based game challenge

Posted 11 September 2011 - 03:36 PM

I will work on a submission, this seems quite fun!
Was This Post Helpful? 0
  • +
  • -

#11 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Text based game challenge

Posted 11 September 2011 - 06:08 PM

glad to have you!! i look forward to your games :)
Was This Post Helpful? 0
  • +
  • -

#12 common_man  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 06-August 11

Re: Text based game challenge

Posted 11 September 2011 - 10:16 PM

Is there any restriction on the programming language used for the game?
Was This Post Helpful? 0
  • +
  • -

#13 .Aaron  Icon User is online

  • Rock, paper, scissors, lizard, Spock
  • member icon

Reputation: 61
  • View blog
  • Posts: 2,875
  • Joined: 04-August 09

Re: Text based game challenge

Posted 11 September 2011 - 10:26 PM

View Postcommon_man, on 12 September 2011 - 01:16 AM, said:

Is there any restriction on the programming language used for the game?


Along with this being in the C/C++ forum, he also stated it here:

Quote

The following libraries are allowed:
Boost 1.47.0 all of it, anything in it is fair game
Ncurses 4.0 and PDcurses 3.4 Im allowing both so that almost all platforms can have a curses library
Lua 5.1.4 or Lua 5.2(beta) You can use either but it has to be embedded, this is a C/C++ programming challenge so you cant just use pure Lua; it should be used as an extension.

Was This Post Helpful? 0
  • +
  • -

#14 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Text based game challenge

Posted 12 September 2011 - 08:27 AM

i also even more explicitly stated that the source code should be submitted in C/C++.

Quote

Full source code is required and should be in C or C++(along with any necessary files)

Was This Post Helpful? 0
  • +
  • -

#15 lionaneesh  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 01-April 10

Re: Text based game challenge

Posted 12 September 2011 - 08:46 AM

Nice Challenge! Will surely give it a try if time suggests! :)
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »