RCRPG/C++98: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
(5 intermediate revisions by 3 users not shown)
Line 1:
Yet another C++ RCRPG, this one has some tweaks thouthough:
* You can lose: If you try to break one of the cave's boundary walls, your sledge will break. If that happens in a room that has no exits (first room), you are trapped and dies!
* If you enter a room that you visited, at least 3 minutes ago, there is a 40% chance that the loot will re-spawn.
* The Treasure Room is placed at random in the cave.
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[C++]]</span><hr>
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">
#include <stdio.h>
#include <time.h>
Line 25:
{
public:
position() : x(0), y(0), z(0) { }
position( int a, int xb, =int yc =) z: =x(a), y(b), z(c) 0;{ }
void set( int a, int b, int c ) {
}
position( int a, int b, intx c= )a; {y = b; z = c;
x = a; y = b; z = c;
}
void set( int a, int b, int c ) {
x = a; y = b; z = c;
}
bool operator ==( const position o ) {
Line 137 ⟶ 133:
unsigned hashStr( std::string s ) {
unsigned wrd = 0x4e67c6a7, p = 0;
while( s[p] !=< 0s.length() )
wrd ^= ( ( wrd << 5 ) + s[p++] + ( wrd >> 2 ) );
return wrd;
Line 148 ⟶ 144:
{
public:
treasure( keyWord k, uint c ) : key(k), cnt(c) { }
key = k; cnt = c;
}
keyWord key;
uint cnt;
Line 216 ⟶ 210:
{
public:
room( std::string n ) : name(n), visited(false) {
memset( bRooms, 0, sizeof( bRooms ) );
memset( ladderZ, 0, sizeof( ladderZ ) );
name = n;
visited = false;
}
void describe() {
Line 297 ⟶ 289:
{
public:
player() : curRoom(0) { }
curRoom = 0;
}
~player() {
deleteRooms();
Line 546 ⟶ 536:
return 0;
}
</syntaxhighlight>
</lang>
9,476

edits