diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-12 02:33:30 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-12 02:33:30 -0600 |
commit | f368f2811a3f8ca0a4b9572b300358bd17d8dac1 (patch) | |
tree | b93bda2b6c50c5ce9cb9354be4c24bb0c7123fbf /src | |
parent | 23be929353d4583edbd8621cd755f8a636c3fd90 (diff) |
Maresciallo added
Diffstat (limited to 'src')
-rw-r--r-- | src/assets.c | 5 | ||||
-rw-r--r-- | src/assets.h | 7 | ||||
-rw-r--r-- | src/entities/antifaShip.c | 24 | ||||
-rw-r--r-- | src/entities/antifaShip.h | 2 | ||||
-rw-r--r-- | src/entities/caporale.c | 19 | ||||
-rw-r--r-- | src/entities/caporale.h | 12 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 19 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 12 | ||||
-rw-r--r-- | src/entities/sergente.c | 19 | ||||
-rw-r--r-- | src/entities/sergente.h | 12 | ||||
-rw-r--r-- | src/entity.c | 8 | ||||
-rw-r--r-- | src/game.c | 6 | ||||
-rw-r--r-- | src/playerCamera.c | 3 | ||||
-rw-r--r-- | src/settings.c | 8 | ||||
-rw-r--r-- | src/settings.h | 14 |
15 files changed, 155 insertions, 15 deletions
diff --git a/src/assets.c b/src/assets.c index c8fe3be..bfc823a 100644 --- a/src/assets.c +++ b/src/assets.c @@ -8,7 +8,10 @@ const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX] = { const char modelAssetPaths[MODEL_ASSET_COUNT][ASSET_PATH_MAX] = { "/home/nathan/Documents/KillaFacsista/assets/antifaShip.obj", - "/home/nathan/Documents/KillaFacsista/assets/soldato.obj" + "/home/nathan/Documents/KillaFacsista/assets/soldato.obj", + "/home/nathan/Documents/KillaFacsista/assets/caporale.obj", + "/home/nathan/Documents/KillaFacsista/assets/sergente.obj", + "/home/nathan/Documents/KillaFacsista/assets/maresciallo.obj" }; void LoadAssets(Assets * assets) { diff --git a/src/assets.h b/src/assets.h index 658367a..3797c3f 100644 --- a/src/assets.h +++ b/src/assets.h @@ -6,7 +6,7 @@ #define ASSET_PATH_MAX 255 #define TEXTURE_ASSET_COUNT 3 -#define MODEL_ASSET_COUNT 2 +#define MODEL_ASSET_COUNT 5 // Paths to assets. extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX]; @@ -24,7 +24,10 @@ enum { // Model asset ids. enum { ANTIFA_SHIP_ASSET, - SOLDATO_ASSET + SOLDATO_ASSET, + CAPORATE_ASSET, + SERGENTE_ASSET, + MARESCIALLO_ASSET }; typedef struct Assets { diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index f102f6c..c2e292a 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -1,5 +1,6 @@ #include "antifaShip.h" #include "game.h" +#include "settings.h" // TODO: Get rid of some magic numbers. @@ -33,14 +34,25 @@ void closeAntifaShip(Entity * entity) { } void controlAntifaShipJoystick(Game * game, Entity * entity) { + Settings settings = game->settings; + int gamePadNum = settings.gamePadNum; + + // Get joystick values. + float pitchStick = GetGamepadAxisMovement(gamePadNum, settings.pitchStick); + float yawStick = GetGamepadAxisMovement(gamePadNum, settings.yawStick); + float rollStick = GetGamepadAxisMovement(gamePadNum, settings.rollStick); + float speedStick = GetGamepadAxisMovement(gamePadNum, settings.speedStick); + Vector3 stick = (Vector3){ - GetGamepadAxisMovement(0, 1), - -GetGamepadAxisMovement(0, 0), - GetGamepadAxisMovement(0, 2) * 0.25 + pitchStick, + -yawStick, + rollStick }; - stick = Vector3Scale(stick, 0.5); - entityJoystickControl(entity, stick, fabs(GetGamepadAxisMovement(0, 3) * 300.0)); + stick = Vector3Scale(stick, settings.joystickSensitivity); + float speed = fabs(speedStick * ANTIFA_SHIP_MAX_SPEED); + + entityJoystickControl(entity, stick, speed); } void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) { @@ -54,6 +66,8 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) { if (data->forwardSpeed < 0.0) data->forwardSpeed = 0.0; + else if (data->forwardSpeed > ANTIFA_SHIP_MAX_SPEED) + data->forwardSpeed = ANTIFA_SHIP_MAX_SPEED; Vector2 v = Vector2Subtract(mouse, data->lastMouse); data->lastMouse = mouse; diff --git a/src/entities/antifaShip.h b/src/entities/antifaShip.h index 61d843c..06ef094 100644 --- a/src/entities/antifaShip.h +++ b/src/entities/antifaShip.h @@ -4,6 +4,8 @@ #ifndef ANTIFA_SHIP_H #define ANTIFA_SHIP_H +#define ANTIFA_SHIP_MAX_SPEED 200.0 + typedef struct AntifaShip { Vector2 lastMouse; float forwardSpeed; diff --git a/src/entities/caporale.c b/src/entities/caporale.c new file mode 100644 index 0000000..bf95235 --- /dev/null +++ b/src/entities/caporale.c @@ -0,0 +1,19 @@ +#include "caporale.h" +#include "assets.h" +#include "game.h" + +void initCaporale(Entity * entity, Game * game) { + entity->model = &game->assets.models[CAPORATE_ASSET]; + entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0}; +} + +void closeCaporale(Entity * entity) { +} + +void updateCaporale(Game * game, Entity * entity) { + entityUpdateRotation(entity); +} + +void drawCaporale(Game * game, Entity * entity) { + entityDraw(entity); +} diff --git a/src/entities/caporale.h b/src/entities/caporale.h new file mode 100644 index 0000000..13f86d1 --- /dev/null +++ b/src/entities/caporale.h @@ -0,0 +1,12 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef CAPORALE_H +#define CAPORALE_H + +void initCaporale(Entity * entity, Game * game); +void closeCaporale(Entity * entity); +void updateCaporale(Game * game, Entity * entity); +void drawCaporale(Game * game, Entity * entity); + +#endif diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c new file mode 100644 index 0000000..568d056 --- /dev/null +++ b/src/entities/maresciallo.c @@ -0,0 +1,19 @@ +#include "maresciallo.h" +#include "assets.h" +#include "game.h" + +void initMaresciallo(Entity * entity, Game * game) { + entity->model = &game->assets.models[MARESCIALLO_ASSET]; + entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0}; +} + +void closeMaresciallo(Entity * entity) { +} + +void updateMaresciallo(Game * game, Entity * entity) { + entityUpdateRotation(entity); +} + +void drawMaresciallo(Game * game, Entity * entity) { + entityDraw(entity); +} diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h new file mode 100644 index 0000000..51714df --- /dev/null +++ b/src/entities/maresciallo.h @@ -0,0 +1,12 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef MARESCIALLO_H +#define MARESCIALLO_H + +void initMaresciallo(Entity * entity, Game * game); +void closeMaresciallo(Entity * entity); +void updateMaresciallo(Game * game, Entity * entity); +void drawMaresciallo(Game * game, Entity * entity); + +#endif diff --git a/src/entities/sergente.c b/src/entities/sergente.c new file mode 100644 index 0000000..4a821dc --- /dev/null +++ b/src/entities/sergente.c @@ -0,0 +1,19 @@ +#include "sergente.h" +#include "assets.h" +#include "game.h" + +void initSergente(Entity * entity, Game * game) { + entity->model = &game->assets.models[SERGENTE_ASSET]; + entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0}; +} + +void closeSergente(Entity * entity) { +} + +void updateSergente(Game * game, Entity * entity) { + entityUpdateRotation(entity); +} + +void drawSergente(Game * game, Entity * entity) { + entityDraw(entity); +} diff --git a/src/entities/sergente.h b/src/entities/sergente.h new file mode 100644 index 0000000..15d4c0d --- /dev/null +++ b/src/entities/sergente.h @@ -0,0 +1,12 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef SERGENTE_H +#define SERGENTE_H + +void initSergente(Entity * entity, Game * game); +void closeSergente(Entity * entity); +void updateSergente(Game * game, Entity * entity); +void drawSergente(Game * game, Entity * entity); + +#endif diff --git a/src/entity.c b/src/entity.c index f4066b5..956c40f 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1,11 +1,17 @@ #include "entity.h" #include "entities/antifaShip.h" #include "entities/soldato.h" +#include "entities/caporale.h" +#include "entities/sergente.h" +#include "entities/maresciallo.h" // This fucker is used for creating entities. const EntityTypeInfo entityTypeInfo[ENTITY_TYPE_COUNT] = { (EntityTypeInfo){initAntifaShip, closeAntifaShip, updateAntifaShip, drawAntifaShip}, - (EntityTypeInfo){initSoldato, closeSoldato, updateSoldato, drawSoldato} + (EntityTypeInfo){initSoldato, closeSoldato, updateSoldato, drawSoldato}, + (EntityTypeInfo){initCaporale, closeCaporale, updateCaporale, drawCaporale}, + (EntityTypeInfo){initSergente, closeSergente, updateSergente, drawSergente}, + (EntityTypeInfo){initMaresciallo, closeMaresciallo, updateMaresciallo, drawMaresciallo} }; EntityVelocity entityVelocityIdentity() { @@ -26,10 +26,10 @@ void initGame(Game * game) { // Debug. WorldEntry entries[] = { (WorldEntry){ENTITY_ANTIFA, Vector3Zero(), QuaternionIdentity()}, - (WorldEntry){ENTITY_SOLDATO, (Vector3){10.0, 10.0, 10.0}, QuaternionIdentity()}, (WorldEntry){ENTITY_SOLDATO, (Vector3){20.0, 20.0, 20.0}, QuaternionIdentity()}, - (WorldEntry){ENTITY_SOLDATO, (Vector3){30.0, 30.0, 30.0}, QuaternionIdentity()}, - (WorldEntry){ENTITY_SOLDATO, (Vector3){40.0, 40.0, 40.0}, QuaternionIdentity()} + (WorldEntry){ENTITY_CAPORALE, (Vector3){30.0, 30.0, 30.0}, QuaternionIdentity()}, + (WorldEntry){ENTITY_SERGENTE, (Vector3){40.0, 40.0, 40.0}, QuaternionIdentity()}, + (WorldEntry){ENTITY_MARESCIALLO, (Vector3){50.0, 50.0, 50.0}, QuaternionIdentity()} }; addEntriesToWorld( diff --git a/src/playerCamera.c b/src/playerCamera.c index e7db154..fd7ffac 100644 --- a/src/playerCamera.c +++ b/src/playerCamera.c @@ -1,5 +1,6 @@ #include "playerCamera.h" #include "game.h" +#include "world.h" void initPlayerCamera(Camera3D * camera) { *camera = (Camera3D){ @@ -9,7 +10,7 @@ void initPlayerCamera(Camera3D * camera) { } void updatePlayerCamera(Camera3D * camera, Game * game) { - Entity * player = &game->world.entities[0]; + Entity * player = getEntityFromWorld(game->world, 0); camera->target = player->position; diff --git a/src/settings.c b/src/settings.c index d46bc86..d58b222 100644 --- a/src/settings.c +++ b/src/settings.c @@ -2,9 +2,15 @@ void initSettings(Settings * settings) { *settings = (Settings){ + .controlMode = KEYBOARD_AND_MOUSE_CONTROL, .mouseSensitivity = 0.05, .scrollBarSpeed = 10.0, - .controlMode = KEYBOARD_AND_MOUSE_CONTROL, + .gamePadNum = 0, + .pitchStick = 1, + .yawStick = 0, + .rollStick = 2, + .speedStick = 3, + .joystickSensitivity = 1.0, .fps = 60, .drawFps = true }; diff --git a/src/settings.h b/src/settings.h index 15cdcb7..0e648bb 100644 --- a/src/settings.h +++ b/src/settings.h @@ -10,10 +10,22 @@ typedef enum ControlMode { } ControlMode; typedef struct Settings { + // Player control stuff. + ControlMode controlMode; + + // Keyboard and mouse control. float mouseSensitivity; float scrollBarSpeed; - ControlMode controlMode; + // Joystick control. + int gamePadNum; + int pitchStick; + int yawStick; + int rollStick; + int speedStick; + float joystickSensitivity; + + // Fps shit. int fps; bool drawFps; } Settings; |