-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayState.cpp
55 lines (44 loc) · 1.13 KB
/
PlayState.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
51
52
53
54
55
#include "PlayState.h"
PlayState::PlayState(sf::RenderWindow* rw) :
player(rw->getSize().x / 2, rw->getSize().y / 2, 200)
{
//gameObjects = new std::vector<GameObject>;
bossGuyTexture.loadFromFile("resources/sprites/testBaddie_spr_0.png");
playerTexture.loadFromFile("resources/sprites/testPlayer.png");
//player.setCenter(rw->getSize().x / 2, rw->getSize().y / 2);
player.setTexture(playerTexture);
bossGuy.setTexture(bossGuyTexture);
bossGuy.setPosition(rw->getSize().x / 2, rw->getSize().y / 2);
}
void PlayState::Cleanup()
{
}
void PlayState::HandleEvents(sf::RenderWindow* rw)
{
sf::Event event;
while (rw->pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
rw->close();
}
}
void PlayState::Update(sf::RenderWindow* rw, double tickrate)
{
bossGuy.Update(tickrate);
player.Update(tickrate);
}
void PlayState::Render(sf::RenderWindow* rw)
{
// clear the window with black color
rw->clear(sf::Color::Black);
// draw everything here...
// window.draw(...);
rw->draw(bossGuy);
rw->draw(player);
// end the current frame
rw->display();
}
PlayState::~PlayState()
{
}