#include <iostream>
using namespace std;
int main()
{
int x;
x = 100;
double y = 0.0;
double i = 0.0;
int Dead;
Dead = 0;
cin >> y;
cin >> i;
if (y - x)
cout << "Hit \n";
if ( x == Dead)
cout << "Game over";
system ("pause");
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int x;
x = 100;
double y = 0.0;
double i = 0.0;
int Dead;
Dead = 0;
cin >> y;
cin >> i;
if (y - x)
cout << "Hit \n";
if ( x == Dead)
cout << "Game over";
system ("pause");
return 0;
}
(Merged topics) This is the other topic's OP, not sure if code is different. --Mar
Well you could have a variable called 'Lives' and set that to a set amount and deduct 1 from lives every time you die, then terminate the program after lives = 0.
#include <iostream>
using namespace std;
int main()
{
int x;
x = 100;
double y = 0.0;
double i = 0.0;
int Dead;
Dead = 0;
`int lives = 3;
cin >> y;
cin >> i;
if (y - x)
cout << "Hit \n";
if ( x == Dead)
lives--;
if(lives == 0)
cout << "Game over";
system ("pause");
return 0;
}
MarauderIIC wrote:You know those people that are like "CHECK IT OUT I just made Linux run on this piece of celery [or other random object]!!"? Yeah, that's Falco, but with ES.
Dear god, they actually ported ES to a piece of celery!
Martin Golding wrote:
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
#include <iostream>
using namespace std;
int main()
{
int x;
x = 100;
double y = 0.0;
double i = 0.0;
int Dead;
Dead = 0;
cin >> y;
if (y - x)
cout << "Hit \n";
cin >> i;
if (i - x)
cout << "Hit again watch it! \n";
if ( x == Dead)
cout << "Game over \n";
else
cout << "Heal up \n";
system ("pause");
return 0;
}
MarauderIIC wrote:Actually, does (y - x) test the value of (y - x), or whether the operation was successful?
Is that a serious question, if so I don't have a clue either.
Jokeboxproductions wrote:I kind of thought I put this in the wrong place so I put it in the other forum.
It's probably better if you had just left it here and requested the mods just move it. Having two topics is worse than having one in the wrong place. Oh well.
EDIT: Actually I think you can delete your own topics in phpBB3 using the little "X" button right next to edit in top right corner of your post.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
Seriously. I haven't gotten around to trying it yet. I'd assume it'd return the value, as
if ( (x = new Class(initializers) ) is a way to assign while testing whether or not the assignment was successful, IIRC. But that's an assignment, not an expression.
Also yeah, don't cross-post. Just leave it and post a move request. I merged the topics. Feel free to delete any of your own posts that are total duplicates.
Last edited by MarauderIIC on Tue Nov 11, 2008 2:21 pm, edited 2 times in total.
Reason:see sig
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
#include <iostream>
using namespace std;
int main()
{
int life = 100;
double damage = 0.0;
do
{
cin >> damage;
life -= damage;
cout << "You took " << damage << " damage. Current life: " << life << endl;
}while ( life > 0 );
cout << "Game over";
cin.get();
return 0;
}
Yeah.. I was bored.
I use your code and like 5billion Gameovers Came flying on the screen.
because of
while ( life > 0 ); //that means that if life is bigger... which it always will be until it gets to 0... and it will repeat.. If i were you, i would use if
Jokeboxproductions wrote:
I use your code and like 5billion Gameovers Came flying on the screen.
Lol what? I compiled it and it worked correctly. Did you edit it?
davidthefat wrote:
because of
while ( life > 0 ); //that means that if life is bigger... which it always will be until it gets to 0... and it will repeat.. If i were you, i would use if
cout << "Game over";
cin.get();
return 0;
}
It shouldn't give you game over but only once after which it exits. There's no need for an if statement unless you only want to take damage once?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
There is no way for his code to output game over more than once. Game over & exit are in the same basic block. Copy and paste it, perhaps. The only thing I'd say is that since
#include <iostream>
using namespace std;
int main()
{
int x;
x = 100;
double y = 0.0;
double i = 0.0;
int Dead;
Dead = 0;
int lives = 0;
cin >> y;
cin >> i;
if (y - x)
cout << "Hit \n";
if ( x == Dead)
lives--;
if(lives == 0)
cout << "Game over";
;
system ("pause");
return 0;
}