It is currently Sat Aug 02, 2025 12:25 pm

All times are UTC - 5 hours



Forum rules


1.) No trolling. If you cant have fun without being a jerk to others, find some other forum to QQ
2.) No inappropriate/vulgar/sexually explicit posting. Staff reserves the right to deem anything they see fit as inappropriate.
3.) Have fun and don't post anything not geared at having fun!
4.) Please respect staff members and their decisions at all times. If you cannot accept a staff or moderator decision, please appeal to admin Seth.



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Jake's C++ Battle Sim help :D
PostPosted: Tue Nov 22, 2011 2:01 pm 
Major
Major
User avatar
 Profile

Joined: Sat Dec 19, 2009 7:48 pm
Posts: 2693
Gender: male
Okay, so I was sick today and I decided to devote my day to making a extremely basic battle sim. on C++, I just wanted some tips, and there are little bugs (huge) but please report them when you find them... blah blah

Like I said it is very basic. Here is the code:

Code:
#include <iostream>
#include <cmath>
int main ()
{
using namespace std;

cout << "Welcome, to Jakes battle simulator 1000" << endl;
int Jake;
Jake = 100;
int JakeDam;
JakeDam = Jake / 4;
int Bad;
Bad = 50;
int BadDam;
BadDam = Bad / 4;
cout << "This is your hp and current damage." << endl << Jake << endl << JakeDam << endl;
system ("Pause");
cout << "the status of your opponet is this." << endl << Bad << endl << BadDam << endl;
system ("pause");
cout << "press 1 to attack you're opponet, press 2 to run like hell." << endl;
int pchoice;
cin >> pchoice;

if (pchoice <= 1 )
{
Bad = Bad - JakeDam;
cout << "bad is hit" << endl ;
system ("pause");
cout << "new bad hp = ";
cout << Bad << endl;
system ("pause");
cout << "You are hit!" << endl;
system ("pause");
Jake = Jake - BadDam;
cout << "You're new HP is: " << endl;
cout << Jake;
}

cout << "press 1 to attack you're opponet, press 2 to run like hell." << endl;
int r2;
cin >> r2;

if (r2 <= 1 )
{
Bad = Bad - JakeDam;
cout << "bad is hit" << endl ;
system ("pause");
cout << "new bad hp = ";
cout << Bad << endl;
system ("pause");
if (Bad <=0)
{
cout << "Bad is dead" ;
cout << endl;
cout << "end of simulation" << endl;
system ("pause");
return 0;

}


        }
cout << "You are hit!" << endl;
system ("pause");
Jake = Jake - BadDam;
cout << "You're new HP is: " << endl;
cout << Jake;
}
             


I also wanted to include that I did this all by myself, after watching a few tut's of course ;)

Also note that it only goes up to round two currently, if you somehow make it go past that it will say "end of simulation"

_________________
Image

Image


Top
 

 Post subject: Re: Jake's C++ Battle Sim help :D
PostPosted: Tue Nov 22, 2011 3:36 pm 
Captain
Captain
User avatar
 Profile

Joined: Tue Dec 14, 2010 10:55 am
Posts: 1163
cout << "press 1 to attack you're opponet, press 2 to run like hell." << endl;
int r2;
cin >> r2;

if (r2 <= 1 )
{
Bad = Bad - JakeDam;
cout << "bad is hit" << endl ;
system ("pause");
cout << "new bad hp = ";
cout << Bad << endl;
system ("pause");
if (Bad <=0)
{
cout << "Bad is dead" ;
cout << endl;
cout << "end of simulation" << endl;
system ("pause");
return 0;



Take a look here.


Top
 

 Post subject: Re: Jake's C++ Battle Sim help :D
PostPosted: Tue Nov 22, 2011 4:15 pm 
Major
Major
User avatar
 Profile

Joined: Sat Dec 19, 2009 7:48 pm
Posts: 2693
Gender: male
Diazepam wrote:
cout << "press 1 to attack you're opponet, press 2 to run like hell." << endl;
int r2;
cin >> r2;

if (r2 <= 1 )
{
Bad = Bad - JakeDam;
cout << "bad is hit" << endl ;
system ("pause");
cout << "new bad hp = ";
cout << Bad << endl;
system ("pause");
if (Bad <=0)
{
cout << "Bad is dead" ;
cout << endl;
cout << "end of simulation" << endl;
system ("pause");
return 0;



Take a look here.


Thanks, I am constantly learning more today I actually scrapped all of this and went on with a completely different approach. I will pm that to you guys if anyone wants me to ;)

_________________
Image

Image


Top
 

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours



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

Jump to:  
cron

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group  
Copyright Tacticsoft Ltd. 2008   
Updated By phpBBservice.nl