diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-10 12:20:13 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-09-10 12:20:13 -0600 |
commit | 061e3371e860d498baf5eb85386fd638ab7f90f9 (patch) | |
tree | e7e45636e190517496dbe616cd1d3081e9fe23d5 /src | |
parent | 989621071dc8ce292ca8c985cfed887c88f121ce (diff) |
Reinstalling linux again lol
Diffstat (limited to 'src')
-rw-r--r-- | src/entities/guidedMissile.c | 28 | ||||
-rw-r--r-- | src/entities/guidedMissile.h | 15 | ||||
-rw-r--r-- | src/entities/maresciallo.c | 26 | ||||
-rw-r--r-- | src/entities/maresciallo.h | 4 | ||||
-rw-r--r-- | src/entities/sergente.c | 2 | ||||
-rw-r--r-- | src/entitiesInclude.h | 1 | ||||
-rw-r--r-- | src/entity.c | 3 | ||||
-rw-r--r-- | src/entity.h | 5 | ||||
-rw-r--r-- | src/game.c | 2 | ||||
-rw-r--r-- | src/playerCamera.c | 6 |
10 files changed, 82 insertions, 10 deletions
diff --git a/src/entities/guidedMissile.c b/src/entities/guidedMissile.c new file mode 100644 index 0000000..986760f --- /dev/null +++ b/src/entities/guidedMissile.c @@ -0,0 +1,28 @@ +#include "guidedMissile.h" +#include "assets.h" +#include "game.h" + +void initGuidedMissile(Entity * entity, Game * game) { + entity->model = &game->assets.models[MARESCIALLO_ASSET]; + entity->collisionModel = entityCreateCollisionModel(*entity->model); + entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model); + setEntityRadius(entity); +} + +void closeGuidedMissile(Entity * entity) { + if (entity->data != NULL) + KF_FREE(entity->data); + + entityFreeCollisionModel(entity->collisionModel); + entityFreeCollisionModel(entity->transformedCollisionModel); +} + +void updateGuidedMissile(Game * game, Entity * entity) { + entityUpdateLastValues(entity); + + entityCheckTransformedCollisionModel(entity); +} + +void drawGuidedMissile(Game * game, Entity * entity) { + entityDraw(entity); +}
\ No newline at end of file diff --git a/src/entities/guidedMissile.h b/src/entities/guidedMissile.h new file mode 100644 index 0000000..edf3fce --- /dev/null +++ b/src/entities/guidedMissile.h @@ -0,0 +1,15 @@ +#include "gameCommon.h" +#include "entity.h" + +#ifndef GUIDED_MISSILE_H +#define GUIDED_MISSILE_H + +typedef struct GuidedMissile { +} GuidedMissile; + +void initGuidedMissile(Entity * entity, Game * game); +void closeGuidedMissile(Entity * entity); +void updateGuidedMissile(Game * game, Entity * entity); +void drawGuidedMissile(Game * game, Entity * entity); + +#endif
\ No newline at end of file diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index a5b0628..34d3377 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -2,6 +2,8 @@ #include "assets.h" #include "game.h" #include "PID.h" +#include "bullets.h" +#include <raylib.h> void initMaresciallo(Entity * entity, Game * game) { entity->model = &game->assets.models[MARESCIALLO_ASSET]; @@ -19,6 +21,8 @@ void initMaresciallo(Entity * entity, Game * game) { Maresciallo * data = (Maresciallo*)entity->data; + data->timeSinceLastBulletShot = GetTime(); + PIDConfig flyToPointPID = (PIDConfig){ .kP = 1.1, .kI = 0.0, @@ -88,6 +92,22 @@ void circlePlayerMaresciallo(Game * game, Entity * entity) { entity->rotation = QuaternionSlerp(entity->rotation, rotation, t * MARESCIALLO_ROTATION_SPEED); } +// A gun, like one of those things you find in public schools. +void updateGunMaresciallo(Game * game, Entity * entity) { + double t = GetTime(); + Maresciallo * data = (Maresciallo*)entity->data; + Entity * player = getEntityFromWorld(game->world, 0); + + if (t - data->timeSinceLastBulletShot < MARESCIALLO_COOLDOWN) + return; + + // Create and shoot bullet. + Bullet bullet = createBulletFromEntity(*entity, MARESCIALLO_BULLET_DAMAGE); + BulletHitInfo hit = shootBulletAtEntity(player, bullet); + + data->timeSinceLastBulletShot = t; +} + void updateMaresciallo(Game * game, Entity * entity) { entityUpdateLastValues(entity); @@ -109,6 +129,8 @@ void updateMaresciallo(Game * game, Entity * entity) { void drawMaresciallo(Game * game, Entity * entity) { entityDraw(entity); - Entity * player = getEntityFromWorld(game->world, 0); - DrawLine3D(entity->position, player->position, BLUE); + updateGunMaresciallo(game, entity); + + // Entity * player = getEntityFromWorld(game->world, 0); + // DrawLine3D(entity->position, player->position, BLUE); } diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h index 2e50ffe..7624f8f 100644 --- a/src/entities/maresciallo.h +++ b/src/entities/maresciallo.h @@ -9,8 +9,12 @@ #define MARESCIALLO_ROTATION_SPEED 20.0 #define MARESCIALLO_CIRCLE_PLAYER_SPEED 1.0 +#define MARESCIALLO_COOLDOWN 1.0 +#define MARESCIALLO_BULLET_DAMAGE 0.01 + typedef struct Maresciallo { EntityFlyToPointInfo flyToPoint; + double timeSinceLastBulletShot; } Maresciallo; void initMaresciallo(Entity * entity, Game * game); diff --git a/src/entities/sergente.c b/src/entities/sergente.c index f161622..7c278a4 100644 --- a/src/entities/sergente.c +++ b/src/entities/sergente.c @@ -99,7 +99,7 @@ void updateGunsSergente(Game * game, Entity * entity) { data->shots[i] = shot; } - printf("%f\n", (float)hits / SERGENTE_SHOT_COUNT); + //printf("%f\n", (float)hits / SERGENTE_SHOT_COUNT); data->timeSinceLastShot = t; } diff --git a/src/entitiesInclude.h b/src/entitiesInclude.h index 4c6f5ac..be4713c 100644 --- a/src/entitiesInclude.h +++ b/src/entitiesInclude.h @@ -5,5 +5,6 @@ #include "entities/maresciallo.h" #include "entities/generale.h" #include "entities/mussolini.h" +#include "entities/guidedMissile.h" // Through the magic of this ugly file you can include all entities at once. diff --git a/src/entity.c b/src/entity.c index 52d24f6..fb000a7 100644 --- a/src/entity.c +++ b/src/entity.c @@ -10,7 +10,8 @@ const EntityTypeInfo entityTypeInfo[ENTITY_TYPE_COUNT] = { (EntityTypeInfo){initSergente, closeSergente, updateSergente, drawSergente}, (EntityTypeInfo){initMaresciallo, closeMaresciallo, updateMaresciallo, drawMaresciallo}, (EntityTypeInfo){initGenerale, closeGenerale, updateGenerale, drawGenerale}, - (EntityTypeInfo){initMussolini, closeMussolini, updateMussolini, drawMussolini} + (EntityTypeInfo){initMussolini, closeMussolini, updateMussolini, drawMussolini}, + (EntityTypeInfo){initGuidedMissile, closeGuidedMissile, updateGuidedMissile, drawGuidedMissile} }; EntityVelocity entityVelocityIdentity() { diff --git a/src/entity.h b/src/entity.h index 37b80a5..f67f091 100644 --- a/src/entity.h +++ b/src/entity.h @@ -13,10 +13,11 @@ enum { ENTITY_SERGENTE, ENTITY_MARESCIALLO, ENTITY_GENERALE, - ENTITY_MUSSOLINI + ENTITY_MUSSOLINI, + ENTITY_GUIDED_MISSILE }; -#define ENTITY_TYPE_COUNT 7 +#define ENTITY_TYPE_COUNT 8 typedef int8_t EntityType; typedef int16_t EntityId; // Id in world. @@ -35,7 +35,7 @@ void initGame(Game * game) { WorldEntry entries[2] = { (WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()}, - (WorldEntry){ENTITY_SERGENTE, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()} + (WorldEntry){ENTITY_MARESCIALLO, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()} }; addEntriesToWorld( diff --git a/src/playerCamera.c b/src/playerCamera.c index f759166..096ee36 100644 --- a/src/playerCamera.c +++ b/src/playerCamera.c @@ -23,7 +23,7 @@ void updatePlayerCamera(Camera3D * camera, Game * game) { // Up. camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation); - camera->target = player->position; - camera->position = (Vector3){10.0, 10.0, 10.0}; - camera->up = (Vector3){0.0, 1.0, 0.0}; + // camera->target = player->position; + // camera->position = (Vector3){10.0, 10.0, 10.0}; + // camera->up = (Vector3){0.0, 1.0, 0.0}; } |