-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInGame.cpp
45 lines (34 loc) · 888 Bytes
/
InGame.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
#include "InGame.h"
#include "WorldRenderer.h"
#include "Application.h"
#include <iostream>
InGame::InGame(){
m_worldRenderer = WorldRendererPtr(new WorldRenderer);
m_worldRenderer->getCamera().setView(Application::instance()->getRenderWindow()->getDefaultView());
}
WorldRendererPtr InGame::getRenderer(){
return m_worldRenderer;
}
void InGame::init(){
m_worldRenderer->init();
}
void InGame::unload(){
m_worldRenderer->unload();
}
void InGame::update(){
m_worldRenderer->update(m_frameTime);
}
void InGame::render(sf::RenderTarget* target){
checkInputs();
// render world
m_worldRenderer->render(target);
// render gui
fps++;
if (m_clock.getElapsedTime() >= sf::seconds(1)){
std::cout << fps << " " << m_frameTime.asMilliseconds() << "ms" << std::endl;
fps = 0;
m_clock.restart();
}
m_frameTime = m_frameClock.getElapsedTime();
m_frameClock.restart();
}