From 59b7c312c61a8526859c725d4f9a7367cbc4751d Mon Sep 17 00:00:00 2001
From: nathansmithsmith <thenathansmithsmith@gmail.com>
Date: Mon, 18 Dec 2023 13:56:39 -0700
Subject: Funny funny speed mod thingy

---
 src/entities/antifaShip.c | 13 ++++++++++++-
 src/gameScreen.c          | 17 ++++++++---------
 src/settings.c            |  3 ++-
 src/settings.h            |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

(limited to 'src')

diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c
index 342f0f9..0f64d14 100644
--- a/src/entities/antifaShip.c
+++ b/src/entities/antifaShip.c
@@ -222,8 +222,18 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) {
 	// Get mouse values.
 	Vector2 mouse = GetMousePosition();
 	float speed = GetMouseWheelMove();
+
+	// Speed mod.
+	float speedMod = 1.0;
+
+	if (IsKeyDown(KEY_LEFT_SHIFT))
+		speedMod = 1.0 / game->settings.speedMod;
+	else if (IsKeyDown(KEY_LEFT_CONTROL))
+		speedMod = game->settings.speedMod;
+
+	printf("%f\n", speedMod);
 	
-	data->forwardSpeed += (speed * game->settings.scrollBarSpeed);
+	data->forwardSpeed += (speed * game->settings.scrollBarSpeed * speedMod);
 
 	if (data->forwardSpeed < 0.)
 		data->forwardSpeed = 0.0;
@@ -237,6 +247,7 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) {
 	// Using mouse as a joystick.
 	Vector3 mouseStick = (Vector3){v.y, -v.x, 0.0};
 	mouseStick = Vector3Scale(mouseStick, game->settings.mouseSensitivity);
+	mouseStick = Vector3Scale(mouseStick, speedMod);
 
 	// Swap axis for more movement with mouse.
 	if (IsMouseButtonDown(MOUSE_BUTTON_MIDDLE)) {
diff --git a/src/gameScreen.c b/src/gameScreen.c
index d35a05d..059eea6 100644
--- a/src/gameScreen.c
+++ b/src/gameScreen.c
@@ -91,9 +91,7 @@ void drawCrossHair(float size, float thick, Color color) {
 
 void drawGameScreenInfoText(Game * game, GameScreen * gameScreen) {
 	Entity * player = getEntityFromWorld(game->world, 0);
-
-	Vector3 position = player->position;
-	Vector3 velocity = player->velocity.velocity;
+	AntifaShip * data = (AntifaShip*)player->data;
 
 	// Hello reader. I fucking hate you!
 	size_t bufSize = 255;
@@ -103,12 +101,13 @@ void drawGameScreenInfoText(Game * game, GameScreen * gameScreen) {
 	snprintf(
 		buf,
 		bufSize,
-		"Health %.2f\n\nX %.2f\nY %.2f\nZ %.2f\n\nSpeed %.2f",
+		"Health %.2f\n\nX %.2f\nY %.2f\nZ %.2f\n\nSpeed %.2f/%.2f",
 		player->health,
-		position.x,
-		position.y,
-		position.z,
-		Vector3Length(velocity)
+		player->position.x,
+		player->position.y,
+		player->position.z,
+		data->forwardSpeed,
+		Vector3Length(player->velocity.velocity)
 	);
 
 	// Draw info text.
@@ -240,7 +239,7 @@ void gameScreenHandleLevels(Game * game, GameScreen * gameScreen) {
 		if (GetTime() - gameScreen->timeAtLevelComplete >= GAME_SCREEN_NEXT_LEVEL_DELAY) {
 			gameScreen->levelComplete = false;
 			startLevel(game, &game->levels, gameScreen->lastLevel + 1);
-			getEntityFromWorld(game->world, 0)->health = gameScreen->healthAtLevelEnd;
+			getEntityFromWorld(game->world, 0)->health = Clamp(gameScreen->healthAtLevelEnd * 1.5, 0.0, 1.0);
 		}
 
 		return;
diff --git a/src/settings.c b/src/settings.c
index 889867c..5d1a7fa 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -4,7 +4,8 @@ void initSettings(Settings * settings) {
 	*settings = (Settings){
 		.controlMode = KEYBOARD_AND_MOUSE_CONTROL,
 		.mouseSensitivity = 0.0007,
-		.scrollBarSpeed = 10.0,
+		.speedMod = 10.0,
+		.scrollBarSpeed = 2.0,
 		.lockMouse = true,
 		.gamePadNum = 0,
 		.pitchStick = 1,
diff --git a/src/settings.h b/src/settings.h
index 119f4f4..b5d703d 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -15,6 +15,7 @@ typedef struct Settings {
 
 	// Keyboard and mouse control.
 	float mouseSensitivity;
+	float speedMod;
 	float scrollBarSpeed;
 	bool lockMouse;
 
-- 
cgit v1.2.3