-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrosshair.cpp
More file actions
31 lines (27 loc) · 1.2 KB
/
Copy pathcrosshair.cpp
File metadata and controls
31 lines (27 loc) · 1.2 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
#include "crosshair.h"
#include "utils.h"
#include <raylib.h>
Crosshair::Crosshair(){
}
void Crosshair::drawCrosshair(){
// Determine if crosshair is going to the left or to the right
if (previousMouseX < GetMouseX()) {
crossHairRotation += 2.0f;
} else if (previousMouseX > GetMouseX()) {
crossHairRotation -= 2.0f;
} else {
crossHairRotation = 0.0f;
}
DrawTexturePro(this->crosshairTexture, {0,0, (float)this->crosshairTexture.width, (float)this->crosshairTexture.height},
{(float)GetMouseX(), (float)GetMouseY(), (float)this->crosshairTexture.width/4, (float)this->crosshairTexture.height/4},
{(float)this->crosshairTexture.width/8, (float)this->crosshairTexture.height/8},
clamp(this->crossHairRotation, -25.0f, 25.0f),
WHITE);
// This is a cool one, so the crosshair png is too big so we're only using 25% of its original size
// So we divide the og size by 4
// But then we need center point of the new rect to rotate it accurately
// So we divide the og size by 8
// So now you ask: Wouldn't it be easier to just shrink the png?
// My response: nuh huh
previousMouseX = GetMouseX(); // We update the previous position
}