I am giving the following code for free and you may use it wherever but I do ask you give credit where credit is due.
#include <iostream>
using namespace std;
#include <ctime> // For time()
#include <cstdlib> // For srand() and rand()
int random (int Range)
{
int num;
num = rand() % (Range + 1);
return num;
}
int main ()
{
srand(time(0)); // Initialize random number generator.
cout << "Welcome to treasure Hunt! A game by Alfie275!\n You have to guess the position of the treasure on the following grid:\n0 1 2 3 4 5 6 7 8 9\n1\n2\n3\n4\n5\n6\n7\n8\n9";
bool Guessed = false;
int Guesses = 0;
int pX;
int pY;
int X = random(9);
int Y = random(9);
while (!Guessed){
cout << "\n\n Enter your guess:\nX:";
cin >> pX;
cout <<"\nY:";
cin >> pY;
Guesses ++;
if (pX != X pY != Y){
cout << "\n Incorrect! The treasure was to the ";
if (pY < Y){
cout << "south";
}
if (pY > Y){
cout << "north";
}
if (pX < X){
cout << "east";
}
if (pX > X){
cout << "west";
}
cout << ".";
}
if (pX == X && pY == Y){
cout << "\n\nYou got it right ";
if (Guesses == 1){
cout << "first time!";
}
else {
cout << "in " << Guesses << " guesses.";
}
Guessed = true;
}
}
while (1);
}
Saturday, 24 October 2009
Thursday, 22 October 2009
Games to watch: Dwarf Fortress
Dwarf Fortress (actually called "Slaves to Armok:God of Blood Chapter II:Dwarf Fortress) is an ascii based game (its currently in alpha, so remember that before criticising it) being made by Tarn Adams (also known as Toady One), head of Bay 12 Games.
The first thing the player will do (well the first thing you might want to do is get a tileset ifyou can't handle the ascii awsomeness) is to generate a world.
Then the player can use this world to play either Dwarf Mode or Adventure Mode.
Dwarf Mode:
This is similar to an RTS in some respects. The player does not directly control the dwarves, rather they give orders such as mining and building things. The player will have to provide food and shelter for their dwarves as well as defend against attackers. After a fort has matured the player will often attempt a 'megaproject' such as a pyramid or tower.
Adventure Mode:
This is like a rougelike. The player controls a single character and can take quests from mayors. This mode has a wrestling system and the player can train various other skills such as swimming or throwing. In the future it is planned that the player will be able to use the same skills as in dwarf mode to build a house.
Here is the site:
http://www.bay12games.com/dwarves/
As of writing the current version is 0.28.181.40d16.
The first thing the player will do (well the first thing you might want to do is get a tileset ifyou can't handle the ascii awsomeness) is to generate a world.
Then the player can use this world to play either Dwarf Mode or Adventure Mode.
Dwarf Mode:
This is similar to an RTS in some respects. The player does not directly control the dwarves, rather they give orders such as mining and building things. The player will have to provide food and shelter for their dwarves as well as defend against attackers. After a fort has matured the player will often attempt a 'megaproject' such as a pyramid or tower.
Adventure Mode:
This is like a rougelike. The player controls a single character and can take quests from mayors. This mode has a wrestling system and the player can train various other skills such as swimming or throwing. In the future it is planned that the player will be able to use the same skills as in dwarf mode to build a house.
Here is the site:
http://www.bay12games.com/dwarves/
As of writing the current version is 0.28.181.40d16.
Subscribe to:
Posts (Atom)