-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayState.cpp
More file actions
68 lines (57 loc) · 1.35 KB
/
PlayState.cpp
File metadata and controls
68 lines (57 loc) · 1.35 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include "SDL2/SDL.h"
#include "Magicengine/Game.h"
#include "PlayState.h"
PlayState PlayState::m_PlayState;
void PlayState::Init(Game* game)
{
phy2 = game->getPhysics();
playTexture = NULL;
playTexture = Load::Texture((char *) "assets/test.png", game->GetScreen());
textColor = { 255, 255, 255 };
fonttype = Load::Font((char *) "assets/Font/lazy.ttf", 26);
test = new Object(playTexture, game->GetScreen(), 0,0,50,50);
test2 = new Object(playTexture, game->GetScreen(), 100,100);
timeFont = new Font(timeText.str(), fonttype, textColor, 50, 50, game->GetScreen());
timer = new Timer();
timer->start();
phy2->addObject(test);
phy2->addObject(test2);
printf("PlayState Init Successful\n");
}
void PlayState::Clean()
{
SDL_DestroyTexture(playTexture);
printf("PlayState Clean Successful\n");
}
void PlayState::Pause()
{
printf("PlayState Paused\n");
}
void PlayState::Resume()
{
printf("PlayState Resumed\n");
}
void PlayState::HandleEvents(Game* game)
{
SDL_Event event;
if (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
game->Quit();
break;
}
}
}
void PlayState::Update(Game* game)
{
timeText.str( "" );
timeText << "Seconds since start time " << (timer->getTicks()/1000.f);
timeFont->setText(timeText.str());
}
void PlayState::Draw(Game* game)
{
timeFont->Draw();
test->Draw();
test2->Draw();
}