aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entity.c9
-rw-r--r--src/entity.h4
-rw-r--r--src/game.c1
-rw-r--r--src/player.c8
-rw-r--r--src/settings.c1
-rw-r--r--src/settings.h5
-rw-r--r--src/world.c12
-rw-r--r--src/world.h2
8 files changed, 22 insertions, 20 deletions
diff --git a/src/entity.c b/src/entity.c
index 93d713a..3f988ad 100644
--- a/src/entity.c
+++ b/src/entity.c
@@ -161,7 +161,7 @@ void updateEntity(Entity* entity, Game* game)
break;
case POND:
DrawPlane(
- Vector3Add(entity->position, (Vector3){0.0, POND_HEIGHT * 2.0, 0.0}),
+ Vector3Add(entity->position, (Vector3){0.0, POND_HEIGHT, 0.0}),
(Vector2){POND_SIZE * 2.5, POND_SIZE * 2.5}, BLUE);
break;
case SAMANTHA:
@@ -215,15 +215,14 @@ void placeEntityOnGround(Entity* entity, const World* world)
setEntityPosition(entity, position);
}
-bool entityIsPlace(EntityId id)
+bool entityCanBeSelected(EntityId id)
{
switch (id)
{
- case POND:
case SAMANTHAS_SPOT:
- return true;
- default:
return false;
+ default:
+ return true;
}
}
diff --git a/src/entity.h b/src/entity.h
index aad3a05..9727e51 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -12,7 +12,7 @@
#define FLOWER_SCALE 3.0
#define POND_SIZE 250.0
-#define POND_HEIGHT 10.0
+#define POND_HEIGHT 15.0
#define UTILITY_POLE_HEIGHT 100.0
#define UTILITY_POLE_RADIUS 3.0
@@ -96,7 +96,7 @@ Entity createEntity(EntityId id, Vector3 position);
void updateEntity(Entity* entity, Game* game);
void setEntityPosition(Entity* entity, Vector3 position);
void placeEntityOnGround(Entity* entity, const World* world);
-bool entityIsPlace(EntityId id);
+bool entityCanBeSelected(EntityId id);
InteractionCommand interactWithEntity(Entity* entity, Game* game,
Selection selection);
diff --git a/src/game.c b/src/game.c
index aa6c449..dd60eeb 100644
--- a/src/game.c
+++ b/src/game.c
@@ -77,6 +77,7 @@ void initGame(Game* game)
// Player.
game->player = createPlayer();
+ game->player.camera.fovy = game->settings.fov;
game->player.position = Vector3Scale(game->world.size, 0.5);
disableGameCursor(game);
diff --git a/src/player.c b/src/player.c
index 7da0b01..5c1c150 100644
--- a/src/player.c
+++ b/src/player.c
@@ -11,7 +11,7 @@ Player createPlayer()
.position = (Vector3){0.0, 0.0, 0.0},
.target = Vector3Zero(),
.up = (Vector3){0.0, 1.0, 0.0},
- .fovy = 100,
+ .fovy = 90.0,
.projection = CAMERA_PERSPECTIVE
},
.cameraAngle = Vector2Zero()
@@ -83,7 +83,6 @@ void updatePlayer(Player* player, Game* game)
camera->position = player->position;
camera->target = Vector3Add(player->position, player->direction);
-/* #ifdef FT_DEBUG_MODE */
Ray ray = (Ray){
.position = player->position,
.direction = player->direction
@@ -92,13 +91,12 @@ void updatePlayer(Player* player, Game* game)
DrawRay(ray, YELLOW);
int tests;
- WorldUID uid = castRayAtWorld(&game->world, ray, true, &tests);
+ WorldUID uid = castRayAtWorld(&game->world, ray, false, &tests);
- //printf("%d\n", tests);
+ printf("%d\n", tests);
if (uid != -1)
{
DrawBoundingBox(game->world.entities[uid].box, RED);
}
-/* #endif */
}
diff --git a/src/settings.c b/src/settings.c
index 9eb1fd2..b88ac83 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -7,6 +7,7 @@ Settings defaultSettings()
.windowHeight = 720,
.screenWidth = 596,
.screenHeight = 447,
+ .fov = 90.0,
.edgeDetectionWidth = 80.0,
.edgeDetectionHeight = 60.0,
.edgeDetectionFactor = 0.11,
diff --git a/src/settings.h b/src/settings.h
index 668e615..68cdca7 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -12,12 +12,15 @@ typedef struct {
int screenWidth;
int screenHeight;
+ // Render.
+ float fov;
+
// Edge detection.
float edgeDetectionWidth;
float edgeDetectionHeight;
float edgeDetectionFactor;
- // Color
+ // Color.
float gamma;
float colorCount;
diff --git a/src/world.c b/src/world.c
index 75fc0ab..dd76cf8 100644
--- a/src/world.c
+++ b/src/world.c
@@ -936,7 +936,7 @@ float getWorldHeightAtLocation(const World* world, float x, float y)
return 0.0;
}
-void castRayBVH(const World* world, BVHNode node, Ray ray, bool includePlaces,
+void castRayBVH(const World* world, BVHNode node, Ray ray, bool allowAll,
int* tests, WorldUID* closest, float* closestDistance)
{
if (!GetRayCollisionBox(ray, node.box).hit)
@@ -964,8 +964,8 @@ void castRayBVH(const World* world, BVHNode node, Ray ray, bool includePlaces,
ray.position);
// Don't include places.
- if (!includePlaces &&
- entityIsPlace(world->entities[node.entities[index]].id))
+ if (!allowAll &&
+ !entityCanBeSelected(world->entities[node.entities[index]].id))
{
continue;
}
@@ -982,7 +982,7 @@ void castRayBVH(const World* world, BVHNode node, Ray ray, bool includePlaces,
{
for (int index = 0; index < node.branchCount; ++index)
{
- castRayBVH(world, *node.branches[index], ray, includePlaces, tests,
+ castRayBVH(world, *node.branches[index], ray, allowAll, tests,
closest, closestDistance);
}
}
@@ -990,12 +990,12 @@ void castRayBVH(const World* world, BVHNode node, Ray ray, bool includePlaces,
return;
}
-WorldUID castRayAtWorld(const World* world, Ray ray, bool includePlaces,
+WorldUID castRayAtWorld(const World* world, Ray ray, bool allowAll,
int* tests)
{
WorldUID uid = -1;
float distance = Vector3LengthSqr(world->size);
- castRayBVH(world, world->bvh, ray, includePlaces, tests, &uid, &distance);
+ castRayBVH(world, world->bvh, ray, allowAll, tests, &uid, &distance);
return uid;
}
diff --git a/src/world.h b/src/world.h
index 10306d3..df9ba73 100644
--- a/src/world.h
+++ b/src/world.h
@@ -89,7 +89,7 @@ void freeWorld(World world);
// When dealing with the world in 2d use y in place of z.
float getWorldHeightAtLocation(const World* world, float x, float y);
Vector2 worldPositionToPixel(const World* world, float x, float y);
-WorldUID castRayAtWorld(const World* world, Ray ray, bool includePlaces,
+WorldUID castRayAtWorld(const World* world, Ray ray, bool allowAll,
int* tests);
#endif