RCRPG/C++98: Difference between revisions

m
Fixed syntax highlighting.
(Created page with "Yet another C++ RCRPG, this one has some tweaks thou: * 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 t...")
 
m (Fixed syntax highlighting.)
 
(6 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 78 ⟶ 74:
}
actions.insert( std::make_pair( hashStr( nw ), it->second ) );
std::cout << "Done\n";
}
bool parse( std::string a, command& cmd ) {
Line 136 ⟶ 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 147 ⟶ 144:
{
public:
treasure( keyWord k, uint c ) : key(k), cnt(c) { }
key = k; cnt = c;
}
keyWord key;
uint cnt;
Line 215 ⟶ 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 260 ⟶ 253:
void setName( std::string n ) {
name = n;
namestd::cout =<< "OK\n";
}
std::vector<treasure> tak( keyWord k ) {
Line 295 ⟶ 289:
{
public:
player() : curRoom(0) { }
curRoom = 0;
}
~player() {
deleteRooms();
Line 544 ⟶ 536:
return 0;
}
</syntaxhighlight>
</lang>
9,485

edits