Daniel
2010-03-20 03:32:08
It's a good idea that when you start a programming language for the first time, you should make a minor game (excluding 'Hello World', :p).
So, post your "first" games you've made in various languages and their relevant sources :) (Don't update anything, leave the source in-tact :))
The first game I made in Delphi was Tetris, which I cannot find the source files for.
The first game I made in C++ was a guessing game:
So, post your "first" games you've made in various languages and their relevant sources :) (Don't update anything, leave the source in-tact :))
The first game I made in Delphi was Tetris, which I cannot find the source files for.
The first game I made in C++ was a guessing game:
#include <iostream>
#include <string>
#include <stdlib.h>
bool isNum(std::string str)
{
for (unsigned int i = 0; i < str.length(); i++)
{
if(!(std::isdigit(str[i])))
return false;
}
return true;
}
int strtoint(const std::string str)
{
if(!(isNum(str)))
return 0;
return(atoi(str.c_str()));
}
int main()
{
int TheNumber = 0;
std::string GuessedNumber = "";
int GNumber = 0;
int Guesses = 0;
std::cout << "Welcome to Guess! A game made by Mayazcherquoi\n\n\n";
while (true)
{
std::randomize();
TheNumber = std::random(10) + 1;
using namespace std;
{
guess:
cout << "I am thinking of a number between 1 and 10, what is it?\n - ";
cin >> GuessedNumber;
if(isNum(GuessedNumber))
GNumber = strtoint(GuessedNumber); else
if((GuessedNumber == "x") || (GuessedNumber == "X"))
return 0; else
{
cout << "\nPlease enter a number only, or the letter 'X' (which will close the program).\n\n";
goto guess;
}
while (GNumber != TheNumber)
{
Guesses++;
if(GNumber < TheNumber)
cout << "Not quite right. Higher.\n"; else
cout << "Not quite right. Lower.\n";
guess2:
cout << "\nWhat is the number?:\n - ";
cin >> GuessedNumber;
if(isNum(GuessedNumber))
GNumber = strtoint(GuessedNumber); else
if((GuessedNumber == "x") || (GuessedNumber == "X"))
return 0; else
{
cout << "\nPlease enter a number only, or the letter 'X' (which will close the program).\n\n";
goto guess2;
}
}
cout << "Congratulations! You got it! The number was " << TheNumber << ".\n It took you " << Guesses << " guess(es) to figure it out!\n\n";
Guesses = 0;
}
}
return 0;
}
My first game in PHP was also a guessing game (used POST and a form), which I also cannot find the source for :(