Thread: First Text based game.

  1. #16
    Registered User
    Join Date
    Oct 2012
    Posts
    99
    What does srand do? I get errors from it and can't compile the code.

  2. #17
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    Initialize random number generator

    Did you know::

    You can google nearly any function and you'll get a documentation page as a result. Try googling srand().
    This simple tactic will teach you much about programming.

    Pay attention to the #include at the top of any examples as most new functions come with a new file to #include.
    Last edited by Lesshardtofind; 12-13-2012 at 03:04 AM.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

  3. #18
    Registered User
    Join Date
    Oct 2012
    Posts
    99
    hmmm I'm still getting errors trying to compile this guy's code.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(36): warning #2027: Missing prototype for 'getch'.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(45): warning #2027: Missing prototype for 'sleep'.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(9): warning #2114: Local 'loot' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'retal' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'initiate' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'attack' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(492): warning #2096: Missing return value.

    Building game.exe.

    POLINK: error: Unresolved external symbol '_getch'.

    POLINK: error: Unresolved external symbol '_sleep'.

    POLINK: fatal error: 2 unresolved external(s).

    *** Error code: 1 ***

  4. #19
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by gratiafide View Post
    hmmm I'm still getting errors trying to compile this guy's code.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(36): warning #2027: Missing prototype for 'getch'.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(45): warning #2027: Missing prototype for 'sleep'.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(9): warning #2114: Local 'loot' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'retal' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'initiate' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(8): warning #2114: Local 'attack' is not referenced.

    C:\Program Files (x86)\PellesC\Projects\game\main.c(492): warning #2096: Missing return value.

    Building game.exe.

    POLINK: error: Unresolved external symbol '_getch'.

    POLINK: error: Unresolved external symbol '_sleep'.

    POLINK: fatal error: 2 unresolved external(s).

    *** Error code: 1 ***
    Did you include <conio.h> and use the _getch() in your code? For sleep() use <time.h> and _sleep() (this is a second timer in Pelles C. For the sub second version, you need to go into Project Options and check the "Use Microsoft Extensions", box, and save that. Then include <window.h> and use Sleep() (with the upper case S), and re-build the project.

  5. #20
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    I think that the best way of developing this sort of game is to imagine that you are on a chess board with discrete locations. Put something like a mountain in there and comment on it every now and then - Remember that these story based games need to verbally create everything the user sees and feels.


    The story should be across separate text files - For each location you need a few versions for things like poor luck, good luck, returning, ect...


    Location A1 could be in a text file called A1_0.txt, A1_1.txt, A1_2.txt

    A1_0.txt could have the intro message, a description of the land and/or character
    A1_1.txt could be if the player returned to place A1 and was lucky
    A1_2.txt could be if the player returned to A1 and was unlucky

    The player's location, health, gold and special features picked up can be stored into a struct - There should be an option of saving the game, which would involve writing the contents of this struct to a text file. Each monster needs to have their information saved as well, just in case the player returns to the same location.
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text based game
    By wipeout4wh in forum C Programming
    Replies: 12
    Last Post: 03-26-2009, 04:39 PM
  2. text based game
    By PippinofTook in forum Game Programming
    Replies: 5
    Last Post: 08-24-2005, 06:56 PM
  3. Text-Based Game Help
    By Sentral in forum Game Programming
    Replies: 6
    Last Post: 07-01-2005, 01:08 PM
  4. Text based game..
    By MipZhaP in forum C++ Programming
    Replies: 8
    Last Post: 02-28-2005, 08:35 AM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 06:21 PM