diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-13 20:57:32 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-13 20:57:32 -0600 |
commit | 9eeb5293fc0d022298fb772338241aa7e8672dac (patch) | |
tree | d6ddbaf8f0398d6c83125a64a8c42e1c71ea48b4 /src | |
parent | f368f2811a3f8ca0a4b9572b300358bd17d8dac1 (diff) |
Half working mussolini
Diffstat (limited to 'src')
-rw-r--r-- | src/assets.c | 4 | ||||
-rw-r--r-- | src/assets.h | 6 | ||||
-rw-r--r-- | src/entities/generale.c | 19 | ||||
-rw-r--r-- | src/entities/generale.h | 12 | ||||
-rw-r--r-- | src/entities/mussolini.c | 34 | ||||
-rw-r--r-- | src/entities/mussolini.h | 12 | ||||
-rw-r--r-- | src/entity.c | 8 | ||||
-rw-r--r-- | src/game.c | 4 |
8 files changed, 94 insertions, 5 deletions
diff --git a/src/assets.c b/src/assets.c index bfc823a..fde88af 100644 --- a/src/assets.c +++ b/src/assets.c @@ -11,7 +11,9 @@ const char modelAssetPaths[MODEL_ASSET_COUNT][ASSET_PATH_MAX] = { "/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" + "/home/nathan/Documents/KillaFacsista/assets/maresciallo.obj", + "/home/nathan/Documents/KillaFacsista/assets/generale.obj", + "/home/nathan/Documents/KillaFacsista/assets/mussolini.obj" }; void LoadAssets(Assets * assets) { diff --git a/src/assets.h b/src/assets.h index 3797c3f..8721242 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 5 +#define MODEL_ASSET_COUNT 7 // Paths to assets. extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX]; @@ -27,7 +27,9 @@ enum { SOLDATO_ASSET, CAPORATE_ASSET, SERGENTE_ASSET, - MARESCIALLO_ASSET + MARESCIALLO_ASSET, + GENERALE_ASSET, + MUSSOLINI_ASSET }; typedef struct Assets { diff --git a/src/entities/generale.c b/src/entities/generale.c new file mode 100644 index 0000000..8e86e3f --- /dev/null +++ b/src/entities/generale.c @@ -0,0 +1,19 @@ +#include "generale.h" +#include "assets.h" +#include "game.h" + +void initGenerale(Entity * entity, Game * game) { + entity->model = &game->assets.models[GENERALE_ASSET]; + entity->velocity.angularVelocity = (AxisAngle){(Vector3){1.0, 1.0, 1.0}, 1.0}; +} + +void closeGenerale(Entity * entity) { +} + +void updateGenerale(Game * game, Entity * entity) { + entityUpdateRotation(entity); +} + +void drawGenerale(Game * game, Entity * entity) { + entityDraw(entity); +} diff --git a/src/entities/generale.h b/src/entities/generale.h new file mode 100644 index 0000000..12b1ccb --- /dev/null +++ b/src/entities/generale.h @@ -0,0 +1,12 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef GENERALE_H +#define GENERALE_H + +void initGenerale(Entity * entity, Game * game); +void closeGenerale(Entity * entity); +void updateGenerale(Game * game, Entity * entity); +void drawGenerale(Game * game, Entity * entity); + +#endif diff --git a/src/entities/mussolini.c b/src/entities/mussolini.c new file mode 100644 index 0000000..2770d2f --- /dev/null +++ b/src/entities/mussolini.c @@ -0,0 +1,34 @@ +#include "mussolini.h" +#include "assets.h" +#include "game.h" + +void initMussolini(Entity * entity, Game * game) { + entity->model = &game->assets.models[MUSSOLINI_ASSET]; +} + +void closeMussolini(Entity * entity) { +} + +void updateMussolini(Game * game, Entity * entity) { + Entity * player = getEntityFromWorld(game->world, 0); + + float pitch = Vector2Angle( + (Vector2){entity->position.y, entity->position.x}, + (Vector2){player->position.y, player->position.x} + ); + + float yaw = Vector2Angle( + (Vector2){entity->position.x, entity->position.z}, + (Vector2){player->position.x, player->position.z} + ); + + entity->rotation = QuaternionFromEuler( + pitch - (PI/2), + -(yaw - (PI/2)), + 0.0 + ); +} + +void drawMussolini(Game * game, Entity * entity) { + entityDraw(entity); +} diff --git a/src/entities/mussolini.h b/src/entities/mussolini.h new file mode 100644 index 0000000..ee595f5 --- /dev/null +++ b/src/entities/mussolini.h @@ -0,0 +1,12 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef MUSSOLINI_H +#define MUSSOLINI_H + +void initMussolini(Entity * entity, Game * game); +void closeMussolini(Entity * entity); +void updateMussolini(Game * game, Entity * entity); +void drawMussolini(Game * game, Entity * entity); + +#endif diff --git a/src/entity.c b/src/entity.c index 956c40f..0d91ac8 100644 --- a/src/entity.c +++ b/src/entity.c @@ -1,9 +1,13 @@ #include "entity.h" + +// Entities. #include "entities/antifaShip.h" #include "entities/soldato.h" #include "entities/caporale.h" #include "entities/sergente.h" #include "entities/maresciallo.h" +#include "entities/generale.h" +#include "entities/mussolini.h" // This fucker is used for creating entities. const EntityTypeInfo entityTypeInfo[ENTITY_TYPE_COUNT] = { @@ -11,7 +15,9 @@ const EntityTypeInfo entityTypeInfo[ENTITY_TYPE_COUNT] = { (EntityTypeInfo){initSoldato, closeSoldato, updateSoldato, drawSoldato}, (EntityTypeInfo){initCaporale, closeCaporale, updateCaporale, drawCaporale}, (EntityTypeInfo){initSergente, closeSergente, updateSergente, drawSergente}, - (EntityTypeInfo){initMaresciallo, closeMaresciallo, updateMaresciallo, drawMaresciallo} + (EntityTypeInfo){initMaresciallo, closeMaresciallo, updateMaresciallo, drawMaresciallo}, + (EntityTypeInfo){initGenerale, closeGenerale, updateGenerale, drawGenerale}, + (EntityTypeInfo){initMussolini, closeMussolini, updateMussolini, drawMussolini} }; EntityVelocity entityVelocityIdentity() { @@ -29,7 +29,9 @@ void initGame(Game * game) { (WorldEntry){ENTITY_SOLDATO, (Vector3){20.0, 20.0, 20.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()} + (WorldEntry){ENTITY_MARESCIALLO, (Vector3){50.0, 50.0, 50.0}, QuaternionIdentity()}, + (WorldEntry){ENTITY_GENERALE, (Vector3){60.0, 60.0, 60.0}, QuaternionIdentity()}, + (WorldEntry){ENTITY_MUSSOLINI, (Vector3){0.0, 0.0, 150.0}, QuaternionIdentity()} }; addEntriesToWorld( |