Column Posted December 6, 2014 Report Share Posted December 6, 2014 #include <iostream>#include <windows.h>using namespace std;int y, x;char Map[100][100] = { "----ATEM KNIGHT----- ", "#################### *-------Legenda-------*", "# # % # | |", "# # # # # ######### | #-> Wall |", "# # # # # ### %## | @-> Character |", "# # # # ## ### #### | !-> Finish Line |", "#@#% %# !# * *### | %-> Enemies |", "#################### | Copyright->'Column' |", " | or Copyright->'Atem'|", " *---------------------*" };int GameSpeed = 90;int level = 1;int stopgame = false;int HP = 100;int Score = 0;int main(){ while(stopgame == false && level == 1) { system("cls"); for(int y=0; y<20;y++) { cout<<Map[y]<<endl; } cout<<"Level: "<<level<<endl; cout<<"Score: "<<Score<<endl; cout<<"HP: "<<HP<<endl; for(y=0;y<20;y++) { for(x=0;x<20;x++) { switch(Map[y][x]) { case '@': { if(GetAsyncKeyState(VK_UP) != 0) { int y2 = (y-1); switch(Map[y2][x]) { case ' ': { Map[y][x] = ' '; y -= 1; Map[y2][x] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; } case '*': { HP +=5; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; Score += 4; } } } if(GetAsyncKeyState(VK_DOWN) != 0) { int y2 = (y+1); switch(Map[y2][x]) { case ' ': { Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; y += 1; Score += 4; Map[y2][x] = '@'; } } } if(GetAsyncKeyState(VK_RIGHT) != 0) { int x2 = (x+1); switch(Map[y][x2]) { case ' ': { Map[y][x] = ' '; x += 1; Map[y][x2] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; x += 1; Map[y][x2] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; x += 1; Score += 4; Map[y][x2] = '@'; } } } if(GetAsyncKeyState(VK_LEFT) != 0) { int x2 = (x-1); switch(Map[y][x2]) { case ' ': { Map[y][x] = ' '; x -= 1; Map[y][x2] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; x -= 1; Map[y][x2] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; x-=1; Score += 4; Map[y][x2] = '@'; } } } }break; } } } Sleep(GameSpeed); } while(stopgame == false && level == 2) { system("cls"); cout<<"Felicitari! Ai obtinut Level: "<<level<<", scor"<<endl; system("pause"); }return 0;}PS: "Am realizat acest joc pentru programatorii incepatori si de asemenea ii incurajez sa invete inca din clasele 9-12 librariile <windows.h><ctype.h><ctime.h> chiar si altele ce se fac prin facultate! Succes programatorilor!" Quote Link to comment Share on other sites More sharing options...
MARIUSCS Posted December 6, 2014 Report Share Posted December 6, 2014 Multumesc! E numai bun ca si exemplu Quote Link to comment Share on other sites More sharing options...
Ganav Posted December 6, 2014 Report Share Posted December 6, 2014 #include <iostream>#include <windows.h>using namespace std;int y, x;char Map[100][100] = { "----ATEM KNIGHT----- ", "#################### *-------Legenda-------*", "# # % # | |", "# # # # # ######### | #-> Wall |", "# # # # # ### %## | @-> Character |", "# # # # ## ### #### | !-> Finish Line |", "#@#% %# !# * *### | %-> Enemies |", "#################### | Copyright->'Column' |", " | or Copyright->'Atem'|", " *---------------------*" };int GameSpeed = 90;int level = 1;int stopgame = false;int HP = 100;int Score = 0;int main(){ while(stopgame == false && level == 1) { system("cls"); for(int y=0; y<20;y++) { cout<<Map[y]<<endl; } cout<<"Level: "<<level<<endl; cout<<"Score: "<<Score<<endl; cout<<"HP: "<<HP<<endl; for(y=0;y<20;y++) { for(x=0;x<20;x++) { switch(Map[y][x]) { case '@': { if(GetAsyncKeyState(VK_UP) != 0) { int y2 = (y-1); switch(Map[y2][x]) { case ' ': { Map[y][x] = ' '; y -= 1; Map[y2][x] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; } case '*': { HP +=5; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; Score += 4; } } } if(GetAsyncKeyState(VK_DOWN) != 0) { int y2 = (y+1); switch(Map[y2][x]) { case ' ': { Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; y += 1; Map[y2][x] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; y += 1; Score += 4; Map[y2][x] = '@'; } } } if(GetAsyncKeyState(VK_RIGHT) != 0) { int x2 = (x+1); switch(Map[y][x2]) { case ' ': { Map[y][x] = ' '; x += 1; Map[y][x2] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; x += 1; Map[y][x2] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; x += 1; Score += 4; Map[y][x2] = '@'; } } } if(GetAsyncKeyState(VK_LEFT) != 0) { int x2 = (x-1); switch(Map[y][x2]) { case ' ': { Map[y][x] = ' '; x -= 1; Map[y][x2] = '@'; }break; case '!': { level = 2; } case '%': { HP -= 20; Map[y][x] = ' '; x -= 1; Map[y][x2] = '@'; } case '*': { HP += 5; Map[y][x] = ' '; x-=1; Score += 4; Map[y][x2] = '@'; } } } }break; } } } Sleep(GameSpeed); } while(stopgame == false && level == 2) { system("cls"); cout<<"Felicitari! Ai obtinut Level: "<<level<<", scor"<<endl; system("pause"); }return 0;}PS: "Am realizat acest joc pentru programatorii incepatori si de asemenea ii incurajez sa invete inca din clasele 9-12 librariile <windows.h><ctype.h><ctime.h> chiar si altele ce se fac prin facultate! Succes programatorilor!"Foloseste termenul de biblioteci. Librariile inseamna cu totul altceva. library != librarie, library = biblioteca. Quote Link to comment Share on other sites More sharing options...
Bosketar. Posted December 6, 2014 Report Share Posted December 6, 2014 Daca vrei si putina culoare: (in main adaugam:)system("color 2");merge si "2b" pt background 2=verde Quote Link to comment Share on other sites More sharing options...
Column Posted December 6, 2014 Author Report Share Posted December 6, 2014 "Bosketar." Multumesc pentru rectificare! Quote Link to comment Share on other sites More sharing options...
Eustatiu Posted December 7, 2014 Report Share Posted December 7, 2014 PS: "Am realizat acest joc pentru programatorii incepatori si de asemenea ii incurajez sa invete inca din clasele 9-12 librariile <windows.h><ctype.h><ctime.h> chiar si altele ce se fac prin facultate! Succes programatorilor!"M-ar ajuta mai mult niste linkuri/tutoriale/sfaturi de unde pot sa le invat, daca se poate. Mul?umesc anticipat Am rulat codul si l-am inteles, iar primul gand mi s-a dus la Pacman [..] Quote Link to comment Share on other sites More sharing options...