-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCCombatText.cpp
More file actions
executable file
·37 lines (29 loc) · 1012 Bytes
/
CCombatText.cpp
File metadata and controls
executable file
·37 lines (29 loc) · 1012 Bytes
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
//
// CCombatText.cpp
// Fifth
//
// Created by Didrik Munther on 02/06/15.
// Copyright (c) 2015 Didrik Munther. All rights reserved.
//
#include "CCombatText.h"
#include "NSurface.h"
#include "CText.h"
CCombatText::CCombatText(int x, int y, Color color, int size, std::string text, std::string fontKey) : CGuiText(x, y, text, fontKey) {
_livingTime = 2;
int variator = 100;
int randomPosX = rand() % variator - variator / 2;
int randomPosY = rand() % variator - variator / 2;
_x += randomPosX;
_y += randomPosY;
_textObj = new CText(text, size, fontKey, color);
}
void CCombatText::onLoop() {
if(SDL_GetTicks() > _creationTime + _livingTime * 1000)
_toRemove = true;
_y--;
_x += floor(cos(_y * 25) * 2); // Use _y as an incrementor here
}
void CCombatText::onRender(CWindow* window, CCamera* camera, RenderFlags renderFlags) {
if(renderFlags & RenderFlags::RENDER_COMBAT_TEXT)
_textObj->onRender(_x, _y, window, camera);
}