|
|
|
@ -67,7 +67,7 @@ bool Enemy::CanShoot() { |
|
|
|
|
|
|
|
|
|
void Enemy::ShootBullet(int myIndex) { |
|
|
|
|
fireDelay = game->enemyData[GetID()].fireDelay; |
|
|
|
|
game->bullets.push_back({ game->bullet, {pos.x,pos.y+0.15f,pos.z},rot,0.2f,1,{std::cosf(rot) * game->shotSpd,std::sinf(rot) * game->shotSpd }, YELLOW,false,GetID(),myIndex,blinking}); |
|
|
|
|
game->bullets.push_back({ game->bullet, {pos.x,pos.y+0.15f,pos.z},rot,0.2f,1,true,{std::cosf(rot) * game->shotSpd,std::sinf(rot) * game->shotSpd }, YELLOW,false,GetID(),myIndex,blinking}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Enemy::ReloadBullet(float fElapsedTime) { |
|
|
|
@ -436,7 +436,7 @@ void FaceBall::LoadLevel(int level) |
|
|
|
|
walls = { mapWalls }; |
|
|
|
|
MapWallsObjectIndex = objects.size()-1; |
|
|
|
|
objects.push_back({ mapFloor,{0,0,0},0,0 }); |
|
|
|
|
objects.push_back({ worldSkyBox,{0,0,0},0,0 }); |
|
|
|
|
objects.push_back({ worldSkyBox,{MAP_SIZE.x/2.f,0,MAP_SIZE.y/2.f},0,0,std::max(float(MAP_SIZE.x),float(MAP_SIZE.y))*2,false }); |
|
|
|
|
//objects.push_back({ game->mapExit,{(float)exitCoords.x+0.5f,0,(float)exitCoords.y+0.5f},0,0.4f });
|
|
|
|
|
exit = { game->mapExit,{(float)exitCoords.x + 0.5f,0.02f,(float)exitCoords.y + 0.5f},0,0.4f }; |
|
|
|
|
RegenerateMinimap(); |
|
|
|
@ -955,7 +955,7 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector<Triangle>&vecTrianglesToRas |
|
|
|
|
|
|
|
|
|
vec3d vCameraRay = Vector_Sub(triTransformed.p[0], freeRoam ? freeRoamCamera : player.GetPos()); |
|
|
|
|
|
|
|
|
|
if (Vector_DotProduct(normal, vCameraRay) < 0) { |
|
|
|
|
if (Vector_DotProduct(normal, vCameraRay) < 0||!o.affectedByLighting) { |
|
|
|
|
vec3d light_dir = Vector_Mul(vLookDir, -1); |
|
|
|
|
light_dir = Vector_Normalise(light_dir); |
|
|
|
|
|
|
|
|
@ -967,9 +967,11 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector<Triangle>&vecTrianglesToRas |
|
|
|
|
triViewed.uv[0] = triTransformed.uv[0]; |
|
|
|
|
triViewed.uv[1] = triTransformed.uv[1]; |
|
|
|
|
triViewed.uv[2] = triTransformed.uv[2]; |
|
|
|
|
if (o.affectedByLighting) { |
|
|
|
|
triViewed.col[0] = Pixel(triTransformed.col[0].r * dp * dp, triTransformed.col[0].g * dp * dp, triTransformed.col[0].b * dp * dp); |
|
|
|
|
triViewed.col[1] = Pixel(triTransformed.col[1].r * dp * dp, triTransformed.col[1].g * dp * dp, triTransformed.col[1].b * dp * dp); |
|
|
|
|
triViewed.col[2] = Pixel(triTransformed.col[2].r * dp * dp, triTransformed.col[2].g * dp * dp, triTransformed.col[2].b * dp * dp); |
|
|
|
|
} |
|
|
|
|
Pixel originalCol[3] = { triViewed.col[0],triViewed.col[1],triViewed.col[2] }; |
|
|
|
|
float dist = std::sqrtf(std::powf((freeRoam ? freeRoamCamera : player.GetPos()).x - triTransformed.p[0].x, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).y - triTransformed.p[0].y, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).z - triTransformed.p[0].z, 2)); |
|
|
|
|
float dist2 = std::sqrtf(std::powf((freeRoam ? freeRoamCamera : player.GetPos()).x - triTransformed.p[1].x, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).y - triTransformed.p[1].y, 2) + std::powf((freeRoam ? freeRoamCamera : player.GetPos()).z - triTransformed.p[1].z, 2)); |
|
|
|
@ -977,11 +979,19 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector<Triangle>&vecTrianglesToRas |
|
|
|
|
float colorMult = dist > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist + PI / 2); |
|
|
|
|
float colorMult2 = dist2 > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist2 + PI / 2); |
|
|
|
|
float colorMult3 = dist3 > 5 * PI / 3 ? 0 : std::sinf(0.3 * dist3 + PI / 2); |
|
|
|
|
if (o.affectedByLighting) { |
|
|
|
|
triViewed.col[0] = Pixel(triViewed.col[0].r * colorMult, triViewed.col[0].g * colorMult, triViewed.col[0].b * colorMult); |
|
|
|
|
triViewed.col[1] = Pixel(triViewed.col[1].r * colorMult2, triViewed.col[1].g * colorMult2, triViewed.col[1].b * colorMult2); |
|
|
|
|
triViewed.col[2] = Pixel(triViewed.col[2].r * colorMult3, triViewed.col[2].g * colorMult3, triViewed.col[2].b * colorMult3); |
|
|
|
|
} |
|
|
|
|
if (!o.affectedByLighting) { |
|
|
|
|
triViewed.col[0] = originalCol[0]; |
|
|
|
|
triViewed.col[1] = originalCol[1]; |
|
|
|
|
triViewed.col[2] = originalCol[2]; |
|
|
|
|
} |
|
|
|
|
triViewed.tex = triTransformed.tex; |
|
|
|
|
|
|
|
|
|
if (o.affectedByLighting) { |
|
|
|
|
for (Bullet& b : bullets) { |
|
|
|
|
float dist = std::sqrtf(std::powf(b.pos.x - triTransformed.p[0].x, 2) + std::powf(b.pos.y - triTransformed.p[0].y, 2) + std::powf(b.pos.z - triTransformed.p[0].z, 2)); |
|
|
|
|
float dist2 = std::sqrtf(std::powf(b.pos.x - triTransformed.p[1].x, 2) + std::powf(b.pos.y - triTransformed.p[1].y, 2) + std::powf(b.pos.z - triTransformed.p[1].z, 2)); |
|
|
|
@ -994,6 +1004,7 @@ void FaceBall::RenderMesh(mat4x4&matView,std::vector<Triangle>&vecTrianglesToRas |
|
|
|
|
if (dist2 < 2) { triViewed.col[1] = Pixel(std::min(255, std::max((int)originalCol[1].r, (int)(originalCol[1].r * colorMult2 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[1].g, (int)(originalCol[1].g * colorMult2 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[1].b, (int)(originalCol[1].b * colorMult2 / float(255.f / lightCol.b))))); } |
|
|
|
|
if (dist3 < 2) { triViewed.col[2] = Pixel(std::min(255, std::max((int)originalCol[2].r, (int)(originalCol[2].r * colorMult3 / float(255.f / lightCol.r)))), std::min(255, std::max((int)originalCol[2].g, (int)(originalCol[2].g * colorMult3 / float(255.f / lightCol.g)))), std::min(255, std::max((int)originalCol[2].b, (int)(originalCol[2].b * colorMult3 / float(255.f / lightCol.b))))); } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//triViewed.col = triTransformed.col;
|
|
|
|
|
|
|
|
|
|
int nClippedTriangles = 0; |
|
|
|
@ -1546,7 +1557,7 @@ void FaceBall::HandleKeys(float fElapsedTime) { |
|
|
|
|
pitch = 0; |
|
|
|
|
if (GetMouse(0).bPressed) { |
|
|
|
|
if (PlayerActiveShotCount(0) < shotLimit) { |
|
|
|
|
Bullet newBullet={ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,1,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }; |
|
|
|
|
Bullet newBullet={ bullet,{player.GetPos().x,player.GetPos().y - 0.15f, player.GetPos().z},fYaw,0.125f,1,true,{shotSpd * std::cosf(fYaw),shotSpd * std::sinf(fYaw)},GREEN,true }; |
|
|
|
|
newBullet.playerIndex=0; |
|
|
|
|
bullets.push_back(newBullet); |
|
|
|
|
} |
|
|
|
|