-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathNMouse.cpp
More file actions
executable file
·45 lines (36 loc) · 876 Bytes
/
NMouse.cpp
File metadata and controls
executable file
·45 lines (36 loc) · 876 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
38
39
40
41
42
43
44
45
//
// NMouse.cpp
// Third
//
// Created by Didrik Munther on 16/04/15.
// Copyright (c) 2015 Didrik Munther. All rights reserved.
//
#include <SDL2/SDL.h>
#include "NMouse.h"
#include "CCamera.h"
int NMouse::absoluteMouseX() {
int x, y;
SDL_GetMouseState(&x, &y);
return x;
}
int NMouse::absoluteMouseY() {
int x, y;
SDL_GetMouseState(&x, &y);
return y;
}
int NMouse::relativeMouseX(CCamera* camera) {
int x, y;
SDL_GetMouseState(&x, &y);
return x + camera->offsetX();
}
int NMouse::relativeMouseY(CCamera* camera) {
int x, y;
SDL_GetMouseState(&x, &y);
return y + camera->offsetY();
}
bool NMouse::leftMouseButtonPressed() {
return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT);
}
bool NMouse::rightMouseButtonPressed() {
return SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT);
}