-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cursor.cpp
41 lines (31 loc) · 959 Bytes
/
Cursor.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
#ifndef SFMLSET_CURSOR_CPP
#define SFMLSET_CURSOR_CPP
#include "Cursor.h"
Cursor::Cursor(){
cursor.setSize(sf::Vector2f(10.f, 50.f));
cursor.setFillColor(sf::Color::Green);
// cursor.setPosition(100.f, 280.f);
x = 300;
time = clock.getElapsedTime();
}
void Cursor::SetSize(float size){
cursor.setSize({10.f, size});
}
void Cursor::update(sf::Vector2f position){
cursor.setPosition(position);
if(clock.getElapsedTime().asMilliseconds() > blink){
cursor.setFillColor(sf::Color::White);
}
if(clock.getElapsedTime().asMilliseconds() > (blink * 2)){
// cout << clock.getElapsedTime().asMilliseconds() << " " << endl;
clock.restart();
cursor.setFillColor(sf::Color::Green);
}
}
void Cursor::draw(sf::RenderTarget& window, sf::RenderStates states) const{
window.draw(cursor,states);
}
void Cursor::SetPosition(sf::Vector2f position){
cursor.setPosition(position);
}
#endif