| | |
help my first game!
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
ok this will not work what im trying to do is create a game where you are a miner and need to put mines in 5 different spots im about 1/3 done but i cant get the money to come in after i build the mine i have gone through it three times maby one of yuo could help
code:
-kbcubs-
code:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { int Y; // up-down int X; //left-right int STATION; int MINE; int YOU; int SCAN; int FUEL; int SEL; int MONEY; int TCOUNTER; MONEY = 10000; if (MONEY = 10000){ cout<<"money corect\n"; } else{ MONEY = 10000; } cout<<"checking int...\n"; ////////////// Y = 50; // checking // X = 50; ////////////// if (Y == 50){ cout<<"y corect\n"; } else { Y = 50; //setting int } if (X == 50){ // checking int cout<<"x corect\n"; } else { X = 50; //resetting int } FUEL=10; if (FUEL == 10){ cout<<"fuel corect\n"; } else { FUEL=10; cout<<"fuel correct\n"; } STATION = 1; //at 50,50 if (STATION == 1){ cout<<"station corect\n"; } else { STATION = 1; cout<<"station corect\n"; } while (STATION == 1){ //------------------------------------------------------------------------------ if (MINE == 1){ cout<<"you have sucessfully mined 2metric tones of\n mixed rock coal and dirt!\n"; cout<<"you sold the mixed dirt for 200$!"; MONEY = MONEY+120; cout<<"taxes and gas out of 200 - 80 = 120\n"; } if (MINE == 2){ cout<<"you have sucessfully mined 4metric tones of\n mixed rock coal and dirt!\n"; cout<<"you sold the mixed dirt for 400$!"; MONEY = MONEY+240; cout<<"taxes and gas out of 400 - 160 = 240\n"; } if (MINE == 3){ cout<<"you have sucessfully mined 6metric tones of\n mixed rock coal and dirt!\n"; cout<<"you sold the mixed dirt for 600$!"; MONEY = MONEY+370; cout<<"taxes and gas out of 600 - 230 = 270\n"; } if (MINE == 4){ cout<<"you have sucessfully mined 8metric tones of\n mixed rock coal and dirt!\n"; cout<<"you sold the mixed dirt for 800$!"; MONEY = MONEY+480; cout<<"taxes and gas out of 800 - = 240\n"; } //------------------------------------------------------------------------------ cout<<"you are at---"<< Y <<"-"<< X <<"\n"; cout<<" 1=up 2=down 3=left 4=right 5=scan 6=skip 7=BUY-fuel 8=create sml mine\n9=create research lab 10=create refiner\n\n"; //choices cin>>SEL; //------------------------------------------------------------------------------ if (SEL == 1){ //selection Y = Y+1; //stating NEW int if (Y > 100){ //checking not greater than 100 cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n"; Y = Y-1; } else { cout<<"you have moved to" << Y << "-" << X <<"\n"; FUEL = FUEL-1; cout<<"your current fuel level is="<<FUEL<<"0%\n"; } } //------------------------------------------------------------------------------ if (SEL == 2){ Y = Y-1; //stating NEW int if (Y < 0){ //checking no lesser than 0 cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n"; Y = Y+1; FUEL = FUEL+1; } else { cout<<"you have moved to" << Y << "-" << X <<"\n"; FUEL = FUEL-1; cout<<"your current fuel level is="<<FUEL<<"0%\n"; } } //------------------------------------------------------------------------------ if (SEL == 3){ X = X-1; //stating NEW int if (X < 0){ //checking not greater than 100 cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n"; X = X-1; } else { cout<<"you have moved to" << Y << "-" << X <<"\n"; FUEL = FUEL-1; cout<<"your current fuel level is="<<FUEL<<"0%\n"; } } //------------------------------------------------------------------------------ if (SEL == 4){ X = X + 1; if (X > 100){ //checking not greater than 100 cout<<"A sign clearley states :NO TRESSPASSING!: in big BOLD letters!\n"; X = X-1; } else { cout<<"you have moved to" << Y << "-" << X <<"\n"; FUEL = FUEL-1; cout<<"your current fuel level is="<<FUEL<<"0%\n"; } } //------------------------------------------------------------------------------ if (SEL==5){ // 1 2 3 4 5 cout<<" there is 5 possibel mine spots they are at\n X-55 Y-52\n X-72 Y-75 \n X-32 U-45\n X-10 Y-34\n X-72 Y-12\n"; } //------------------------------------------------------------------------------ if (SEL==6){ cout<<"SKIPPING\n"; } //------------------------------------------------------------------------------ if (SEL==7){ cout<<"BUYING FUEL...\n"; FUEL = 10; MONEY = MONEY-100; cout<<"you curently have="<<MONEY<<"$\n"; } //------------------------------------------------------------------------------ if (SEL==8){ if (Y==55){ //1 if(X==52){ cout<<"you built a small mine 3 turns remaning!\n"; MINE=MINE+1; MONEY = MONEY-1000; cout<<"your current money is="<<MONEY<<"\n"; } } if (Y==72){//2 if(X==75){ cout<<"you built a small mine 3 turns remaning!\n"; MINE=MINE+1; MONEY = MONEY-1000; cout<<"your current money is="<<MONEY<<"\n"; } } if (Y == 32){//3 if(X == 45){ cout<<"you built a small mine 3 turns remaning!\n"; MINE=MINE+1; MONEY = MONEY-1000; cout<<"your current money is="<<MONEY<<"\n"; } } if (Y==10){//4 if(X==34){ cout<<"you built a small mine 3 turns remaning!\n"; MINE=MINE+1; MONEY = MONEY-1000; cout<<"your current money is="<<MONEY<<"\n"; } } if (Y==72){ if (X==12){ cout<<"you built a small mine 3 turns remaning!\n"; MINE=MINE+1; MONEY = MONEY-1000; cout<<"your current money is="<<MONEY<<"\n"; } } else { cout<<"you were unable to build the mine! there is no valid resource...\n"; } } } }
-kbcubs-
With out programing i could not live.
C++ Syntax (Toggle Plain Text)
if ( MONEY = 10000 )
C++ Syntax (Toggle Plain Text)
if ( MINE == 1 )
Also consider a switch statement instead of a long string of ifs. And consider function to do the contents of each block.
Using cin for number input may be problematic -- consider taking user input as a string and then converting to a numeric value.
Avoid "magic" numbers. Given them a name via #define, const, or perhaps array index, or even character literal.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- Word Association Game (Posting Games)
- recall a game with mad red monks? (Geeks' Lounge)
- Big Game need progrmmers (C++)
- PHP Programmer interested in an existing project? Game! =o] (PHP)
- Help With An Online Game! (Web Development Job Offers)
- Your Fav Game (Geeks' Lounge)
Other Threads in the C++ Forum
- Previous Thread: Button can't display when selected tabpage is visible, Bug?
- Next Thread: grant access
| Thread Tools | Search this Thread |
api array based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






