diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/assets.c | 22 | ||||
| -rw-r--r-- | src/entities/generale.c | 11 | ||||
| -rw-r--r-- | src/entities/maresciallo.c | 4 | ||||
| -rw-r--r-- | src/entities/maresciallo.h | 2 | ||||
| -rw-r--r-- | src/gameScreen.c | 7 | ||||
| -rw-r--r-- | src/playerCamera.c | 6 | ||||
| -rw-r--r-- | src/settings.c | 1 | ||||
| -rw-r--r-- | src/settings.h | 1 | ||||
| -rw-r--r-- | src/world.c | 57 | ||||
| -rw-r--r-- | src/world.h | 2 | 
10 files changed, 85 insertions, 28 deletions
| diff --git a/src/assets.c b/src/assets.c index 9671a00..94f2aa8 100644 --- a/src/assets.c +++ b/src/assets.c @@ -1,20 +1,20 @@  #include "assets.h"  const char textureAssetPaths[TEXTURE_ASSET_COUNT][ASSET_PATH_MAX] = { -	"../assets/icon.png", -	"../assets/icon128.png", -	"../assets/icon64.png" +	"/home/nathan/Documents/KillaFacsista/assets/icon.png", +	"/home/nathan/Documents/KillaFacsista/assets/icon128.png", +	"/home/nathan/Documents/KillaFacsista/assets/icon64.png"  };  const char modelAssetPaths[MODEL_ASSET_COUNT][ASSET_PATH_MAX] = { -	"../assets/antifaShip.obj", -	"../assets/soldato.obj", -	"../assets/caporale.obj", -	"../assets/sergente.obj", -	"../assets/maresciallo.obj", -	"../assets/generale.obj", -	"../assets/mussolini.obj", -	"../assets/guidedMissile.obj" +	"/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", +	"/home/nathan/Documents/KillaFacsista/assets/guidedMissile.obj"  };  void LoadAssets(Assets * assets) { diff --git a/src/entities/generale.c b/src/entities/generale.c index 4868824..bc7c0f0 100644 --- a/src/entities/generale.c +++ b/src/entities/generale.c @@ -43,6 +43,15 @@ void closeGenerale(Entity * entity) {  	entityFreeCollisionModel(entity->transformedCollisionModel);  } +void updateGeneraleLaser(Game * game, Entity * entity) { +	Entity * player = getEntityFromWorld(game->world, 0); +	Generale * data = (Generale*)entity->data; + +	Vector3 direction = Vector3Subtract(player->position, entity->position); + +	DrawLine3D(entity->position, Vector3Add(entity->position, direction), RED); +} +  void updateGenerale(Game * game, Entity * entity) {  	entityUpdateLastValues(entity); @@ -70,6 +79,8 @@ void updateGenerale(Game * game, Entity * entity) {  void drawGenerale(Game * game, Entity * entity) {  	entityDraw(entity); +	updateGeneraleLaser(game, entity); +  	/*  	Generale * data = (Generale*)entity->data; diff --git a/src/entities/maresciallo.c b/src/entities/maresciallo.c index 826a7d4..98fc19f 100644 --- a/src/entities/maresciallo.c +++ b/src/entities/maresciallo.c @@ -115,7 +115,7 @@ void updateGunMaresciallo(Game * game, Entity * entity) {  	Bullet bullet = createBulletFromDirection(*entity, direction, MARESCIALLO_BULLET_DAMAGE);  	BulletHitInfo hit = shootBulletAtEntity(player, bullet); -	printf("This fucker hithit ajskdlfjkl %d\n", hit.hit); +	//printf("This fucker hithit ajskdlfjkl %d\n", hit.hit);  	data->timeSinceLastBulletShot = t;  } @@ -146,12 +146,12 @@ void updateMaresciallo(Game * game, Entity * entity) {  	// Fly away if to close to player.  	if (dis < MARESCIALLO_CIRCLE_AT_DIS - 1 || dis >= MARESCIALLO_COME_BACK_AT_DIS) {  		flyToPointMaresciallo(game, entity); -		updateMissilesMaresciallo(game, entity);  	} else {  		circlePlayerMaresciallo(game, entity);  	}  	updateGunMaresciallo(game, entity); +	updateMissilesMaresciallo(game, entity);  	entityCheckTransformedCollisionModel(entity);  } diff --git a/src/entities/maresciallo.h b/src/entities/maresciallo.h index d1d17af..6413fdb 100644 --- a/src/entities/maresciallo.h +++ b/src/entities/maresciallo.h @@ -13,7 +13,7 @@  #define MARESCIALLO_BULLET_DAMAGE 0.01  #define MARESCIALLO_CHANGE_OF_HIT 10 -#define MARESCIALLO_MISSILE_COOLDOWN 3.0 +#define MARESCIALLO_MISSILE_COOLDOWN 0.5  typedef struct Maresciallo {  	EntityFlyToPointInfo flyToPoint; diff --git a/src/gameScreen.c b/src/gameScreen.c index b004215..c38b06d 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -49,9 +49,12 @@ void updateGameScreen(Game * game) {  void openGameScreen(Game * game) {  	game->screenId = SCREEN_GAME; -	DisableCursor(); + +	if (game->settings.lockMouse) +		DisableCursor();  }  void closeGameScreen(Game * game) { -	EnableCursor(); +	if (game->settings.lockMouse) +		EnableCursor();  } 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};  } diff --git a/src/settings.c b/src/settings.c index ceda921..7aa10ea 100644 --- a/src/settings.c +++ b/src/settings.c @@ -5,6 +5,7 @@ void initSettings(Settings * settings) {  		.controlMode = KEYBOARD_AND_MOUSE_CONTROL,  		.mouseSensitivity = 0.1,  		.scrollBarSpeed = 10.0, +		.lockMouse = false,  		.gamePadNum = 0,  		.pitchStick = 1,  		.yawStick = 0, diff --git a/src/settings.h b/src/settings.h index 0e648bb..7d97bd2 100644 --- a/src/settings.h +++ b/src/settings.h @@ -16,6 +16,7 @@ typedef struct Settings {  	// Keyboard and mouse control.  	float mouseSensitivity;  	float scrollBarSpeed; +	bool lockMouse;  	// Joystick control.  	int gamePadNum; diff --git a/src/world.c b/src/world.c index 26ac9cd..0e7c975 100644 --- a/src/world.c +++ b/src/world.c @@ -203,13 +203,22 @@ KfError removeEntityFromWorld(World * world, EntityId id) {  		return KFERROR;  	// Move back entities. -	for (i = pos; i < world->entitiesCount - 1; ++i) -		world->entities[i] = world->entities[i + 1]; +	// for (i = pos; i < world->entitiesCount - 1; ++i) +	// 	world->entities[i] = world->entities[i + 1];  	// Update lookup. -	for (i = id + 1; i < world->lookUpSize; ++i) -		if (world->lookUp[i] != ENTITY_ID_NONE) -			--world->lookUp[i]; +	// for (i = id + 1; i < world->lookUpSize; ++i) +	// 	if (world->lookUp[i] != ENTITY_ID_NONE) +	// 		--world->lookUp[i]; + +	// This is a replacement for the code above. It was buggy. +	for (i = pos; i < world->entitiesCount - 1; ++i) { +		// Move back entities +		world->entities[i] = world->entities[i + 1]; + +		// Update lookUp. +		world->lookUp[world->entities[i].id] = i; +	}  	world->lookUp[id] = ENTITY_ID_NONE; @@ -298,6 +307,8 @@ void handleCollisionInWorld(Entity * entity1, Entity * entity2) {  			break;  		case ENTITY_MUSSOLINI:  			break; +		case ENTITY_GUIDED_MISSILE: +			break;  		default:  			break;  	} @@ -336,17 +347,19 @@ void updateWorld(World * world, Game * game) {  		}  		// It fucking died. -		if (entity->health <= 0.0) { +		if (entity->health <= 0.0 && entity->type != ENTITY_ANTIFA) {  			kills[killCount] = entity->id;  			++killCount;  		}  	} +	if (killCount != 0) { +		printf("%ld\n", killCount); +		debugWorld(world); +	} +  	// "bring out your dead!"  	for (i = 0; i < killCount; ++i) { -		if (kills[i] == 0) // Hack to keep player alive while debugging. -			continue; -  		removeEntityFromWorld(world, kills[i]);  	} @@ -415,6 +428,32 @@ EntityId traceRayToEntityInWorld(World * world, Ray ray, EntityFingerprint from,  	return closestId;  } +void debugWorld(World * world) { +	int i; +	Entity * entity; + +	for (i = 0; i < world->entitiesCount; ++i) { +		entity = &world->entities[i]; + +		bool idMatches = world->lookUp[entity->id] == i; + +		printf("index: %d, look up: %d, id: %d fingerprint: %x, matches: %d\n", i, world->lookUp[entity->id], entity->id, entity->fingerprint, idMatches); +	} + +	// for (i = 0; i < world->lookUpSize; ++i) { +	// 	if (world->lookUp[i] != ENTITY_ID_NONE) +	// 		printf("%d\n", world->entities[world->lookUp[i]].id == i); +	// } + +	if (world->vacantIds == NULL) +		return; + +	for (i = 0; i < world->vacantIdsCount; ++i) +		printf("v %d\n", world->vacantIds[i]); + +	puts(""); +} +  KfError addEntryToWorld(World * world, Game * game, WorldEntry entry) {  	// Create entity.  	Entity entity = createEntity(entry.type, game); diff --git a/src/world.h b/src/world.h index d714649..b364270 100644 --- a/src/world.h +++ b/src/world.h @@ -46,6 +46,8 @@ void drawWorld(World * world, Game * game);  // From can be used to stop it from hitting the entity the ray is coming from...  EntityId traceRayToEntityInWorld(World * world, Ray ray, EntityFingerprint from, bool useFrom); +void debugWorld(World * world); +  // Used for creating worlds.  typedef struct WorldEntry {  	EntityType type; | 
