summary refs log tree commit diff
path: root/src/GameTick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GameTick.cpp')
-rw-r--r--src/GameTick.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 2932d8c..6536547 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -22,6 +22,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Black Shades.  If not, see <https://www.gnu.org/licenses/>.
 
+#include <GLFW/glfw3.h>
+
 #include "Game.h"
 
 extern float multiplier;
@@ -122,18 +124,19 @@ void Game::updateSong()
 	alSourcePlay(gSourceID[whichsong]);
 }
 
-void Game::handleMenu(unsigned char* theKeyMap)
+void Game::handleMenu()
 {
-	if (IsKeyDown(theKeyMap, MAC_SPACE_KEY))
+	if (IsKeyDown(GLFW_KEY_SPACE))
 		mainmenu = 0;
 
 	GetMouse(&mouseloc);
 	float mousex = (float) mouseloc.h * 640 / screenwidth;
 	float mousey = 480 - (float) mouseloc.v * 480 / screenheight;
 
+	int button = Button();
 	oldmouseoverbutton = mouseoverbutton;
 	mouseoverbutton = 0;
-	if (mousex > 120 && mousex < 560 && Button() && !oldbutton) {
+	if (mousex > 120 && mousex < 560 && button && !oldbutton) {
 		if (mousey > 235 && mousey < 305)
 			mouseoverbutton = 1;
 		else if (mousey > 112 && mousey < 182)
@@ -141,7 +144,7 @@ void Game::handleMenu(unsigned char* theKeyMap)
 	} else if (!mainmenuness) {
 		mouseoverbutton = 1;
 	}
-	oldbutton = Button();
+	oldbutton = button;
 
 	switch (mouseoverbutton) {
 	case 1:
@@ -168,7 +171,7 @@ void Game::handleMenu(unsigned char* theKeyMap)
 		} else {
 			flashamount = flashr = 1;
 			flashg = flashb = 0;
-			gQuit = true;
+			glfwSetWindowShouldClose(glfwGetCurrentContext(), true);
 		}
 
 		alSourcePlay(gSourceID[losesound]);
@@ -177,9 +180,9 @@ void Game::handleMenu(unsigned char* theKeyMap)
 	}
 }
 
-void Game::handleToggles(unsigned char* theKeyMap)
+void Game::handleToggles()
 {
-	if (!IsKeyDown(theKeyMap, psychickey)) {
+	if (!IsKeyDown(psychickey)) {
 		oldvisionkey = 0;
 	} else if (!oldvisionkey) {
 		oldvisionkey = 1;
@@ -220,7 +223,7 @@ void Game::handleToggles(unsigned char* theKeyMap)
 		}
 	}
 
-	if (!IsKeyDown(theKeyMap, MAC_TAB_KEY)) {
+	if (!IsKeyDown(GLFW_KEY_TAB)) {
 		tabkeydown = 0;
 	} else if (!tabkeydown && debug) {
 		thirdperson++;
@@ -229,13 +232,13 @@ void Game::handleToggles(unsigned char* theKeyMap)
 		tabkeydown = 1;
 	}
 
-	if (!IsKeyDown(theKeyMap, aimkey)) {
+	if (!IsKeyDown(aimkey)) {
 		aimtoggle = 0;
 	} else if (!aimtoggle) {
 		person[0].aiming ^= aimtoggle = 1;
 	}
 
-	if (!IsKeyDown(theKeyMap, MAC_R_KEY)) {
+	if (!IsKeyDown(GLFW_KEY_R)) {
 		reloadtoggle = 0;
 	} else if (!reloadtoggle) {
 		if (person[0].reloads[person[0].whichgun] > 0
@@ -244,7 +247,7 @@ void Game::handleToggles(unsigned char* theKeyMap)
 		reloadtoggle = 1;
 	}
 
-	if (!IsKeyDown(theKeyMap, psychicaimkey)) {
+	if (!IsKeyDown(psychicaimkey)) {
 		slomokeydown = 0;
 	} else if (!slomokeydown && !slomo) {
 		flashamount = 0.5;
@@ -407,10 +410,8 @@ XYZ Game::aimBot(int j)
 
 void Game::Tick()
 {
-	unsigned char theKeyMap[16];
-	GetKeys((unsigned long*) theKeyMap);
 	if (mainmenu) {
-		handleMenu(theKeyMap);
+		handleMenu();
 		return;
 	}
 
@@ -471,7 +472,7 @@ void Game::Tick()
 	flatfacing.y = 0;
 	Normalise(&flatfacing);
 
-	handleToggles(theKeyMap);
+	handleToggles();
 	mouseLook();
 
 	//Check collision with buildings
@@ -690,7 +691,7 @@ void Game::Tick()
 
 	}
 
-	if (IsKeyDown(theKeyMap, MAC_SPACE_KEY)
+	if (IsKeyDown(GLFW_KEY_SPACE)
 	    && person[0].playerrotation == person[0].playerlowrotation
 	    && person[0].targetanimation == joganim
 	    && person[0].currentanimation == joganim
@@ -2138,7 +2139,7 @@ void Game::Tick()
 
 			XYZ end {start + aim * 1000};
 			if (debug && j == 0
-			    && IsKeyDown(theKeyMap, MAC_G_KEY)) {
+			    && IsKeyDown(GLFW_KEY_G)) {
 				sprites.MakeSprite(grenadesprite, 1, 1, 1, 1,
 					start, aim * 200, 1.01);
 				continue;