Skip to content

Commit 5871156

Browse files
author
eros.dipede
committed
Fix spending on towers, enhance post game screens
1 parent dd37a45 commit 5871156

File tree

9 files changed

+270
-251
lines changed

9 files changed

+270
-251
lines changed

TextureDemo/TextureDemo/Castle.cpp

Lines changed: 232 additions & 222 deletions
Large diffs are not rendered by default.

TextureDemo/TextureDemo/Castle.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class Castle :
5959
std::vector<GLuint> projectileTextures;
6060
bool playerControlled;
6161
double health,
62-
funds = 100;
62+
funds = 100,
63+
t1Cost = 200,
64+
t2Cost = 250,
65+
t3Cost = 150;
6366
};
6467

Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

TextureDemo/TextureDemo/Graph.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ Node& Graph::getNode(int id) {
168168
std::vector<glm::vec2> Graph::pathfind(glm::vec2 start, glm::vec2 end) {
169169
int startNodeId = getNodeIdFromCoords(start.x, start.y),
170170
endNodeId = getNodeIdFromCoords(end.x, end.y);
171-
std::cout << endNodeId << std::endl;
172171
//final path
173172
vector<glm::vec2> finalPath;
174173
//priority queue used in pathfinding.

TextureDemo/TextureDemo/Unit.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,6 @@ void Unit::update(double deltaTime, GameObject* enemyCastle)
9595
enemy = enem;
9696
break;
9797
}
98-
99-
dist = sqrt(pow(target.x - position.x, 2) + pow(target.y - position.y, 2));
100-
if (dist <= enemyDist)
101-
{
102-
std::cout << "ping" << std::endl;
103-
enemyNear = true;
104-
enemy = enemyCastle;
105-
break;
106-
}
10798
enemyNear = false;
10899
enemy = NULL;
109100
}

TextureDemo/TextureDemo/main.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,22 @@ int main(void){
216216

217217
Graph* graph = new Graph(68, 5, GameObject(glm::vec3(0.0f), tex[7], size));
218218

219-
vector<Castle*> castles = { new Castle(0,glm::vec3(6,0.5,0),glm::vec3(-2,2,2),tex[1],size,projectileTextures,castleTwoUnitTextures,castleTwoTowerTextures),
219+
vector<Castle*> castles = { new Castle(0,glm::vec3(6,0.5,0),glm::vec3(-2,2,2),tex[1],size,projectileTextures,castleTwoUnitTextures,castleTwoTowerTextures),
220220
new Castle(1,glm::vec3(-6,0.5,0),glm::vec3(2,2,2),tex[0],size,projectileTextures,castleOneUnitTextures,castleOneTowerTextures) };
221221

222222
// Run the main loop
223223
double lastTime = glfwGetTime();
224224
double pauseTimer = glfwGetTime();
225+
double toMainTimer = glfwGetTime();
225226
double pauseDelay = 0.3;
227+
double toMainDelay = 0.3;
226228
Camera* camera = new Camera(shader, window, glm::vec2(window_width_g, window_height_g));
227229
Board* board = new Board(camera, &particleSystem, graph, castles);
228230

229231
static bool playtoggle = false;
230232
static int startState = 0;
231233

232-
GameObject pause(glm::vec3(0.0f, 0.0f, 0.0f), tex[22], 200);
234+
GameObject pause = GameObject(glm::vec3(0.0f, 0.0f, 0.0f), tex[22], 200);
233235
GameObject startscreen(glm::vec3(0.0f, 0.0f, 0.0f), tex[23], 200);
234236

235237
while (!glfwWindowShouldClose(window.getWindow()))
@@ -261,7 +263,17 @@ int main(void){
261263
renderText(std::string("Press SPACE to Start"), textShader, glm::vec3(1.0), glm::vec3(-0.65f, -0.65f, 0.07f), 0.1);
262264
shader.enable();
263265

264-
if (glfwGetKey(window.getWindow(), GLFW_KEY_SPACE) == GLFW_PRESS) startState = 1;
266+
if (glfwGetKey(window.getWindow(), GLFW_KEY_SPACE) == GLFW_PRESS) {
267+
if ((glfwGetTime() - toMainTimer) > toMainDelay)
268+
{
269+
toMainTimer = glfwGetTime();
270+
startState = 1;
271+
lastTime = glfwGetTime();
272+
castles = { new Castle(0,glm::vec3(6,0.5,0),glm::vec3(-2,2,2),tex[1],size,projectileTextures,castleTwoUnitTextures,castleTwoTowerTextures),
273+
new Castle(1,glm::vec3(-6,0.5,0),glm::vec3(2,2,2),tex[0],size,projectileTextures,castleOneUnitTextures,castleOneTowerTextures) };
274+
board = new Board(camera, &particleSystem, graph, castles);
275+
}
276+
}
265277
break;
266278
}
267279
case 1:
@@ -340,32 +352,36 @@ int main(void){
340352
particleSystem.enable();
341353
particleSystem.setAttributes();
342354
particleSystem.setUniformMat4("viewMatrix", camera->getViewMatrix());
355+
356+
for (int i = 0; i < board->getCastles().size(); i++)
357+
{
358+
if (board->getCastles().at(0)->getHealth() <= 0)
359+
{
360+
startState = 3;
361+
toMainTimer = glfwGetTime();
362+
}
363+
else if (board->getCastles().at(1)->getHealth() <= 0)
364+
{
365+
startState = 2;
366+
toMainTimer = glfwGetTime();
367+
}
368+
}
343369
break;
344370
}
345371
case 2:
346372
camera->update(0);
347-
renderText(std::string("DEFEAT"), textShader, glm::vec3(1.0), glm::vec3(-0.60f, 0.65f, 0.1f), 0.12f);
373+
renderText(std::string("Kingdom Seige"), textShader, glm::vec3(1.0), glm::vec3(-0.60f, 0.65f, 0.1f), 0.12f);
374+
renderText(std::string("DEFEAT"), textShader, glm::vec3(1.0), glm::vec3(-0.22f, 0.45f, 0.1f), 0.12f);
348375
shader.enable();
349376
break;
350377
case 3:
351378
camera->update(0);
352-
renderText(std::string("VICTORY"), textShader, glm::vec3(1.0), glm::vec3(-0.60f, 0.65f, 0.1f), 0.12f);
353-
shader.enable();
379+
renderText(std::string("Kingdom Seige"), textShader, glm::vec3(1.0), glm::vec3(-0.60f, 0.65f, 0.1f), 0.12f);
380+
renderText(std::string("VICTORY"), textShader, glm::vec3(1.0), glm::vec3(-0.3f, 0.45f, 0.1f), 0.12f);
381+
shader.enable();
354382
break;
355383
}
356384

357-
for (int i = 0; i < board->getCastles().size(); i++)
358-
{
359-
if (board->getCastles().at(0)->getHealth() <= 0)
360-
{
361-
startState = 2;
362-
}
363-
else if (board->getCastles().at(1)->getHealth() <= 0)
364-
{
365-
startState = 3;
366-
}
367-
}
368-
369385
// Update other events like input handling
370386
glfwPollEvents();
371387

0 commit comments

Comments
 (0)