From 62fdfac2959b92fe5d99bd244b36a9fe1d975e86 Mon Sep 17 00:00:00 2001 From: g5-chappell <gareth2.chappell@live.uwe.ac.uk> Date: Sun, 23 Jan 2022 07:32:12 +0000 Subject: [PATCH] Update assignment.cpp --- assignment/assignment.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assignment/assignment.cpp b/assignment/assignment.cpp index a6e8f80..9fd4408 100644 --- a/assignment/assignment.cpp +++ b/assignment/assignment.cpp @@ -26,7 +26,7 @@ // their size. #include <stdlib.h> -// For randomly generating the orb location. +// For randomly generating the cube location. #include <cstring> // Import used to manipulate C++ output. @@ -90,8 +90,8 @@ public: int player_y = 64; // Player co-ordinates defaults - int orb_x = 256; - int orb_y = 256; + int cube_x = 256; + int cube_y = 256; // Cube co-ordinates defaults int player_score = 0; @@ -100,8 +100,8 @@ public: int time_remaining_seconds = 60; // 60 seconds per round, before score resets - bool player_takes_orb = false; - // If player has taken orb, then a new one will be spawned elsewhere. + bool player_takes_cube = false; + // If player has taken cube , then a new one will be spawned elsewhere. }; @@ -124,7 +124,7 @@ void MyApp::update() { // Function called per frame rendered. Updates the program as to what should be drawn in the frame, so it knows what to draw. time_remaining_seconds = time_remaining_seconds - 1; - // Every second, the remaining time in seconds is reduced by one second. + // Every second, the remaining time in seconds is reduced by one second. This remaining time will be drawn on screen by another function. if(time_remaining_seconds <= 0) // If the player runs out of time, reset their score to zero, and reset their time to sixty seconds. @@ -137,11 +137,11 @@ void MyApp::update() { break; } - if(player_x == orb_x && player_y == orb_y) + if(player_x == cube_x && player_y == cube_y) // If player is touching a red cube, increase their score. { player_score = player_score + 1; - player_takes_orb = true; + player_takes_cube = true; } else { @@ -151,8 +151,8 @@ void MyApp::update() { if(player_takes_orb == true) // If player has touched a red cube, change the cube's location. { - orb_x = rand() % 512 + 128; - orb_y = rand() % 512 + 128; + cube_x = rand() % 512 + 128; + cube_y = rand() % 512 + 128; player_takes_orb = false; } else -- GitLab