diff options
| -rw-r--r-- | src/assets.c | 21 | ||||
| -rw-r--r-- | src/assets.h | 5 | ||||
| -rw-r--r-- | src/entities/antifaShip.c | 2 | ||||
| -rw-r--r-- | src/entities/guidedMissile.c | 48 | ||||
| -rw-r--r-- | src/entities/guidedMissile.h | 12 | ||||
| -rw-r--r-- | src/game.c | 2 | ||||
| -rw-r--r-- | src/playerCamera.c | 6 | 
7 files changed, 75 insertions, 21 deletions
| diff --git a/src/assets.c b/src/assets.c index fde88af..9671a00 100644 --- a/src/assets.c +++ b/src/assets.c @@ -1,19 +1,20 @@  #include "assets.h"  const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX] = { -	"/home/nathan/Documents/KillaFacsista/assets/icon.png", -	"/home/nathan/Documents/KillaFacsista/assets/icon128.png", -	"/home/nathan/Documents/KillaFacsista/assets/icon64.png" +	"../assets/icon.png", +	"../assets/icon128.png", +	"../assets/icon64.png"  };  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/caporale.obj", -	"/home/nathan/Documents/KillaFacsista/assets/sergente.obj", -	"/home/nathan/Documents/KillaFacsista/assets/maresciallo.obj", -	"/home/nathan/Documents/KillaFacsista/assets/generale.obj", -	"/home/nathan/Documents/KillaFacsista/assets/mussolini.obj" +	"../assets/antifaShip.obj", +	"../assets/soldato.obj", +	"../assets/caporale.obj", +	"../assets/sergente.obj", +	"../assets/maresciallo.obj", +	"../assets/generale.obj", +	"../assets/mussolini.obj", +	"../assets/guidedMissile.obj"  };  void LoadAssets(Assets * assets) { diff --git a/src/assets.h b/src/assets.h index 8721242..63839ee 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 7 +#define MODEL_ASSET_COUNT 8  // Paths to assets.  extern const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX]; @@ -29,7 +29,8 @@ enum {  	SERGENTE_ASSET,  	MARESCIALLO_ASSET,  	GENERALE_ASSET, -	MUSSOLINI_ASSET +	MUSSOLINI_ASSET, +	GUIDED_MISSILE_ASSET  };  typedef struct Assets { diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index 6e8c239..f6a9ec9 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -99,7 +99,7 @@ void controlAntifaShipKeyboardAndMouse(Game * game, Entity * entity) {  		mouseStick.z = -mouseStick.y;  		mouseStick.y = 0.0;  	} -	 +  	entityJoystickControl(entity, mouseStick, data->forwardSpeed);  } diff --git a/src/entities/guidedMissile.c b/src/entities/guidedMissile.c index 744e1cb..53cbaf8 100644 --- a/src/entities/guidedMissile.c +++ b/src/entities/guidedMissile.c @@ -3,10 +3,28 @@  #include "game.h"  void initGuidedMissile(Entity * entity, Game * game) { -	entity->model = &game->assets.models[MARESCIALLO_ASSET]; +	entity->model = &game->assets.models[GUIDED_MISSILE_ASSET];  	entity->collisionModel = entityCreateCollisionModel(*entity->model);  	entity->transformedCollisionModel = entityCreateCollisionModel(*entity->model);  	setEntityRadius(entity); + +	// Allocate data. +	entity->data = KF_MALLOC(sizeof(GuidedMissile)); + +	if (entity->data == NULL) { +		ALLOCATION_ERROR; +		return; +	} + +	GuidedMissile * data = (GuidedMissile*)entity->data; + +	data->flyToPoint = (EntityFlyToPointInfo){ +		.controller.bangbang.speed = 80, +		.controller.bangbang.stopAt = 0.0, +		.controlType = ENTITY_FLY_TO_POINT_BANG_BANG, +		.rotationSpeed = 20.0, +		.applyRotation = true +	};  }  void closeGuidedMissile(Entity * entity) { @@ -19,11 +37,35 @@ void closeGuidedMissile(Entity * entity) {  void updateGuidedMissile(Game * game, Entity * entity) {  	entityUpdateLastValues(entity); -	// hi + +	Entity * player = getEntityFromWorld(game->world, 0); +	GuidedMissile * data = (GuidedMissile*)entity->data; + +	entityFlyToPoint(entity, player->position, &data->flyToPoint); + +	// boom boom time +	if (Vector3Distance(player->position, entity->position) <= GUIDED_MISSILE_BOOM_BOOM_AT) +		guidedMissileGoBoomBoom(game, entity);  	entityCheckTransformedCollisionModel(entity);  }  void drawGuidedMissile(Game * game, Entity * entity) {  	entityDraw(entity); -}
\ No newline at end of file +} + +void guidedMissileGoBoomBoom(Game * game, Entity * entity) { +	Entity * player = getEntityFromWorld(game->world, 0); + +	// Get player distance and get the damage the missile will do. +	float distance = Vector3Distance(player->position, entity->position); +	float damage = distance * GUIDED_MISSILE_DAMAGE; + +	// Hurt this mother fucker. +	player->health -= damage; + +	// Remove its self from the world. I have thought of doing the same for years ): +	entity->health = 0.0; + +	printf("This fucker did %f damage\n", damage); +} diff --git a/src/entities/guidedMissile.h b/src/entities/guidedMissile.h index edf3fce..b184775 100644 --- a/src/entities/guidedMissile.h +++ b/src/entities/guidedMissile.h @@ -1,10 +1,17 @@  #include "gameCommon.h"  #include "entity.h" +// This mother fucker follows the player and goes fucking boom boom!!! +// btw I wrote some of this on 9/11 +  #ifndef GUIDED_MISSILE_H  #define GUIDED_MISSILE_H +#define GUIDED_MISSILE_DAMAGE 2.0 +#define GUIDED_MISSILE_BOOM_BOOM_AT 5.0 +  typedef struct GuidedMissile { +    EntityFlyToPointInfo flyToPoint;  } GuidedMissile;  void initGuidedMissile(Entity * entity, Game * game); @@ -12,4 +19,7 @@ void closeGuidedMissile(Entity * entity);  void updateGuidedMissile(Game * game, Entity * entity);  void drawGuidedMissile(Game * game, Entity * entity); -#endif
\ No newline at end of file +// Boom boom like a poop poop +void guidedMissileGoBoomBoom(Game * game, Entity * entity); + +#endif @@ -35,7 +35,7 @@ void initGame(Game * game) {  	WorldEntry entries[2] = {  		(WorldEntry){ENTITY_ANTIFA, (Vector3){0.0, 0.0, 0.0}, QuaternionIdentity()}, -		(WorldEntry){ENTITY_MARESCIALLO, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()} +		(WorldEntry){ENTITY_GUIDED_MISSILE, (Vector3){0.0, 0.0, 100.0}, QuaternionIdentity()}  	};  	addEntriesToWorld( diff --git a/src/playerCamera.c b/src/playerCamera.c index 096ee36..f759166 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};  } | 
