Click to See Complete Forum and Search --> : Need some things to get a game working


wmHardRock
01-24-2001, 10:33 AM
Hi. I'm writing a small and simple game (2 pages worth of pseudo-code). I won't tell what it is just now, but you will probably guess, so anyways, before it gets done, I need some info on how to:

-Choose a random number between two given values (like between 1 and 10)
-Create a temporary file (in the home dir), write things to it (screen output) and delete it after the game is over
-Access a file, and display it on screen

Thanks. Vince

P.S: You guys will have to wait for the english version, because I'm releasing the french one first.

YaRness
01-24-2001, 11:16 AM
what language?

a lot of languages have two functions: one for generating a random seeed number (so that if you run the program twice in a row, the 'random' numbers won't be exactly the same), and one function to actually spit out a random number. i think in C and C-like languages, it's srand() and rand(), but i'd just check whatever docs are handy for the language you are workin in and search for rand or random or whatever.

or search in google, "random number <insert your language here".

oh, and i wouldn't mind seeing the french version just for fun, can see how much of the language i can remember (je n'aime pas parler... umm, in french... i can't remember if it's "en francais" or "la/le francais" or what, but you get the drift http://www.linuxnewbie.org/ubb/biggrin.gif ).

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/

wmHardRock
01-24-2001, 01:17 PM
Oh, sorry. C or C++. Whichever you are most familiar with. If anyone feels like giving Pascal examples, good too :-)

P.S: I intend on giving away not only the code, but also the pseudo-code. Good idea or not?

YaRness
01-24-2001, 01:43 PM
probably don't need to give away pseudo-code if the actual code is properly documented.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/