Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Binary..]Basic Console Game

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries
View previous topic :: View next topic  
Author Message
hyphen
Advanced Cheater
Reputation: 0

Joined: 12 Sep 2008
Posts: 84
Location: Not Having Fun

PostPosted: Tue Jun 30, 2009 9:19 pm    Post subject: [Binary..]Basic Console Game Reply with quote

I'm sorry this isn't in the Binaries section.
Unfortunately, I'm like 30 short of the 100 posts requirement >.<
Mmmmmmm I hope this thread duzzn't get deleted.

Anyways was just bored today, decided to spend 3 quarter hours making this useless 2P console game.

I designed to randomly select between two people. (Say you have an extra whatever and can only share it with one of two friends..)

Mediafire Link: http://www.mediafire.com/download.php?mtmymgzy0nm

Code:
//Some random console application game
//Made by Hyphen
//Took approx. 45 mins
//8:50 added sleeptimes to stop everything from happening so fast

//My Includes (some useless)
#include<iostream.h> // Input/Output
#include<windows.h> // for Sleep()
#include<cmath> // for math
#include<cstdio> // for math
#include<cstdlib>
#include<conio.h> // for "press any key to continue"

//these macros didn't work... why? DX
#define player1 Bob
#define player2 UberBob

//randomizer functions prototypes
int zero2ten();
int zero2twenty();

//global stuffz
unsigned short p1hp = 100, p2hp = 100; //l15
enum act {attack,smash,heal};
act action;
int damage;

int main()
{
cout << "The battle between player1 and player2 has started!" << endl;
cout << "player1 has " << p1hp << "/100 hp." << endl;
cout << "player2 has " << p2hp << "/100 hp." << endl;

int starter = rand()%2;
if (starter == 1)
{

}
 //l30
for(;p1hp > 0 && p1hp < 125 && p2hp > 0 && p2hp < 125 ;)
{
//player1 turn
cout << "player1" << "'s turn." << endl << "A: Attack  S: Smash Attack  D: Cast Heal" << endl;
for(;p1hp > 0 && p1hp < 125 && p2hp > 0 && p2hp < 125 ;)
{
if(GetAsyncKeyState(0x41))
{action = attack; break;}
if(GetAsyncKeyState(0x53))
{action = smash; break;}
if(GetAsyncKeyState(0x44))
{action = heal; break;}
}

Sleep(100);

//player1 actions      l45
if (action == attack)
{
damage = zero2ten();
p2hp = p2hp - damage;
cout << "player1 dealed " << damage << " damage to player2. ";
Sleep(500);
cout << "player2 has " << p2hp << "/100 hp." << endl;
Sleep(800);
if (p2hp > 124 || p2hp <1)
break;
}

if (action == smash)
{
damage = zero2twenty();
if (damage < 11)
cout << "player1" << "'s smash attack missed!" << endl;
else
{
p2hp = p2hp - damage;
cout << "player1 dealed " << damage << " damage to player2.";
Sleep(500);
cout << "player2 has " << p2hp << "/100 hp." << endl; //l65
}
Sleep(800);
if (p2hp > 124 || p2hp <1)
break;
}

if (action == heal)
{
damage = zero2ten();
if (damage = 10)
{
p2hp = p2hp + 10;
cout << "player1 accidentely healed player2 for 10 hp!";
}
else
{
p1hp = p1hp + damage;
cout << "player1 healed himself for " << damage << "hp";
}
Sleep(500);
if (p1hp > 100 && p1hp < 125)
p1hp = 100;
cout << "player1 has " << p1hp << "/100 hp." << endl;
Sleep(800);
}

//player2 turn
cout << "player2" << "'s turn." << endl << "NUM_1: Attack  NUM_2: Smash Attack  NUM_3: Cast Heal" << endl;
for(;p1hp > 0 && p1hp < 125 && p2hp > 0 && p2hp < 125 ;)
{
if(GetAsyncKeyState(VK_NUMPAD1))
{action = attack; break;}
if(GetAsyncKeyState(VK_NUMPAD2))
{action = smash; break;}
if(GetAsyncKeyState(VK_NUMPAD3))
{action = heal; break;}
}

Sleep(100);

//player2 actions
if (action == attack)
{
damage = zero2ten();
p1hp = p1hp - damage;
cout << "player2 dealed " << damage << " damage to player1. ";
Sleep(500);
cout << "player1 has " << p1hp << "/100 hp." << endl;
Sleep(800);
if (p1hp > 124 || p1hp <1)
break;
}

if (action == smash)
{
damage = zero2twenty();
if (damage < 11)
cout << "player2" << "'s smash attack missed!" << endl;
else
{
p1hp = p1hp - damage;
cout << "player2 dealed " << damage << " damage to player1.";
Sleep(500);
cout << "player1 has " << p1hp << "/100 hp." << endl;
}
Sleep(800);
if (p1hp > 124 || p1hp <1)
break;
}

if (action == heal)
{
damage = zero2ten();
if (damage = 10)
{
p1hp = p1hp + 10;
cout << "player2 accidentely healed player1 for 10 hp!";
}
else
{
p2hp = p2hp + damage;
cout << "player2 healed himself for " << damage << "hp";
}
Sleep(500);
if (p2hp > 100 && p2hp < 125)
p2hp = 100;
cout << "player2 has " << p2hp << "/100 hp." << endl;
Sleep(800);
}

}

if (p1hp > 124 || p1hp <1)
cout << "player2 wins! player1 is ***" << endl;
else
cout << "player1 wins! player2 is ***" << endl;

Sleep(5000);
system("pause");
return 0;
}


//randomizers
int zero2ten()
{
int retNumber1 = rand()%11; //0 to 10
return retNumber1;
}

int zero2twenty()
{
int retNumber2 = rand()%21; //0 to 20
return retNumber2;
}


Nothing special in there just thought I may as well post it somewhere.

Begs mods to move this into the right section be4 I get bannned.
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Tue Jun 30, 2009 9:22 pm    Post subject: Reply with quote

since you posted code, you are fine. Binaries is for finished projects w/o code
_________________
Back to top
View user's profile Send private message
hyphen
Advanced Cheater
Reputation: 0

Joined: 12 Sep 2008
Posts: 84
Location: Not Having Fun

PostPosted: Tue Jun 30, 2009 9:35 pm    Post subject: Reply with quote

blankrider wrote:
since you posted code, you are fine. Binaries is for finished projects w/o code


Ah alright then. Thanks for enlightening me.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Jul 01, 2009 12:02 am    Post subject: Re: [Binary..]Basic Console Game Reply with quote

hyphen wrote:
Begs mods to move this into the right section be4 I get bannned.


why would you get banned for such a simple mistake?

blankrider wrote:
since you posted code, you are fine. Binaries is for finished projects w/o code


you're plenty welcome to post code in binaries.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Sun Aug 09, 2009 9:01 am    Post subject: Reply with quote

If you're writing in C++, why not to do OO?

Also, why:
Code:
for(;p1hp > 0 && p1hp < 125 && p2hp > 0 && p2hp < 125 ;)
instead of
Code:
while(p1hp > 0 && p1hp < 125 && p2hp > 0 && p2hp < 125)

Kinda buggy, eg:
Code:
if (damage = 10)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming -> Binaries All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites