Powerup descriptions now appear.
This commit is contained in:
parent
494caabffa
commit
c6d7eac589
@ -128,7 +128,7 @@ void FaceBall::InitializeEnemyData() {
|
|||||||
enemyData[START] = { "SPAWN POSITION",undefined,{128,64,0} };
|
enemyData[START] = { "SPAWN POSITION",undefined,{128,64,0} };
|
||||||
enemyData[SHOOTME] = { "SHOOTME",enemy_ShootMe,YELLOW,1,1,PI / 8,2,1,0.2f,true };
|
enemyData[SHOOTME] = { "SHOOTME",enemy_ShootMe,YELLOW,1,1,PI / 8,2,1,0.2f,true };
|
||||||
enemyData[SHOOTME2] = { "SHOOTME2",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.3f,true };
|
enemyData[SHOOTME2] = { "SHOOTME2",enemy_IShoot,YELLOW,1,1,PI / 6,2,1,0.3f,true };
|
||||||
enemyData[SHOOTME_ARMOR] = { "SHOOTME_ARMOR",enemy_ShootMe,YELLOW,6,1,PI / 6,2,1,0.3f,true,PowerupType::ARMOR,true };
|
enemyData[SHOOTME_ARMOR] = { "SHOOTME",enemy_ShootMe,YELLOW,6,1,PI / 6,2,1,0.3f,true,PowerupType::ARMOR,true };
|
||||||
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 };
|
enemyData[SONAR] = { "Sonar",enemy_Sonar,RED,5,1,PI / 8,2,1 };
|
||||||
enemyData[COIN] = { "Coin",undefined,BLUE };
|
enemyData[COIN] = { "Coin",undefined,BLUE };
|
||||||
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} };
|
enemyData[POWERUP_ARMOR] = { "Armor",undefined,{96,0,96} };
|
||||||
@ -141,23 +141,23 @@ void FaceBall::InitializeEnemyData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FaceBall::InitializePowerupColors() {
|
void FaceBall::InitializePowerupColors() {
|
||||||
powerupColorData[PowerupType::ARMOR] = DARK_GREEN;
|
powerupData[PowerupType::ARMOR] = { "Armor UP",DARK_GREEN };
|
||||||
powerupColorData[PowerupType::SPEED] = DARK_BLUE;
|
powerupData[PowerupType::SPEED] = { "Speed UP", DARK_BLUE};
|
||||||
powerupColorData[PowerupType::SHOTS] = DARK_RED;
|
powerupData[PowerupType::SHOTS] = { "Shots UP", DARK_RED};
|
||||||
powerupColorData[PowerupType::STOP] = RED;
|
powerupData[PowerupType::STOP] = { "< STOP >", RED};
|
||||||
powerupColorData[PowerupType::SHIELD] = CYAN;
|
powerupData[PowerupType::SHIELD] = { "< Invincibility Shield >", CYAN};
|
||||||
powerupColorData[PowerupType::CAMO] = MAGENTA;
|
powerupData[PowerupType::CAMO] = { "< Camouflage >", MAGENTA};
|
||||||
powerupColorData[PowerupType::MAP] = GREEN;
|
powerupData[PowerupType::MAP] = { "< Minimap >", GREEN};
|
||||||
powerupColorData[PowerupType::COIN] = BLUE;
|
powerupData[PowerupType::COIN] = { "Coin", BLUE };
|
||||||
}
|
}
|
||||||
|
|
||||||
Powerup::Powerup(Mesh mesh, vec3d pos, float rot, PowerupType type)
|
Powerup::Powerup(Mesh mesh, vec3d pos, float rot, PowerupType type)
|
||||||
: type(type), col(game->powerupColorData[type]), Object{ mesh,pos,rot,0.375f } {}
|
: type(type), col(game->powerupData[type].col), Object{ mesh,pos,rot,0.375f } {}
|
||||||
|
|
||||||
bool Powerup::Update(float fElapsedTime) {
|
bool Powerup::Update(float fElapsedTime) {
|
||||||
aliveTime += fElapsedTime;
|
aliveTime += fElapsedTime;
|
||||||
colorCycle = std::sinf(10 * aliveTime);
|
colorCycle = std::sinf(10 * aliveTime);
|
||||||
col = game->powerupColorData[type] * colorCycle;
|
col = game->powerupData[type].col * colorCycle;
|
||||||
opened = false; //Open state is false until a player causes it to open.
|
opened = false; //Open state is false until a player causes it to open.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -165,9 +165,9 @@ bool Powerup::Update(float fElapsedTime) {
|
|||||||
void FaceBall::SpawnPowerup(PowerupType type, vec3d pos) {
|
void FaceBall::SpawnPowerup(PowerupType type, vec3d pos) {
|
||||||
Mesh mesh = (type <= PowerupType::SHOTS) ? powerup : powerup2;
|
Mesh mesh = (type <= PowerupType::SHOTS) ? powerup : powerup2;
|
||||||
for (Triangle& t : mesh.tris) {
|
for (Triangle& t : mesh.tris) {
|
||||||
t.col[0] = powerupColorData[type];
|
t.col[0] = powerupData[type].col;
|
||||||
t.col[1] = powerupColorData[type];
|
t.col[1] = powerupData[type].col;
|
||||||
t.col[2] = powerupColorData[type];
|
t.col[2] = powerupData[type].col;
|
||||||
}
|
}
|
||||||
powerups.push_back({ mesh,pos,0,type });
|
powerups.push_back({ mesh,pos,0,type });
|
||||||
}
|
}
|
||||||
@ -1206,7 +1206,7 @@ void FaceBall::RenderWorld() {
|
|||||||
{t.uv[1].u,t.uv[1].v},
|
{t.uv[1].u,t.uv[1].v},
|
||||||
{t.uv[2].u,t.uv[2].v},
|
{t.uv[2].u,t.uv[2].v},
|
||||||
}, { t.uv[0].w,t.uv[1].w,t.uv[2].w }, { t.p[0].z,t.p[1].z,t.p[2].z }, { t.col[0],t.col[1],t.col[2]});
|
}, { t.uv[0].w,t.uv[1].w,t.uv[2].w }, { t.p[0].z,t.p[1].z,t.p[2].z }, { t.col[0],t.col[1],t.col[2]});
|
||||||
SetDecalMode(DecalMode::WIREFRAME);
|
/*SetDecalMode(DecalMode::WIREFRAME);
|
||||||
DrawPolygonDecal(nullptr,{
|
DrawPolygonDecal(nullptr,{
|
||||||
{t.p[0].x, t.p[0].y},
|
{t.p[0].x, t.p[0].y},
|
||||||
{t.p[1].x, t.p[1].y},
|
{t.p[1].x, t.p[1].y},
|
||||||
@ -1215,7 +1215,7 @@ void FaceBall::RenderWorld() {
|
|||||||
{0,0},
|
{0,0},
|
||||||
{0,0},
|
{0,0},
|
||||||
{0,0},
|
{0,0},
|
||||||
}, { t.uv[0].w,t.uv[1].w,t.uv[2].w }, { t.p[0].z,t.p[1].z,t.p[2].z }, { WHITE,WHITE,WHITE});
|
}, { t.uv[0].w,t.uv[1].w,t.uv[2].w }, { t.p[0].z,t.p[1].z,t.p[2].z }, { WHITE,WHITE,WHITE});*/
|
||||||
SetDecalStructure(DecalStructure::FAN);
|
SetDecalStructure(DecalStructure::FAN);
|
||||||
triRenderCount++;
|
triRenderCount++;
|
||||||
}
|
}
|
||||||
@ -1784,7 +1784,15 @@ void FaceBall::RenderHud(float fElapsedTime) {
|
|||||||
if (hp > 0) {
|
if (hp > 0) {
|
||||||
DrawStringDecal(vf2d{ 112 + hudOffset+32,4+18 }+hudAdjustment, "Triangles: " + std::to_string(triRenderCount), BLACK, { 2,4 });
|
DrawStringDecal(vf2d{ 112 + hudOffset+32,4+18 }+hudAdjustment, "Triangles: " + std::to_string(triRenderCount), BLACK, { 2,4 });
|
||||||
std::string hudText = "Tags Left: " + std::to_string(tagsRemaining) + " Lives: " + std::to_string(lives);
|
std::string hudText = "Tags Left: " + std::to_string(tagsRemaining) + " Lives: " + std::to_string(lives);
|
||||||
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(hudText).x * 3 / 2)+32,(float)(ScreenHeight() - 64 - GetTextSizeProp(hudText).y * 6)+18 } + hudAdjustment, hudText, WHITE, { 3,6 });
|
DrawStringPropDecal(vf2d{ hudOffset + (float)(ScreenWidth() / 2 - GetTextSizeProp(hudText).x * 3 / 2)+32,(float)(ScreenHeight() - 2 - GetTextSizeProp(hudText).y * 5)+18 } + hudAdjustment, hudText, WHITE, { 3,5 });
|
||||||
|
for (int x = -1; x <= 1; x++) {
|
||||||
|
for (int y = -1; y <= 1; y++) {
|
||||||
|
if (x != 0 && y != 0) {
|
||||||
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 } + vf2d{ float(x),float(y) }, hudDisplayText, DARK_BLUE, { 4,4 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DrawStringDecal(vf2d{ hudOffset + float(ScreenWidth() / 2 - GetTextSize(hudDisplayText).x / 2 * 4) + 32,float(ScreenHeight() - 128 - GetTextSize(hudDisplayText).y * 4) + 18 }, hudDisplayText, { 192,192,255 }, { 4,4 });
|
||||||
DrawDecal({ float(ScreenWidth() / 2 - crosshair->sprite->width / 2),float(ScreenHeight() / 2 - crosshair->sprite->height / 2) }, crosshair, { 1,1 }, {255,255,255,128});
|
DrawDecal({ float(ScreenWidth() / 2 - crosshair->sprite->width / 2),float(ScreenHeight() / 2 - crosshair->sprite->height / 2) }, crosshair, { 1,1 }, {255,255,255,128});
|
||||||
}
|
}
|
||||||
GradientFillRectDecal({ 0,0 }, vf2d{ (float)ScreenWidth()/2,(float)ScreenHeight()/2 }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) });
|
GradientFillRectDecal({ 0,0 }, vf2d{ (float)ScreenWidth()/2,(float)ScreenHeight()/2 }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime > 0.2f ? 64 : 0) }, { (uint8_t)screenCol.r,(uint8_t)screenCol.g,(uint8_t)screenCol.b,(uint8_t)(hudShakeTime>0.2f?120:hudShakeTime>0?64:0) });
|
||||||
@ -2048,6 +2056,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
|
|||||||
gameTimer += fElapsedTime;
|
gameTimer += fElapsedTime;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case GAME: {
|
case GAME: {
|
||||||
|
hudDisplayText = "";
|
||||||
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) {
|
for (std::vector<Bullet>::iterator it = bullets.begin(); it != bullets.end();) {
|
||||||
Bullet& b = *it;
|
Bullet& b = *it;
|
||||||
if (!b.Update(fElapsedTime)) {
|
if (!b.Update(fElapsedTime)) {
|
||||||
@ -2078,6 +2087,7 @@ bool FaceBall::OnUserUpdate(float fElapsedTime)
|
|||||||
vec3d vForward = Vector_Mul(vLookDir, std::min(player.GetRadius() - 0.00001f, moveSpd * fElapsedTime));
|
vec3d vForward = Vector_Mul(vLookDir, std::min(player.GetRadius() - 0.00001f, moveSpd * fElapsedTime));
|
||||||
if (CheckPowerupCollision({ vForward.x,0,vForward.z }, { player.GetPos().x,player.GetPos().z }, player.GetRadius() * 1.25) != -1) {
|
if (CheckPowerupCollision({ vForward.x,0,vForward.z }, { player.GetPos().x,player.GetPos().z }, player.GetRadius() * 1.25) != -1) {
|
||||||
powerups[lastPowerupCollidedWith].opened = true;
|
powerups[lastPowerupCollidedWith].opened = true;
|
||||||
|
hudDisplayText = powerupData[powerups[lastPowerupCollidedWith].type].name;
|
||||||
if (GetKey(F).bPressed) {
|
if (GetKey(F).bPressed) {
|
||||||
powerups.erase(powerups.begin() + lastPowerupCollidedWith);
|
powerups.erase(powerups.begin() + lastPowerupCollidedWith);
|
||||||
lastPowerupCollidedWith = -1;
|
lastPowerupCollidedWith = -1;
|
||||||
|
@ -178,6 +178,11 @@ struct Powerup : Object {
|
|||||||
bool Update(float fElapsedTime);
|
bool Update(float fElapsedTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct PowerupData {
|
||||||
|
std::string name;
|
||||||
|
Pixel col;
|
||||||
|
};
|
||||||
|
|
||||||
struct EnemyData {
|
struct EnemyData {
|
||||||
std::string name;
|
std::string name;
|
||||||
Mesh mesh;
|
Mesh mesh;
|
||||||
@ -258,7 +263,7 @@ class FaceBall : public PixelGameEngine
|
|||||||
EnemyData GetData(EnemyID id);
|
EnemyData GetData(EnemyID id);
|
||||||
Decal* circle,*arrow,*YAZAWA;
|
Decal* circle,*arrow,*YAZAWA;
|
||||||
std::map<EnemyID, EnemyData>enemyData;
|
std::map<EnemyID, EnemyData>enemyData;
|
||||||
std::map<PowerupType, Pixel>powerupColorData;
|
std::map<PowerupType, PowerupData>powerupData;
|
||||||
std::vector<Enemy>enemies;
|
std::vector<Enemy>enemies;
|
||||||
std::vector<Powerup>powerups;
|
std::vector<Powerup>powerups;
|
||||||
private:
|
private:
|
||||||
@ -281,6 +286,7 @@ class FaceBall : public PixelGameEngine
|
|||||||
int lives = 3;
|
int lives = 3;
|
||||||
double gameTimer = 0;
|
double gameTimer = 0;
|
||||||
int lastPowerupCollidedWith = -1;
|
int lastPowerupCollidedWith = -1;
|
||||||
|
std::string hudDisplayText = "";
|
||||||
|
|
||||||
mat4x4 matProj;
|
mat4x4 matProj;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user