Skip to content

Commit

Permalink
Splashscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
mel-mouk committed Jun 24, 2021
1 parent 158bf65 commit 3b948fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/states/splashscreen-state.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#include "splashscreen-state.h"

void SplashscreenState::init() { }
void SplashscreenState::init() {
if (!_texture.loadFromFile("../assets/splashscreen.png")) {
std::cout << "Error while loading Splashscreen assets " << std::endl;
return;
}
_sprite.setTexture(_texture);
}

void SplashscreenState::handleInput(sf::Event *event) { }
void SplashscreenState::handleInput(sf::Event *event) {
if (event->type == sf::Event::KeyPressed || event->type == sf::Event::MouseButtonPressed) {
Pang::setState(Pang::Menu);
}
}

void SplashscreenState::update(float timeElapsed) { }

void SplashscreenState::draw(sf::RenderWindow *window) { }
void SplashscreenState::draw(sf::RenderWindow *window) {
window->draw(_sprite);
}
6 changes: 6 additions & 0 deletions src/states/splashscreen-state.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#ifndef PANG_SPLASHSCREEN_STATE_H
#define PANG_SPLASHSCREEN_STATE_H

#include "../pang.h"
#include "game-state.h"
#include <iostream>

class SplashscreenState : public GameState {
public:
void init() override;
void handleInput(sf::Event *event) override;
void update(float timeElapsed) override;
void draw(sf::RenderWindow *window) override;

private:
sf::Texture _texture;
sf::Sprite _sprite;
};

#endif //PANG_SPLASHSCREEN_STATE_H

0 comments on commit 3b948fe

Please sign in to comment.