online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <unistd.h> #include <stdlib.h> #include <iomanip> #include <cmath> using namespace std; int main(){ start: long long x=15,y=72,px=1,py=1,bombx=0,bomby=0,xholder,bombdirection=5,pause=0; string go,Sgo,pausemenu="menu",player="+",top="-",right="|",bottom="-",left="|",bombnormal="o",bombexploding="X",block="#"; // settings settings: system("clear"); cout<<"|---------------[creating new world]---------------|"<<endl; cout<<"| (Choose a letter to change its settings) |"<<endl; cout<<"| |"<<endl; cout<<"| [x] to change x level ("<<x <<") |"<<endl; cout<<"| [y] to change y level ("<<y <<")"; if(y/10==0){cout<<" |"<<endl;} else if(y/100==0){cout<<" |"<<endl;} else if(y/1000==0){cout<<" |"<<endl;} cout<<"| [p] to change how you look ("<<player <<") |"<<endl; cout<<"| [t] to change top layer ("<<top <<") |"<<endl; cout<<"| [r] to change right layer ("<<right <<") |"<<endl; cout<<"| [b] to change bottom layer ("<<bottom <<") |"<<endl; cout<<"| [l] to change left layer ("<<left <<") |"<<endl; cout<<"| [o] to change normal bomb midair ("<<bombnormal<<") |"<<endl; cout<<"| [d] to change bomb while exploding ("<<bombexploding<<") |"<<endl; cout<<"| [v] to change how blocks look ("<<block <<") |"<<endl; cout<<"| |"<<endl; cout<<"| are these sittings okey? [yes/no] |"<<endl; cout<<"| |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>Sgo; if(Sgo=="x"){ system("clear"); cout<<"|-------------------[changing x]-------------------|"<<endl; cout<<"| choose the new hight |"<<endl; cout<<"| (with a max of 15) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>x; goto settings; } else if(Sgo=="y"){ system("clear"); cout<<"|-------------------[changing y]-------------------|"<<endl; cout<<"| choose the new whidth |"<<endl; cout<<"| (with a max of 151) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>y; goto settings; } else if(Sgo=="p"){ system("clear"); cout<<"|-----------------[changing player]----------------|"<<endl; cout<<"| choose how you look |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>player; goto settings; } else if(Sgo=="t"){ system("clear"); cout<<"|---------------[changing top layer]---------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>top; goto settings; } else if(Sgo=="r"){ system("clear"); cout<<"|--------------[changing right layer]--------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>right; goto settings; } else if(Sgo=="b"){ system("clear"); cout<<"|--------------[changing bottom layer]-------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>bottom; goto settings; } else if(Sgo=="l"){ system("clear"); cout<<"|---------------[changing left layer]--------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>left; goto settings; } else if(Sgo=="o"){ system("clear"); cout<<"|---------------[changing bomb midair]-------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>bombnormal; goto settings; } else if(Sgo=="d"){ system("clear"); cout<<"|--------------[changing bomb expoding]------------|"<<endl; cout<<"| choose a new skin |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>bombexploding; goto settings; } else if(Sgo=="v"){ system("clear"); cout<<"|--------------[changing block shape]--------------|"<<endl; cout<<"| choose the new blocks |"<<endl; cout<<"| (only one charecter) |"<<endl; cout<<"|--------------------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; cin>>block; goto settings; } else if(Sgo=="no"){goto settings;} else if(Sgo=="yes"){} else{cout<<endl<<"I didn't understand"<<"\033[F"<<"| <";} xholder=x; long long graph[x][y],blocks[x][y]; px=x/2+ 1; if(y%2==0){py=y/2;} else{py=y/2+ 1;} // frame handler nextframe: system("clear"); //pause menu ------- while(pause==1){ system("clear"); if(pausemenu=="menu"){ cout<<"|----------------------------------------|"<<endl; cout<<"| |"<<endl; cout<<"| {game paused} |"<<endl; cout<<"| |"<<endl; cout<<"| |"<<endl; cout<<"| [continue (p)] [ help (h) ] |"<<endl; cout<<"| [ credits (c)] [sittings (s)] |"<<endl; cout<<"| [ restart (r)] [exit game(t)] |"<<endl; cout<<"| |"<<endl; cout<<"|----------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; } if(pausemenu=="help"){ cout<<"|----------------------------------------|"<<endl; cout<<"| |"<<endl; cout<<"| {game help} |"<<endl; cout<<"| |"<<endl; cout<<"| > <w,a,s,d> to move around |"<<endl; cout<<"| > double use a key to sprint |"<<endl; cout<<"| > you can use two keys at a time |"<<endl; cout<<"| ------------------------------------ |"<<endl; cout<<"| > <e + move key> to throw bomb |"<<endl; cout<<"| > a bomb can destroy blocks |"<<endl; cout<<"| ------------------------------------ |"<<endl; cout<<"| > <[,]> to place/remove blocks |"<<endl; cout<<"| > <p> to pause/unpause |"<<endl; cout<<"| |"<<endl; cout<<"| |"<<endl; cout<<"| [continue (p)] [ help (h) ] |"<<endl; cout<<"| [ credits (c)] [sittings (s)] |"<<endl; cout<<"| [ restart (r)] [exit game(t)] |"<<endl; cout<<"| [back (b)] |"<<endl; cout<<"|----------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; } if(pausemenu=="credits"){ cout<<"|----------------------------------------|"<<endl; cout<<"| |"<<endl; cout<<"| {game credits} |"<<endl; cout<<"| |"<<endl; cout<<"| clickednebula3#4710 (discord) |"<<endl; cout<<"| -Abdullah Anas Alsalman |"<<endl; cout<<"| |"<<endl; cout<<"| [continue (p)] [ help (h) ] |"<<endl; cout<<"| [ credits (c)] [sittings (s)] |"<<endl; cout<<"| [ restart (r)] [exit game(t)] |"<<endl; cout<<"| [back (b)] |"<<endl; cout<<"|----------------------------------------|"<<endl; cout<<"| < > |"<<endl<<"\033[F"; cout<<"| <"; } cin>>go; if(go=="p"){pause=0;} if(go=="b"){pausemenu="menu";} if(go=="h"){pausemenu="help";} if(go=="c"){pausemenu="credits";} if(go=="t"){goto exited;} if(go=="r"){goto start;} if(go=="s"){goto settings;} } //pause menu ------- //bomb updater ------- if(bombdirection==0){bombx++;} if(bombdirection==1){bomby=bomby+ 2;} if(bombdirection==2){bombx--;} if(bombdirection==3){bomby=bomby- 2;} //bomb updater ------- // terrain cout<<left; for(long long i=1;i<=y;i++){cout<<top;} cout<<right; while(x>0){ cout<<endl<<left; for(long long i=1;i<=y;i++){ //------------------------(terrain editor)------------------------ if(px==x&&py==i){ if(px==bombx&&py==bomby){goto deathbomb;} cout<<player; continue; } else if(bombx==x&&bomby==i){ if(blocks[x][i]==1){blocks[x][i]=0; bombx=0; bomby=0; cout<<bombexploding; continue; } cout<<bombnormal; continue; } else if(blocks[x][i]==1){ cout<<block; continue; } //------------------------(terrain editor)------------------------ cout<<" "; } cout<<right; x--; } x=xholder; cout<<endl<<left; for(long long i=1;i<=y;i++){cout<<bottom;} cout<<right<<endl; // options cout<<"move around with (w,a,s,d) keys"<<endl<<"place and remove blocks with ([,]) keys"<<endl<<"throw a bomb with(e+w,e+a,e+s,e+d)"<<endl<<"pause with (p)"<<endl; cout<<"What should i do? <__________>"<<endl<<"(click enter afterwards)"<<"\033[F"<<"What should i do? <"; cin>>go; // functions (directions) //------------------------ {normal} if(go=="up" ||go=="w"){px++; } if(go=="down" ||go=="s"){px--; } if(go=="left" ||go=="a"){py=py- 2;} if(go=="right"||go=="d"){py=py+ 2;} //------------------------ {sprinting} if(go=="ww" ||go=="www"){px=px+ 2;} if(go=="ss" ||go=="sss"){px=px- 2;} if(go=="aa" ||go=="aaa"){py=py- 4;} if(go=="dd" ||go=="ddd"){py=py+ 4;} //------------------------ {corner moves} if(go=="wa" ||go=="aw" ){px++; py=py- 2;} if(go=="wd" ||go=="dw" ){px++; py=py+ 2;} if(go=="sa" ||go=="as" ){px--; py=py- 2;} if(go=="sd" ||go=="ds" ){px--; py=py+ 2;} // functions (blocks) //------------------------(place)------------------------// if(go=="place"||go=="["||go=="[["){blocks[px][py]=1;} if(go=="[d"||go=="[dd"||go=="[[d") {blocks[px][py+ 2]=1;} if(go=="[ds"||go=="[sd" ) {blocks[px- 1][py+ 2]=1;} if(go=="[s"||go=="[ss"||go=="[[s") {blocks[px- 1][py]=1;} if(go=="[sa"||go=="[as" ) {blocks[px- 1][py- 2]=1;} if(go=="[a"||go=="[aa"||go=="[[a") {blocks[px][py- 2]=1;} if(go=="[aw"||go=="[wa" ) {blocks[px+ 1][py- 2]=1;} if(go=="[w"||go=="[ww"||go=="[[w") {blocks[px+ 1][py]=1;} if(go=="[wd"||go=="[dw" ) {blocks[px+ 1][py+ 2]=1;} //------------------------(place)------------------------// //------------------------(break)------------------------// if(go=="break"||go=="]"||go=="]]"){blocks[px][py]=0;} if(go=="]d"||go=="]dd"||go=="]d") {blocks[px][py+ 2]=0;} if(go=="]ds"||go=="]sd" ) {blocks[px- 1][py+ 2]=0;} if(go=="]s"||go=="]ss"||go=="]s") {blocks[px- 1][py]=0;} if(go=="]sa"||go=="]as" ) {blocks[px- 1][py- 2]=0;} if(go=="]a"||go=="]aa"||go=="]a") {blocks[px][py- 2]=0;} if(go=="]aw"||go=="]wa" ) {blocks[px+ 1][py- 2]=0;} if(go=="]w"||go=="]ww"||go=="]w") {blocks[px+ 1][py]=0;} if(go=="]wd"||go=="]dw" ) {blocks[px+ 1][py+ 2]=0;} //------------------------(break)------------------------// // functions (bomb) if(go=="ew"){ bombx=px+ 1; bomby=py; px--; bombdirection=0; } if(go=="ed"){ bombx=px; bomby=py+ 2; py--; py--; bombdirection=1; } if(go=="es"){ bombx=px- 1; bomby=py; px++; bombdirection=2; } if(go=="ea"){ bombx=px; bomby=py- 2; py++; py++; bombdirection=3; } // functions (other) if(go=="pause"||go=="p"||go=="pp"){pause=1;} if(go=="creeper"){goto awwman;} // boundries if(px>x){px=x;} if(px<1){px=1;} if(py>y){ if(y%2==0){py=y;} else{py=y- 1;} } if(py<1){py=1;} goto nextframe; // death scenes deathbomb: system("clear"); cout<<"\033[F"; cout<<"|---------------------------------------|"<<endl; cout<<"| game over! |"<<endl; cout<<"| |"<<endl; cout<<"| {you got exploded by your bomb} |"<<endl; cout<<"|---------------------------------------|"; return 0; awwman: system("clear"); cout<<"\033[F"; cout<<"|---------------------------------------|"<<endl; cout<<"| game over! |"<<endl; cout<<"| |"<<endl; cout<<"| {aww man!} |"<<endl; cout<<"|---------------------------------------|"; return 0; exited: system("clear"); cout<<"\033[F"; cout<<"|---------------------------------------|"<<endl; cout<<"| game over! |"<<endl; cout<<"| |"<<endl; cout<<"| {you left the game} |"<<endl; cout<<"|---------------------------------------|"; return 0; // other stuff }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue