diff --git a/Faceball2030/Faceball2030.vcxproj b/Faceball2030/Faceball2030.vcxproj
index 43c66da..8d0526f 100644
--- a/Faceball2030/Faceball2030.vcxproj
+++ b/Faceball2030/Faceball2030.vcxproj
@@ -119,6 +119,7 @@
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
+ stdcpp17
Console
diff --git a/Faceball2030/assets/yazawa.png b/Faceball2030/assets/yazawa.png
new file mode 100644
index 0000000..3fa2015
Binary files /dev/null and b/Faceball2030/assets/yazawa.png differ
diff --git a/Faceball2030/main.cpp b/Faceball2030/main.cpp
index a311624..cfc11fc 100644
--- a/Faceball2030/main.cpp
+++ b/Faceball2030/main.cpp
@@ -36,8 +36,8 @@ void FaceBall::LoadLevel(int level)
std::vectorrow;
for (int x = 0; x < MAP_SIZE.x; x++) {
row.push_back({});
- mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y}},{{0,0},{1,0},{0,1}},BLUE });
- mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{0,0},{1,0},{0,1}},BLUE });
+ mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y}},{{0,0},{0,1},{1,0}},BLUE });
+ mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y},{(float)x,0,(float)y + 1},{(float)x + 1,0,(float)y + 1}},{{1,0},{0,1},{1,1}},BLUE });
}
map.push_back(row);
}
@@ -58,20 +58,20 @@ void FaceBall::LoadLevel(int level)
}
AddWall(wallData, { x,y });
if (map[y][x].wallN != NULL) {
- mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},YELLOW });
- mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x + 1,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},YELLOW });
+ mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,0,(float)y},{(float)x + 1,1,(float)y}},{{0,0},{0,1},{1,0}},YELLOW });
+ mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x + 1,0,(float)y},{(float)x + 1,1,(float)y}},{{0,1},{1,1},{1,0}},YELLOW });
}
if (map[y][x].wallS != NULL) {
- mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x,0,(float)y + 1},{(float)x,1,(float)y + 1}},{{0,0},{1,0},{0,1}},DARK_RED });
- mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x + 1,0,(float)y + 1},{(float)x,0,(float)y + 1}},{{0,0},{1,0},{0,1}},DARK_RED });
+ mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x,0,(float)y + 1},{(float)x,1,(float)y + 1}},{{0,0},{1,1},{1,0}},DARK_RED });
+ mapMesh.tris.push_back({ {{(float)x + 1,1,(float)y + 1},{(float)x + 1,0,(float)y + 1},{(float)x,0,(float)y + 1}},{{0,0},{0,1},{1,1}},DARK_RED });
}
if (map[y][x].wallW != NULL) {
- mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,1,(float)y + 1}, {(float)x,0,(float)y + 1}},{{0,0},{1,0},{0,1}},MAGENTA });
- mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,1,(float)y}, {(float)x,0,(float)y + 1}}, {{0,0},{1,0},{0,1}},MAGENTA });
+ mapMesh.tris.push_back({ {{(float)x,1,(float)y},{(float)x,1,(float)y + 1}, {(float)x,0,(float)y + 1}},{{1,0},{0,0},{0,1}},MAGENTA });
+ mapMesh.tris.push_back({ {{(float)x,0,(float)y},{(float)x,1,(float)y}, {(float)x,0,(float)y + 1}}, {{1,1},{1,0},{0,1}},MAGENTA });
}
if (map[y][x].wallE != NULL) {
- mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1},{(float)x + 1,1,(float)y + 1},{(float)x + 1,1,(float)y}},{{0,0},{1,0},{0,1}},CYAN });
- mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1} ,{(float)x + 1,1,(float)y},{(float)x + 1,0,(float)y}},{{0,0},{1,0},{0,1}},CYAN });
+ mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1},{(float)x + 1,1,(float)y + 1},{(float)x + 1,1,(float)y}},{{1,1},{1,0},{0,0}},CYAN });
+ mapMesh.tris.push_back({ {{(float)x + 1,0,(float)y + 1} ,{(float)x + 1,1,(float)y},{(float)x + 1,0,(float)y}},{{1,1},{0,0},{0,1}},CYAN });
}
}
}
@@ -472,8 +472,8 @@ void FaceBall::RenderWorld() {
vec3d vTarget = { 0,sinf(pitch),cosf(pitch) };
mat4x4 matCameraRot = Matrix_MakeRotationY(fYaw);
vLookDir = Matrix_MultiplyVector(matCameraRot, vTarget);
- vTarget = Vector_Add(player.GetPos(), vLookDir);
- mat4x4 matCamera = Matrix_PointAt(player.GetPos(), vTarget, vUp);
+ vTarget = Vector_Add(freeRoam?freeRoamCamera:player.GetPos(), vLookDir);
+ mat4x4 matCamera = Matrix_PointAt(freeRoam?freeRoamCamera:player.GetPos(), vTarget, vUp);
mat4x4 matView = Matrix_QuickInverse(matCamera);
std::vectorvecTrianglesToRaster;
@@ -505,7 +505,7 @@ void FaceBall::RenderWorld() {
normal = Vector_CrossProduct(line1, line2);
normal = Vector_Normalise(normal);
- vec3d vCameraRay = Vector_Sub(triTransformed.p[0], player.GetPos());
+ vec3d vCameraRay = Vector_Sub(triTransformed.p[0], freeRoam?freeRoamCamera:player.GetPos());
if (Vector_DotProduct(normal, vCameraRay) < 0) {
vec3d light_dir = Vector_Mul(vLookDir, -1);
@@ -666,24 +666,34 @@ void FaceBall::HandleKeys(float fElapsedTime) {
pitch = 0;
}
if (GetKey(W).bHeld) {
- if (!CheckCollision({ vForward.x,0,0 })) {
- vec3d xMovement{ vForward.x,0,0 };
- player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
+ if (freeRoam) {
+ freeRoamCamera = Vector_Add(freeRoamCamera, vForward);
}
- if (!CheckCollision({0,0,vForward.z})) {
- vec3d zMovement{ 0,0,vForward.z };
- player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
+ else {
+ if (!CheckCollision({ vForward.x,0,0 })) {
+ vec3d xMovement{ vForward.x,0,0 };
+ player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
+ }
+ if (!CheckCollision({ 0,0,vForward.z })) {
+ vec3d zMovement{ 0,0,vForward.z };
+ player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
+ }
}
}
if (GetKey(S).bHeld) {
vec3d vReverse = { -vForward.x,-vForward.y,-vForward.z };
- if (!CheckCollision({ vReverse.x,0,0 })) {
- vec3d xMovement{ vReverse.x,0,0 };
- player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
+ if (freeRoam) {
+ freeRoamCamera = Vector_Add(freeRoamCamera, vReverse);
}
- if (!CheckCollision({ 0,0,vReverse.z })) {
- vec3d zMovement{ 0,0,vReverse.z };
- player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
+ else {
+ if (!CheckCollision({ vReverse.x,0,0 })) {
+ vec3d xMovement{ vReverse.x,0,0 };
+ player.UpdatePos(Vector_Add(player.GetPos(), xMovement));
+ }
+ if (!CheckCollision({ 0,0,vReverse.z })) {
+ vec3d zMovement{ 0,0,vReverse.z };
+ player.UpdatePos(Vector_Add(player.GetPos(), zMovement));
+ }
}
}
if (GetKey(olc::A).bHeld) {
@@ -733,11 +743,12 @@ bool FaceBall::OnUserCreate()
circle = new Decal(new Sprite("assets/circle.png"));
arrow = new Decal(new Sprite("assets/arrow.png"));
enemy_ShootMe_tex = new Decal(new Sprite("assets/enemies/ShootMe.png"));
+ YAZAWA = new Decal(new Sprite("assets/yazawa.png"));
InitializeEnemyData();
Mesh testEnemy("assets/enemies/ShootMe.obj", enemy_ShootMe_tex);
- mapMesh.texture = dot;
+ mapMesh.texture = YAZAWA;
LoadLevel(1);
diff --git a/Faceball2030/main.h b/Faceball2030/main.h
index 9208b15..afbee9f 100644
--- a/Faceball2030/main.h
+++ b/Faceball2030/main.h
@@ -169,7 +169,7 @@ class FaceBall : public PixelGameEngine
}
EnemyData GetData(EnemyID id);
- Decal* circle,*arrow;
+ Decal* circle,*arrow,*YAZAWA;
private:
Mesh mapMesh;
@@ -193,6 +193,7 @@ class FaceBall : public PixelGameEngine
float pitch = -PI / 6;
Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} };
+ vec3d freeRoamCamera = { 1,0.5,1 };
vec3d Matrix_MultiplyVector(mat4x4& m, vec3d& i);
mat4x4 Matrix_MakeIdentity();