What does srand do? I get errors from it and can't compile the code.
What does srand do? I get errors from it and can't compile the code.
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.
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.
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