All powerup capsule types working.

linux_template
sigonasr2 2 years ago
parent f2b89a6d01
commit 447881a044
  1. 16
      Faceball2030/Editor.h
  2. 2
      Faceball2030/assets/Powerup2.mtl
  3. BIN
      Faceball2030/assets/Powerup2.wings
  4. 20
      Faceball2030/assets/map/map1.map
  5. BIN
      Faceball2030/assets/octahedron3_auv2.png
  6. 25
      Faceball2030/main.cpp
  7. 1
      Faceball2030/main.h

@ -16,14 +16,14 @@ enum EnemyID {
ISHOOT2, ISHOOT2,
SHOOTME_ARMOR, SHOOTME_ARMOR,
SONAR, SONAR,
COIN = 56, POWERUP_ARMOR = 56,
POWERUP_ARMOR = 57, POWERUP_SPEED = 57,
POWERUP_SPEED = 58, POWERUP_SHOT = 58,
POWERUP_SHOT = 59, SPECIAL_STOP = 59,
SPECIAL_CAMO = 60, SPECIAL_SHIELD = 60,
SPECIAL_STOP = 61, SPECIAL_CAMO = 61,
SPECIAL_SHIELD = 62, AREA_MAP = 62,
AREA_MAP = 63, COIN = 63,
}; };
/* /*

@ -7,5 +7,5 @@ Kd 1.0 1.0 1.0
Ka 0.0 0.0 0.0 Ka 0.0 0.0 0.0
Ks 0.19 0.19 0.19 Ks 0.19 0.19 0.19
Ke 0.0 0.0 0.0 Ke 0.0 0.0 0.0
map_Kd octahedron3_auv.png map_Kd octahedron3_auv2.png

@ -1,38 +1,44 @@
6 7
6 6
32777 32777
32778 32778
8202 8202
8728 8728
24584 24584
8200
8204 8204
40965 40965
57753 57753
24584 24584
25104 25104
8192 8192
16788 16784
8196
8197 8197
8193 8193
8192 8192
8194 8194
8194 8192
15632
8196 8196
8193 8193
2 2
25492 25492
8201 8201
8204 16144
8197 8192
15508
8197 8197
8351 8351
8197 8197
8195 8195
8198 8198
277 273
15764
8195 8195
8602 8602
8194 8194
8202 8202
8202 8202
8198 16018
15894

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

@ -163,7 +163,12 @@ 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) {
t.col[0] = powerupColorData[type];
t.col[1] = powerupColorData[type];
t.col[2] = powerupColorData[type];
}
powerups.push_back({ mesh,pos,0,type }); powerups.push_back({ mesh,pos,0,type });
} }
@ -198,9 +203,12 @@ void FaceBall::LoadLevel(int level)
mapFloor.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}},{WHITE,WHITE,WHITE}, floor_tex }); mapFloor.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}},{WHITE,WHITE,WHITE}, floor_tex });
mapFloor.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}},{WHITE,WHITE,WHITE}, floor_tex }); mapFloor.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}},{WHITE,WHITE,WHITE}, floor_tex });
EnemyID id = mapData[y][x].enemyId; EnemyID id = mapData[y][x].enemyId;
if (id>=SHOOTME&& id < COIN) { if (id>=SHOOTME&& id < POWERUP_ARMOR) {
enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir-1)*PI/2,enemyData[id].radius}); enemies.push_back({ id,vec3d{x + 0.5f,0,y + 0.5f},((int)mapData[y][x].facingDir-1)*PI/2,enemyData[id].radius});
} }
if (id >= POWERUP_ARMOR) {
SpawnPowerup(PowerupType((int)id-55), vec3d{ x + 0.5f,0,y + 0.5f });
}
if (id == EXIT) { if (id == EXIT) {
exitCoords = { x,y }; exitCoords = { x,y };
} }
@ -846,9 +854,9 @@ void FaceBall::RenderPowerupMesh(mat4x4& matView, std::vector<Triangle>& vecTria
triTransformed.uv[0] = tri.uv[0]; triTransformed.uv[0] = tri.uv[0];
triTransformed.uv[1] = tri.uv[1]; triTransformed.uv[1] = tri.uv[1];
triTransformed.uv[2] = tri.uv[2]; triTransformed.uv[2] = tri.uv[2];
triTransformed.col[0] = tri.col[0]; triTransformed.col[0] = tri.col[0] * p.colorCycle;
triTransformed.col[1] = tri.col[1]; triTransformed.col[1] = tri.col[1] * p.colorCycle;
triTransformed.col[2] = tri.col[2]; triTransformed.col[2] = tri.col[2] * p.colorCycle;
triTransformed.tex = tri.tex; triTransformed.tex = tri.tex;
vec3d normal, line1, line2; vec3d normal, line1, line2;
@ -1135,14 +1143,14 @@ void FaceBall::RenderWorld() {
RenderMesh(matView, vecTrianglesToRaster, enemy); RenderMesh(matView, vecTrianglesToRaster, enemy);
} }
} }
for (auto& powerup : powerups) {
RenderPowerupMesh(matView, vecTrianglesToRaster, powerup);
}
for (auto& bullet : bullets) { for (auto& bullet : bullets) {
RenderBulletMesh(matView, vecTrianglesToRasterTranslucent, bullet); RenderBulletMesh(matView, vecTrianglesToRasterTranslucent, bullet);
} }
RenderMesh(matView, vecTrianglesToRaster, walls); RenderMesh(matView, vecTrianglesToRaster, walls);
RenderMesh(matView, vecTrianglesToRasterTranslucent, walls, true); RenderMesh(matView, vecTrianglesToRasterTranslucent, walls, true);
for (auto& powerup : powerups) {
RenderPowerupMesh(matView, vecTrianglesToRasterTranslucent, powerup);
}
//std::sort(vecTrianglesToRaster.begin(),vecTrianglesToRaster.end(),[](triangle&t1,triangle&t2){return (t1.p[0].z+t1.p[1].z+t1.p[2].z)/3.0f>(t2.p[0].z+t2.p[1].z+t2.p[2].z)/3.0f;}); //std::sort(vecTrianglesToRaster.begin(),vecTrianglesToRaster.end(),[](triangle&t1,triangle&t2){return (t1.p[0].z+t1.p[1].z+t1.p[2].z)/3.0f>(t2.p[0].z+t2.p[1].z+t2.p[2].z)/3.0f;});
ClearBuffer(BLACK, true); ClearBuffer(BLACK, true);
@ -1531,6 +1539,7 @@ bool FaceBall::OnUserCreate()
mapFloor.texture = floor_tex; mapFloor.texture = floor_tex;
InitializeEnemyData(); InitializeEnemyData();
InitializePowerupColors();
LoadLevel(1); LoadLevel(1);

@ -366,7 +366,6 @@ class FaceBall : public PixelGameEngine
bool OnUserUpdate(float fElapsedTime) override; bool OnUserUpdate(float fElapsedTime) override;
void OnTextEntryComplete(const std::string& sText) override; void OnTextEntryComplete(const std::string& sText) override;
void InitializeEnemyData(); void InitializeEnemyData();
void InitializeBulletColors();
void InitializePowerupColors(); void InitializePowerupColors();
void LoadLevel(int level); void LoadLevel(int level);
void RenderBulletMesh(mat4x4& matView, std::vector<Triangle>& vecTrianglesToRaster, Bullet& b,bool translucent=true); void RenderBulletMesh(mat4x4& matView, std::vector<Triangle>& vecTrianglesToRaster, Bullet& b,bool translucent=true);

Loading…
Cancel
Save