aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornathansmithsmith <thenathansmithsmith@gmail.com>2023-12-18 13:56:39 -0700
committernathansmithsmith <thenathansmithsmith@gmail.com>2023-12-18 13:56:39 -0700
commit59b7c312c61a8526859c725d4f9a7367cbc4751d (patch)
treec5011d5da404e1926b87e882bfe48b9b60d98c47 /src
parent2016fd3e8a39205843f770df7e80df27f720abad (diff)
Funny funny speed mod thingy
Diffstat (limited to 'src')
-rw-r--r--src/entities/antifaShip.c13
-rw-r--r--src/gameScreen.c17
-rw-r--r--src/settings.c3
-rw-r--r--src/settings.h1
4 files changed, 23 insertions, 11 deletions
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;