2018-06-14 18:24:07 +02:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: Crosshair.cpp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* Created: 14/06/2018 18:10:10
|
|
|
|
*
|
|
|
|
* Author: Quentin Bazin, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
2018-06-30 17:30:47 +02:00
|
|
|
#include "Config.hpp"
|
2018-06-14 18:24:07 +02:00
|
|
|
#include "Crosshair.hpp"
|
|
|
|
|
|
|
|
Crosshair::Crosshair() {
|
2018-06-30 17:30:47 +02:00
|
|
|
float xFactor = SCREEN_WIDTH * SCREEN_HEIGHT / 100;
|
|
|
|
float yFactor = SCREEN_HEIGHT * SCREEN_WIDTH / 100;
|
|
|
|
|
2018-06-30 20:09:01 +02:00
|
|
|
m_hShape.setSize(0.002 * xFactor, 0.0002 * yFactor);
|
|
|
|
m_vShape1.setSize(0.0002 * xFactor, 0.001 * yFactor - m_hShape.height() / 2);
|
|
|
|
m_vShape2.setSize(0.0002 * xFactor, 0.001 * yFactor - m_hShape.height() / 2);
|
2018-06-30 17:30:47 +02:00
|
|
|
|
2018-12-29 02:23:23 +01:00
|
|
|
m_hShape.setColor(gk::Color{200, 200, 200, 180});
|
|
|
|
m_vShape1.setColor(gk::Color{200, 200, 200, 180});
|
|
|
|
m_vShape2.setColor(gk::Color{200, 200, 200, 180});
|
2018-06-30 17:30:47 +02:00
|
|
|
|
|
|
|
m_hShape.setPosition(SCREEN_WIDTH / 2 - m_hShape.width() / 2, SCREEN_HEIGHT / 2 - m_hShape.height() / 2, 0);
|
|
|
|
m_vShape1.setPosition(SCREEN_WIDTH / 2 - m_vShape1.width() / 2, SCREEN_HEIGHT / 2 - m_hShape.height() / 2 - m_vShape1.height(), 0);
|
|
|
|
m_vShape2.setPosition(SCREEN_WIDTH / 2 - m_vShape2.width() / 2, SCREEN_HEIGHT / 2 + m_hShape.height() / 2, 0);
|
2018-06-14 18:24:07 +02:00
|
|
|
}
|
|
|
|
|
2018-12-29 02:23:23 +01:00
|
|
|
void Crosshair::draw(gk::RenderTarget &target, gk::RenderStates states) const {
|
2018-06-30 17:30:47 +02:00
|
|
|
target.draw(m_hShape, states);
|
|
|
|
target.draw(m_vShape1, states);
|
|
|
|
target.draw(m_vShape2, states);
|
2018-06-14 18:24:07 +02:00
|
|
|
}
|
|
|
|
|