Toribash
C++ INCREDIBLY SIMPLE GAME
I made a guessing game on C++ today, it took me about 2 hours.
It's shockingly simple, so do not think for a seconds this is me saying 'I'm good at this shit!'. I just wanted to show you guys as it's the first thing I've -made- with C++.
You can't actually play it unless you have Visual C++ Express 20XX, but I'll post the code just to show it anyway. :F

#include <iostream>
using namespace std;

void main () {
	int y = 0;
	int a = 0;
	int iTurn = 1;
	int iPoints = 0;
	if (iTurn > 5)
	{
	 cout << "Loser." << endl;
	}
	cout << "This is a guessing game in which you type a random number and are given points!" << endl;
	cout << "Win points by guessing numbers in the right ranges. 5 points wins ;)" << endl;
	cout << "The ranges are 0-20, 20>, 20 and <0. Good luck!" << endl;

	if (iTurn = 1)
	{
		cin >> y;
	if ((y > 0) && (y < 20)) {
		std::cout << "y is more than 0, but less than 20" << std::endl;
		a = 1;
	} else if (y > 20) {
		std::cout << "y is more than 20" << std::endl;
		a = 2;
	} else if (y == 20){
		std::cout << "you didn't expect y to equal 20 did you?" << std::endl;
		a = 3;
	} else {
		std::cout << "y is less than or equal to 0 fagit" << std::endl;
		a = 4;
	}


	if (a == 1)
	{
		cout << "1 point" << endl;
		a = 0;
		++iPoints;
		iTurn = 2;
	}else {
		cout << "Loser :p" << endl;
	}
	}


		if (iTurn = 2 && iPoints >= 1)
	{
		cin >> y;
	if ((y > 0) && (y < 20)) {
		std::cout << "y is more than 0, but less than 20" << std::endl;
		a = 1;
	} else if (y > 20) {
		std::cout << "y is more than 20" << std::endl;
		a = 2;
	} else if (y == 20){
		std::cout << "you didn't expect y to equal 20 did you?" << std::endl;
		a = 3;
	} else {
		std::cout << "y is less than or equal to 0 fagit" << std::endl;
		a = 4;
	}
	
    if (a == 3)
	{
		cout << "2 points" << endl;
		a = 0;
		++iPoints;
		iTurn = 3;
	}else {
		cout << "Loser :p" << endl;
	}


			if (iTurn = 3 && iPoints >= 2)
	{
		cin >> y;
	if ((y > 0) && (y < 20)) {
		std::cout << "y is more than 0, but less than 20" << std::endl;
		a = 1;
	} else if (y > 20) {
		std::cout << "y is more than 20" << std::endl;
		a = 2;
	} else if (y == 20){
		std::cout << "you didn't expect y to equal 20 did you?" << std::endl;
		a = 3;
	} else {
		std::cout << "y is less than or equal to 0 fagit" << std::endl;
		a = 4;
	}
	
    if (a == 2)
	{
		cout << "3 points" << endl;
		a = 0;
		++iPoints;
		iTurn = 4;
	}else {
		cout << "Loser :p" << endl;
	}
			}

						if (iTurn = 4 && iPoints >= 3)
	{
		cin >> y;
	if ((y > 0) && (y < 20)) {
		std::cout << "y is more than 0, but less than 20" << std::endl;
		a = 1;
	} else if (y > 20) {
		std::cout << "y is more than 20" << std::endl;
		a = 2;
	} else if (y == 20){
		std::cout << "you didn't expect y to equal 20 did you?" << std::endl;
		a = 3;
	} else {
		std::cout << "y is less than or equal to 0 fagit" << std::endl;
		a = 4;
	}
	
    if (a == 3)
	{
		cout << "4 points" << endl;
		a = 0;
		++iPoints;
		iTurn = 5;
	}else {
		cout << "Loser :p" << endl;
	}
			}

						if (iTurn = 5 && iPoints >= 4)
	{
		cin >> y;
	if ((y > 0) && (y < 20)) {
		std::cout << "y is more than 0, but less than 20" << std::endl;
		a = 1;
	} else if (y > 20) {
		std::cout << "y is more than 20" << std::endl;
		a = 2;
	} else if (y == 20){
		std::cout << "you didn't expect y to equal 20 did you?" << std::endl;
		a = 3;
	} else {
		std::cout << "y is less than or equal to 0 fagit" << std::endl;
		a = 4;
	}
	
    if (a == 4)
	{
		cout << "WINNER!" << endl;
		a = 0;
		++iPoints;
		iTurn = 6;
	}else {
		cout << "Loser :p" << endl;
	}
			}
}
}
Basically the script is thus:

set variables
output info to player

check turn
wait for players input
check turn and points
output info
does players input fit with the conditions on this round?
if yes, give 1 point and go to the next turn
if no, output 'Loser ' and end
if the player has 5 points, output 'WINNER!' and end

The sequence to win is:
A number from 0 - 20
20
A number higher than 20
20
A number less than 0
Last edited by Fear; Apr 16, 2011 at 11:47 PM.
y is less than or equal to 0 fagit
well played sir

if you want something fun to code though
try making a magic 8 ball
the first thing i ever coded was an epic magic 8 ball which provided responses to questions
the easy part is making it poop out responses for yes or no questions
the fun part is making it be able to tell what kind of question you are asking and provide an appropriate response

(yes i have a c++ compiler, yes i ran it, no i did not win, and yes i read the win sequence before hand but forgot)
Last edited by Orion; Apr 17, 2011 at 12:48 AM.
Free Pv2Caribou
chocolate salty balls ~ chef


"say everybody have you seen my balls there big n' salty n' brown"
Free Pv2Caribou
ok i'm coloring my pick and fucking winning this shit
Last edited by Orion; Apr 17, 2011 at 05:53 AM.
Free Pv2Caribou