Add in exit blinking effect.

linux_template
sigonasr2 2 years ago
parent 8149d1110e
commit e4216d5769
  1. 36
      Faceball2030/assets/map/map1.map
  2. 80
      Faceball2030/main.cpp
  3. 8
      Faceball2030/main.h

@ -1,34 +1,34 @@
8 8
4 4
33195 33195
32778 33178
8200 8600
8204 8604
8203 8603
8202 8602
8200 8600
8204 8604
40971 40969
32776 33176
0 400
8194 8594
8618 8618
8202 8202
8198 8198
8197 8197
8351
8193 8193
8198 8192
8598
8617 8617
8200 8202
8202 8202
8202 8202
8198 8198
8203 8195
16662 16662
8207 8207
8195 8195
8194
8202 8202
25114 8202
24590 25118
24735

@ -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)) {

@ -209,14 +209,18 @@ class FaceBall : public PixelGameEngine
Decal* dot, * enemy_ShootMe_tex,*bullet_tex,*wall_tex,*floor_tex, Decal* dot, * enemy_ShootMe_tex,*bullet_tex,*wall_tex,*floor_tex,
*enemy_Sonar_tex,*hud,*exit_wall_tex; *enemy_Sonar_tex,*hud,*exit_wall_tex;
vi2d MAP_SIZE; vi2d MAP_SIZE;
vi2d exitCoords = { 0,0 };
std::vector<std::vector<MapSquare>>map; std::vector<std::vector<MapSquare>>map;
std::vector<Object>objects; std::vector<Object>objects;
std::vector<Bullet>bullets; std::vector<Bullet>bullets;
GAMEMODE mode=GAMEMODE::GAME; GAMEMODE mode=GAMEMODE::GAME;
Editor editor; Editor editor;
int MapWallsObjectIndex = -1;
bool exitWallsCleared = false;
int level=1; int level=1;
int tagsRemaining = 10; int tagsRemaining = 10;
int lives = 3; int lives = 3;
double gameTimer = 0;
mat4x4 matProj; mat4x4 matProj;
@ -229,6 +233,8 @@ class FaceBall : public PixelGameEngine
float pitch = -PI / 6; float pitch = -PI / 6;
Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} }; Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} };
Object walls;
Object exit;
vec3d freeRoamCamera = { 1,0.5,1 }; vec3d freeRoamCamera = { 1,0.5,1 };
float freeRoamCamera_pitch = pitch; float freeRoamCamera_pitch = pitch;
float freeRoamCamera_yaw = fYaw; float freeRoamCamera_yaw = fYaw;

Loading…
Cancel
Save