aboutsummaryrefslogtreecommitdiff
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/antifaShip.c24
-rw-r--r--src/entities/antifaShip.h2
-rw-r--r--src/entities/caporale.c19
-rw-r--r--src/entities/caporale.h12
-rw-r--r--src/entities/maresciallo.c19
-rw-r--r--src/entities/maresciallo.h12
-rw-r--r--src/entities/sergente.c19
-rw-r--r--src/entities/sergente.h12
8 files changed, 114 insertions, 5 deletions
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