int main(){ //Declare the characters Hero Player; Monster Ogre; //Set the main characters in game properties Player.SetName("Budi"); Player.SetHealth(1000); Player.SetAttack(30); Player.SetJob("Magician"); Player.SetTown("Furedator"); Ogre.SetName("Ograr"); Ogre.SetHealth(1500); Ogre.SetAttack(15); Ogre.SetClan("Myrtr"); cout << "Nama playernya adalah " << Player.GetName() << endl; cout << "Player memiliki health " << Player.GetHealth() << endl; cout << "Attack player adalah " << Player.GetAttack() << endl; cout << "Job player adalah " << Player.GetJob() << endl; cout << "Kota asal player adalah " << Player.GetTown() << endl; cout << "Nama monsternya adalah " << Ogre.GetName() << endl; cout << "Monsternya memiliki health " << Ogre.GetHealth() << endl; cout << "Attack Monsternya adalah " << Ogre.GetAttack() << endl; cout << "Clan Monsternya dari " << Ogre.GetClan() << endl; return 0; }
int main() { srand(time(NULL)); Background::LoadBackground(); Sound::LoadSounds(); Sprites::LoadSprites(); Font::LoadFont(); window.setFramerateLimit(30); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && shot_counter==0){ break; } window.draw(Background::BeforeGameStartSprite); window.display(); } Hero hero; Enemys enemys; while(window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); } shot_counter++; shot_counter%=10; if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && shot_counter==0) { hero.fire(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) { hero.MoveLeft(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) { hero.MoveRight(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) { hero.MoveUp(); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) { hero.MoveDown(); } Sound::PlayBackgroundMusic(); Background::show(window); hero.turn(window); enemys.turn(window); window.display(); if (hero.GetHealth()<=0) break; } return 0; }