|
|
@ -79,6 +79,7 @@ void FaceBall::InitializeBulletColors() { |
|
|
|
void FaceBall::LoadLevel(int level) |
|
|
|
void FaceBall::LoadLevel(int level) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this->level = level; |
|
|
|
this->level = level; |
|
|
|
|
|
|
|
exitWallsCleared = false; |
|
|
|
std::vector<std::vector<Tile>>mapData = editor.LoadLevel(level); |
|
|
|
std::vector<std::vector<Tile>>mapData = editor.LoadLevel(level); |
|
|
|
MAP_SIZE = { (int)mapData[0].size(),(int)mapData.size() }; |
|
|
|
MAP_SIZE = { (int)mapData[0].size(),(int)mapData.size() }; |
|
|
|
map.clear(); |
|
|
|
map.clear(); |
|
|
@ -87,7 +88,7 @@ void FaceBall::LoadLevel(int level) |
|
|
|
objects.clear(); |
|
|
|
objects.clear(); |
|
|
|
bullets.clear(); |
|
|
|
bullets.clear(); |
|
|
|
enemies.clear(); |
|
|
|
enemies.clear(); |
|
|
|
vi2d exitCoords = { 0,0 }; |
|
|
|
exitCoords = { 0,0 }; |
|
|
|
for (int y = 0; y < MAP_SIZE.y; y++) { |
|
|
|
for (int y = 0; y < MAP_SIZE.y; y++) { |
|
|
|
std::vector<MapSquare>row; |
|
|
|
std::vector<MapSquare>row; |
|
|
|
for (int x = 0; x < MAP_SIZE.x; x++) { |
|
|
|
for (int x = 0; x < MAP_SIZE.x; x++) { |
|
|
@ -154,9 +155,11 @@ void FaceBall::LoadLevel(int level) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
objects.push_back({ mapWalls,{0,0,0},0,0 }); |
|
|
|
walls = { mapWalls }; |
|
|
|
|
|
|
|
MapWallsObjectIndex = objects.size()-1; |
|
|
|
objects.push_back({ mapFloor,{0,0,0},0,0 }); |
|
|
|
objects.push_back({ mapFloor,{0,0,0},0,0 }); |
|
|
|
objects.push_back({ game->mapExit,{(float)exitCoords.x+0.5f,0,(float)exitCoords.y+0.5f},0,0.4f }); |
|
|
|
//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,(float)exitCoords.y + 0.5f},0,0.4f }; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool FaceBall::CheckCollision(vec3d movementVector,vf2d pos,float radius){ |
|
|
|
bool FaceBall::CheckCollision(vec3d movementVector,vf2d pos,float radius){ |
|
|
@ -698,6 +701,11 @@ void FaceBall::RenderWorld() { |
|
|
|
for (auto& obj : objects) { |
|
|
|
for (auto& obj : objects) { |
|
|
|
RenderMesh(matView,vecTrianglesToRaster,obj); |
|
|
|
RenderMesh(matView,vecTrianglesToRaster,obj); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
RenderMesh(matView, vecTrianglesToRaster, exit); |
|
|
|
|
|
|
|
for (Triangle& t : exit.mesh.tris) { |
|
|
|
|
|
|
|
t.col[0] = t.col[1] = t.col[2] = {0,(uint8_t)(std::abs(std::sinf(2*PI*gameTimer)) * 255),0}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
RenderMesh(matView, vecTrianglesToRaster, walls); |
|
|
|
for (auto& enemy : enemies) { |
|
|
|
for (auto& enemy : enemies) { |
|
|
|
RenderMesh(matView, vecTrianglesToRaster, enemy); |
|
|
|
RenderMesh(matView, vecTrianglesToRaster, enemy); |
|
|
|
} |
|
|
|
} |
|
|
@ -984,6 +992,71 @@ bool Bullet::Update(float fElapsedTime) { |
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::SubtractTag() { |
|
|
|
void FaceBall::SubtractTag() { |
|
|
|
tagsRemaining = std::max(0, tagsRemaining - 1); |
|
|
|
tagsRemaining = std::max(0, tagsRemaining - 1); |
|
|
|
|
|
|
|
if (!exitWallsCleared&&tagsRemaining <= 0) { |
|
|
|
|
|
|
|
exitWallsCleared = true; |
|
|
|
|
|
|
|
if (exitCoords.y != 0) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x].wallN = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.y != MAP_SIZE.y-1) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x].wallS = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.x != 0) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x].wallW = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.x != MAP_SIZE.x-1) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x].wallE = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.x-1 > 0) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x - 1].wallE = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.x+1 < MAP_SIZE.x) { |
|
|
|
|
|
|
|
map[exitCoords.y][exitCoords.x+1].wallW = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.y-1 > 0) { |
|
|
|
|
|
|
|
map[exitCoords.y - 1][exitCoords.x].wallS = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (exitCoords.y+1 < MAP_SIZE.y) { |
|
|
|
|
|
|
|
map[exitCoords.y+1][exitCoords.x].wallN = NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapWalls.tris.clear(); |
|
|
|
|
|
|
|
for (int y = 0; y < MAP_SIZE.y; y++) { |
|
|
|
|
|
|
|
for (int x = 0; x < MAP_SIZE.x; x++) { |
|
|
|
|
|
|
|
if (map[y][x].wallN != NULL) { |
|
|
|
|
|
|
|
Decal* exitWallTex = wall_tex; |
|
|
|
|
|
|
|
if (vi2d{ x,y } == vi2d{ exitCoords.x, exitCoords.y + 1 }) { |
|
|
|
|
|
|
|
exitWallTex = exit_wall_tex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (map[y][x].wallS != NULL) { |
|
|
|
|
|
|
|
Decal* exitWallTex = wall_tex; |
|
|
|
|
|
|
|
if (vi2d{ x,y } == vi2d{ exitCoords.x, exitCoords.y - 1 }) { |
|
|
|
|
|
|
|
exitWallTex = exit_wall_tex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (map[y][x].wallW != NULL) { |
|
|
|
|
|
|
|
Decal* exitWallTex = wall_tex; |
|
|
|
|
|
|
|
if (vi2d{ x,y } == vi2d{ exitCoords.x + 1, exitCoords.y }) { |
|
|
|
|
|
|
|
exitWallTex = exit_wall_tex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (map[y][x].wallE != NULL) { |
|
|
|
|
|
|
|
Decal* exitWallTex = wall_tex; |
|
|
|
|
|
|
|
if (vi2d{ x,y } == vi2d{ exitCoords.x - 1, exitCoords.y }) { |
|
|
|
|
|
|
|
exitWallTex = exit_wall_tex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
mapWalls.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}},{WHITE,WHITE,WHITE}, exitWallTex }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
walls.mesh=mapWalls; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime) { |
|
|
|
void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime) { |
|
|
@ -1041,6 +1114,7 @@ void FaceBall::RunEnemyAI(Enemy& e,float fElapsedTime) { |
|
|
|
|
|
|
|
|
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
bool FaceBall::OnUserUpdate(float fElapsedTime) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
gameTimer += fElapsedTime; |
|
|
|
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end(); ++it) { |
|
|
|
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end(); ++it) { |
|
|
|
Bullet& b = *it; |
|
|
|
Bullet& b = *it; |
|
|
|
if (!b.Update(fElapsedTime)) { |
|
|
|
if (!b.Update(fElapsedTime)) { |
|
|
|