Reupload
This commit is contained in:
33
assets/src/Game.cpp
Normal file
33
assets/src/Game.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "Game.hpp"
|
||||
|
||||
Game::Game() : AGame("resources/", "bg.jpg") {
|
||||
|
||||
_engine = DamnCute::Core::getInstance();
|
||||
}
|
||||
|
||||
void Game::run() {
|
||||
|
||||
_engine->createWindow();
|
||||
_alive = _engine->getWindowStatus();
|
||||
while (_alive) {
|
||||
update();
|
||||
if (_alive) {
|
||||
_engine->flushEvent();
|
||||
_engine->flushScene();
|
||||
}
|
||||
}
|
||||
_engine->freeAll();
|
||||
}
|
||||
|
||||
void Game::pause() {}
|
||||
|
||||
bool Game::update() {
|
||||
return (DamnCute::Core::getInstance()->getWindowStatus());
|
||||
}
|
||||
|
||||
void Game::playMusic() {
|
||||
|
||||
_engine->musicPath("resources/music");
|
||||
_engine->getMusic().setLoop(true);
|
||||
_engine->musicPlay(0);
|
||||
}
|
23
assets/src/Game.hpp
Normal file
23
assets/src/Game.hpp
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef GAME_HPP_
|
||||
# define GAME_HPP_
|
||||
|
||||
#include <damncute/Core/Core.hh>
|
||||
#include <damncute/AGame.hh>
|
||||
|
||||
class Game : public DamnCute::AGame {
|
||||
|
||||
private:
|
||||
bool update();
|
||||
void playMusic();
|
||||
bool _alive;
|
||||
DamnCute::Core *_engine;
|
||||
|
||||
public:
|
||||
Game();
|
||||
~Game() = default;
|
||||
virtual void run();
|
||||
virtual void pause();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
8
assets/src/main.cpp
Normal file
8
assets/src/main.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
#include "Game.hpp"
|
||||
|
||||
int main(void) {
|
||||
|
||||
Game g;
|
||||
g.run();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user