-
Notifications
You must be signed in to change notification settings - Fork 0
/
StartMenuState.cpp
50 lines (40 loc) · 1.21 KB
/
StartMenuState.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "StartMenuState.h"
#include "AcsGE/ECS/EntityManager.h"
#include "AcsGE/ECS/Components/SpriteComponent.h" //include Rectangle.h
#include "AcsGE/GameStateManager.h"
#include "AcsGE/Util/Misc.h"
#include "AcsGE/Renderer.h"
#include "AcsGE/EventManager.h"
#include <algorithm>
#include <SDL2/SDL.h>
#include <iostream>
namespace {
using AcsGameEngine::ECS::EntityManager;
using AcsGameEngine::ECS::SpriteComponent;
using AcsGameEngine::Util::Shapes::Rectangle;
}
void StartMenuState::init()
{
AcsGameEngine::Util::Misc::imageToSprites(*getAssetManager(), m_image, m_coords, m_sprites);
const int center_x = getWindow()->getWidth() / 2 - m_sprites["start_btn"]->getSource().w / 2;
const int center_y = 50;
m_sprites["start_btn"]->setDestinationXY(center_x, center_y);
getEventManager()->onMouseMove([](int x, int y)
{
std::cout << "MOUSE X: " << x << " MOUSE Y: " << y << '\n';
});
}
void StartMenuState::handleEvents()
{
}
void StartMenuState::update(std::chrono::milliseconds deltaTime)
{
}
void StartMenuState::render()
{
getRenderer()->drawSprite(*m_sprites["start_btn"]);
}
std::string StartMenuState::getName() const noexcept
{
return "StartMenuState";
}