@@ -216,20 +216,22 @@ int main(void){
216
216
217
217
Graph* graph = new Graph (68 , 5 , GameObject (glm::vec3 (0 .0f ), tex[7 ], size));
218
218
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),
220
220
new Castle (1 ,glm::vec3 (-6 ,0.5 ,0 ),glm::vec3 (2 ,2 ,2 ),tex[0 ],size,projectileTextures,castleOneUnitTextures,castleOneTowerTextures) };
221
221
222
222
// Run the main loop
223
223
double lastTime = glfwGetTime ();
224
224
double pauseTimer = glfwGetTime ();
225
+ double toMainTimer = glfwGetTime ();
225
226
double pauseDelay = 0.3 ;
227
+ double toMainDelay = 0.3 ;
226
228
Camera* camera = new Camera (shader, window, glm::vec2 (window_width_g, window_height_g));
227
229
Board* board = new Board (camera, &particleSystem, graph, castles);
228
230
229
231
static bool playtoggle = false ;
230
232
static int startState = 0 ;
231
233
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 );
233
235
GameObject startscreen (glm::vec3 (0 .0f , 0 .0f , 0 .0f ), tex[23 ], 200 );
234
236
235
237
while (!glfwWindowShouldClose (window.getWindow ()))
@@ -261,7 +263,17 @@ int main(void){
261
263
renderText (std::string (" Press SPACE to Start" ), textShader, glm::vec3 (1.0 ), glm::vec3 (-0 .65f , -0 .65f , 0 .07f ), 0.1 );
262
264
shader.enable ();
263
265
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
+ }
265
277
break ;
266
278
}
267
279
case 1 :
@@ -340,32 +352,36 @@ int main(void){
340
352
particleSystem.enable ();
341
353
particleSystem.setAttributes ();
342
354
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
+ }
343
369
break ;
344
370
}
345
371
case 2 :
346
372
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 );
348
375
shader.enable ();
349
376
break ;
350
377
case 3 :
351
378
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 ();
354
382
break ;
355
383
}
356
384
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
-
369
385
// Update other events like input handling
370
386
glfwPollEvents ();
371
387
0 commit comments