Skip to content

Instantly share code, notes, and snippets.

View Devhobby's full-sized avatar

Bartosz Gala Devhobby

View GitHub Profile
@Devhobby
Devhobby / Player.cpp
Created April 8, 2018 19:24
Realizacja przemieszczenia
int Player::move()
{
auto x = get_actX();
auto y = get_actY();
if (get_playerLastMove() == 0) { --x; set_actX(x); }
else if (get_playerLastMove() == 1) { ++y; set_actY(y); }
else if (get_playerLastMove() == 2) { ++x; set_actX(x); }
else if (get_playerLastMove() == 3) { --y; set_actY(y); }
else if (get_playerLastMove() == 4) return 3;
@Devhobby
Devhobby / game.cpp
Created April 8, 2018 19:04
Wypisanie opcji wyjść
//Wyliczenie mozliwych wyjsc z obszaru (z wykluczeniem zamknietych drzwi)
std::cout << std::endl;
std::cout << "nacisnij E zeby odpoczac w pokoju jedna runde; R - zrezygnuj i wyjdz z gry\n" << std::endl;
if (p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_exitCell(0)) std::cout << "nacisnij W zeby isc na polnoc" << std::endl;
if (p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_exitCell(1)) std::cout << "nacisnij D zeby isc na wschod" << std::endl;
if (p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_exitCell(2)) std::cout << "nacisnij S zeby isc na poludie" << std::endl;
if (p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_exitCell(3)) std::cout << "nacisnij A zeby isc na zachod" << std::endl;
if (p_player->get_actX() == p_player->get_endX() && p_player->get_actY() == p_player->get_endY())
std::cout << "\n\a\a****** nacisnij Q zeby skorzystac z klapy w podlodze *****" << std::endl;
@Devhobby
Devhobby / game.cpp
Created April 2, 2018 15:40
Opis aktualnego obszaru gry
void areaTextInformation(Player * p_player, World ** p_p_worldArr)
{
std::cout << "wchodzisz do pomieszczenia przez ";
if (p_player->get_playerLastMove() == 9) std::cout << "klape w podlodze " << std::endl;
if (p_player->get_playerLastMove() == 0) std::cout << "poludniowe drzwi " << std::endl;
if (p_player->get_playerLastMove() == 1) std::cout << "zachodnie drzwi " << std::endl;
if (p_player->get_playerLastMove() == 2) std::cout << "polnocne drzwi " << std::endl;
if (p_player->get_playerLastMove() == 3) std::cout << "wschodnie drzwi " << std::endl;
if (p_player->get_playerLastMove() == 0 && !p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_exitCell(2)) std::
@Devhobby
Devhobby / game.cpp
Last active April 2, 2018 15:36
Pierwsza czesc petli gry
do //pętla wewnętrzna gry - tu dzieje się wszystko
{
system("cls");
//zmiana zdrowia gracza w nowym pokoju
p_player->change_plusPlayerHp(p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_hpCell());
//sprawdzenie czy HP są powyzej zero, jesli nie to koniec gry
if (p_player->get_playerHp() <= 0) return 1;
//zmiana czasu zgodna z wlasciwoscia nowego obszaru
p_player->change_minusPlayerTime(p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_timeCell());
//sprawdzanie czasu, jesli ponizej zera to koniec gry
@Devhobby
Devhobby / game.cpp
Created April 2, 2018 13:22
Menu informacyjne
int gameLoop(Player * p_player, World ** p_p_worldArr)
{
// Informujemy gracza o dokladnym celu misji
system("cls");
std::cout << "\n\n\n\nZaraz wejdziesz do gry!!!" << std::endl;
std::cout << "\nzaczniesz w miejscu oznaczonym jako " << p_p_worldArr[p_player->get_actX()][p_player->get_actY()].get_infoCell() << std::endl;
std::cout << "wyjscie znajduje sie w pokoju oznaczonym jako " << p_p_worldArr[p_player->get_endX()][p_player->get_endY()].get_infoCell() << std::endl;
std::cout << "\nzapamietaj to, bo od teraz podawany bedzie tylko numer pokoju w ktorym aktualnie jestes!" << std::endl;
std::cout << "\n\nWspinasz sie po drabince do pomieszczenia od ktorego zaczniesz gre," << std::endl;
std::cout << "celem jest dotrzec jak najszybciej do pomieszczenia z taka sama klapa w podlodze i wyjscie" << std::endl;
@Devhobby
Devhobby / Player.cpp
Created April 2, 2018 13:19
Zmiana HP i czasu - nowe metody
void Player::change_plusPlayerHp(int tmp)
{
playerHp += tmp; //zmieniamy wartosc zdrowia gracza o podany parametr.
}
void Player::change_minusPlayerTime(int tmp)
{
playerTime -= tmp; //zmniejszamy wartosc czasu do konca gry o podana wartosc
}
@Devhobby
Devhobby / sstream.cpp
Created March 31, 2018 13:31
dodawanie int do string przez sstream
std::string name = "adela";
int number = 22;
std::string endData;
std::stringstream temp;
temp << name;
temp << ' ';
temp << number;
@Devhobby
Devhobby / string.cpp
Created March 31, 2018 13:24
dodawanie int do string - to_string()
std::string name = "adela";
int number = 22;
std::string endData = name;
endData += ' ';
endData += std::to_string(number);
@Devhobby
Devhobby / if_else.cpp
Last active March 29, 2018 23:04
Artykuł o if-else oraz ?:
if (key == 'w' || key == 'W') move = 1;
else if (key == 's' || key == 'S') move = 2;
else if (key == 'a' || key == 'A') move = 3;
else if (key == 'd' || key == 'D') move = 4;
else if (key == 'q' || key == 'Q') move = 0;
else move = 9;
@Devhobby
Devhobby / ?:.cpp
Last active March 29, 2018 23:03
do artykulu ?:
move = (key == 'w' || key == 'W') ? 1
: (key == 's' || key == 'S') ? 2
: (key == 'a' || key == 'A') ? 3
: (key == 'd' || key == 'D') ? 4
: (key == 'q' || key == 'Q') ? 0
: 9;