From 9c4aa1af388fc12d023c7348c5331cf26c14d273 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 19:15:41 -0700 Subject: [PATCH 01/13] Add and Update a High Score --- game/src/hud.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/game/src/hud.js b/game/src/hud.js index a83d683..fbaeba8 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -1,5 +1,6 @@ var score = 0; var scoreText; +var highScore = 0; var createHud = function() { var hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); @@ -21,6 +22,9 @@ var createHud = function() { var updateScoreText = function() { scoreText.text = "Score: " + score; + if(score > highScore){ + highScore = score; + } } var resetScore = function() { From 040436dcba604d106f45c74813f05addcd4aed1e Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 20:38:08 -0700 Subject: [PATCH 02/13] High Score Text During Gameplay --- game/src/hud.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/game/src/hud.js b/game/src/hud.js index fbaeba8..859e362 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -15,6 +15,16 @@ var createHud = function() { scoreText.width = .5; scoreText.height = .15; + // Create a High Score Text Block + highScoreText2 = new BABYLON.GUI.TextBlock(); + highScoreText2.fontFamily = "Helvetica, sans-serif"; + highScoreText2.color = "white"; + highScoreText2.fontSize = 48; + highScoreText2.verticalAlignment = BABYLON.GUI.TextBlock.VERTICAL_ALIGNMENT_TOP; + highScoreText2.horizontalAlignment = BABYLON.GUI.TextBlock.HORIZONTAL_ALIGNMENT_LEFT; + highScoreText2.width = .5; + highScoreText2.height = .15; + updateScoreText(); hudTexture.addControl(scoreText); @@ -25,6 +35,7 @@ var updateScoreText = function() { if(score > highScore){ highScore = score; } + highScoreText2.text = "High Score: " + highScore; } var resetScore = function() { From 17f838c477dfede689378d68074872c3f4b0d117 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:05:03 -0700 Subject: [PATCH 03/13] Site --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21858aa..8320103 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # The Flying Cube Game! - +[![Netlify Status](https://api.netlify.com/api/v1/badges/4459e5bd-f0a5-4b06-8317-683bf91fc9c7/deploy-status)](https://app.netlify.com/sites/cubeflyer-m/deploys) Hi! This project is intended to help introduce you to open source! It's a javascript based 3D game built with [Babylon.JS](https://github.com/BabylonJS) that lets you fly a Cube through a set of obstacles. From c41387068ab86dd1945b86ffc7f599fd4a6ce3c9 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:05:51 -0700 Subject: [PATCH 04/13] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 8320103..75c5a87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ # The Flying Cube Game! -[![Netlify Status](https://api.netlify.com/api/v1/badges/4459e5bd-f0a5-4b06-8317-683bf91fc9c7/deploy-status)](https://app.netlify.com/sites/cubeflyer-m/deploys) Hi! This project is intended to help introduce you to open source! It's a javascript based 3D game built with [Babylon.JS](https://github.com/BabylonJS) that lets you fly a Cube through a set of obstacles. From a2c9a1c072d285277406913070c617ef85df724b Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:18:11 -0700 Subject: [PATCH 05/13] High Score Display --- game/src/mainmenu.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/game/src/mainmenu.js b/game/src/mainmenu.js index e66874f..300dc64 100644 --- a/game/src/mainmenu.js +++ b/game/src/mainmenu.js @@ -119,6 +119,16 @@ class MainMenu extends GameObject { this.instructionsText.horizontalAlignment = BABYLON.GUI.TextBlock.HORIZONTAL_ALIGNMENT_CENTER; this.instructionsText.width = .5; this.instructionsText.height = .9; + + this.highScoreText = new BABYLON.GUI.TextBlock(); + this.highScoreText.text = highScore; + this.highScoreText.fontFamily = "Impact"; + this.highScoreText.color = "white"; + this.highScoreText.fontSize = 28; + this.highScoreText.verticalAlignment = BABYLON.GUI.TextBlock.VERTICAL_ALIGNMENT_TOP; + this.highScoreText.horizontalAlignment = BABYLON.GUI.TextBlock.HORIZONTAL_ALIGNMENT_CENTER; + this.highScoreText.width = .5; + this.highScoreText.height = .8; this.hudTexture.addControl(this.welcomeText); this.hudTexture.addControl(this.greetingText); @@ -135,4 +145,4 @@ class MainMenu extends GameObject { var mainMenu = new MainMenu(); createObject(mainMenu); -mainMenu.visible = true; \ No newline at end of file +mainMenu.visible = true; From 65be79a25d8cdb1b7993c1972ed8c5c8bec6a92a Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:20:27 -0700 Subject: [PATCH 06/13] Repair Score Text --- game/src/hud.js | 1 + 1 file changed, 1 insertion(+) diff --git a/game/src/hud.js b/game/src/hud.js index 543c96e..d352d4d 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -1,5 +1,6 @@ var score = 0; var scoreText; +var highScoreText2; var highScore = 0; var createHud = function() { From 177354d55702c49ce2499e484bf7ebf9b4ee5fa9 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:23:43 -0700 Subject: [PATCH 07/13] Add Score Text Controls --- game/src/mainmenu.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/game/src/mainmenu.js b/game/src/mainmenu.js index 300dc64..e7f02fa 100644 --- a/game/src/mainmenu.js +++ b/game/src/mainmenu.js @@ -133,6 +133,7 @@ class MainMenu extends GameObject { this.hudTexture.addControl(this.welcomeText); this.hudTexture.addControl(this.greetingText); this.hudTexture.addControl(this.instructionsText); + this.hudTexture.addControl(this.highScoreText); } @@ -140,6 +141,7 @@ class MainMenu extends GameObject { this.hudTexture.removeControl(this.welcomeText); this.hudTexture.removeControl(this.greetingText); this.hudTexture.removeControl(this.instructionsText); + this.hudTexture.addControl(this.highScoreText); } } From 57bb148a57ee71d820d26be91f8646eb2fd908e2 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:25:26 -0700 Subject: [PATCH 08/13] Hide and Unhide the High Score Text --- game/src/hud.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/game/src/hud.js b/game/src/hud.js index d352d4d..33892f2 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -29,6 +29,7 @@ var createHud = function() { updateScoreText(); hudTexture.addControl(scoreText); + } var updateScoreText = function() { @@ -37,12 +38,16 @@ var updateScoreText = function() { highScore = score; } highScoreText2.text = "High Score: " + highScore; + + hudTexture.addControl(highScoreText2); } var resetScore = function() { console.log("Score reset at: " + score); score = 0; updateScoreText(); + + hudTexture.removeControl(highScoreText2); } var addScore = function(points) { From 16551ae12fd68e364a84b17906571a1a09d9cd93 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:45:02 -0700 Subject: [PATCH 09/13] Delete README.md --- README.md | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 75c5a87..0000000 --- a/README.md +++ /dev/null @@ -1,23 +0,0 @@ -# The Flying Cube Game! -Hi! - -This project is intended to help introduce you to open source! It's a javascript based 3D game built with [Babylon.JS](https://github.com/BabylonJS) that lets you fly a Cube through a set of obstacles. - -The entire project can be run by opening [`game/index.html`](game/index.html) in a browser. All of the 3rd party dependencies like Babylon are using a CDN so you do not need Node or a local developer environment. You can always play the current version of the game at flying-cube-game.netlify.app and if you create PR's against the project you'll be able to play your changes using a special link. - -New PR's are welcome and we've created a series of [Issues](https://github.com/runewake2/CubeFlyer/issues) you can pick up to get started. We're always looking for new Greetings in the game (shown under the game title on the main menu) and you're welcome to contribute your own - there's more info about that in [Issue #25: Add More Greetings](https://github.com/runewake2/CubeFlyer/issues/25). - -*** - -If you're new to contributing you can get started by forking this repository into your own GitHub account or clicking the edit (pencil ✏️) button next to the file you want to change. Make the changes in your own repository and test them, then submit a Pull Request and link the issue you are contributing towards. - -If you would like to submit a new feature or fix a bug that isn't listed consider [Submitting an Issue](https://github.com/runewake2/CubeFlyer/issues/new/choose) first so we can track the change! - -If you're new to Babylon JS that's fine to! Here are some helpful links to help you get started and remember you can always test your changes in your own branch *or* in the Pull Request first. Babylon runs in your browser and this game should work on your Phone, Tablet or PC - you can make and test your changes from any of those devices! If something doesn't work you can enter the developer mode of your browser (F12 on Edge or Chrome) and explore the errors in the console. This developer mode also lets you insert breakpoints if you want to debug further. - -* The [Babylon.JS Playground](https://playground.babylonjs.com/) will let you explore different community samples to learn how Babylon works! -* The [Babylon.JS API](https://doc.babylonjs.com/typedoc/modules/BABYLON) has documentation that can help you understand the API. - -We've also provided a file that should support launching from VS Code that will allow you to integrate your debugging experience there as well as a [devcontainer](https://code.visualstudio.com/docs/remote/create-dev-container) you can use to develop in if you choose with some recommended extensions pre-installed. - -This project is intended as a sandbox for you to learn about GitHub and contributing to Open Source. We're accepting most changes in support of that! From 45d39e485c5db58705c1c983ee942f85aa200cf7 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sat, 13 Aug 2022 21:49:17 -0700 Subject: [PATCH 10/13] Create README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..21858aa --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# The Flying Cube Game! + +Hi! + +This project is intended to help introduce you to open source! It's a javascript based 3D game built with [Babylon.JS](https://github.com/BabylonJS) that lets you fly a Cube through a set of obstacles. + +The entire project can be run by opening [`game/index.html`](game/index.html) in a browser. All of the 3rd party dependencies like Babylon are using a CDN so you do not need Node or a local developer environment. You can always play the current version of the game at flying-cube-game.netlify.app and if you create PR's against the project you'll be able to play your changes using a special link. + +New PR's are welcome and we've created a series of [Issues](https://github.com/runewake2/CubeFlyer/issues) you can pick up to get started. We're always looking for new Greetings in the game (shown under the game title on the main menu) and you're welcome to contribute your own - there's more info about that in [Issue #25: Add More Greetings](https://github.com/runewake2/CubeFlyer/issues/25). + +*** + +If you're new to contributing you can get started by forking this repository into your own GitHub account or clicking the edit (pencil ✏️) button next to the file you want to change. Make the changes in your own repository and test them, then submit a Pull Request and link the issue you are contributing towards. + +If you would like to submit a new feature or fix a bug that isn't listed consider [Submitting an Issue](https://github.com/runewake2/CubeFlyer/issues/new/choose) first so we can track the change! + +If you're new to Babylon JS that's fine to! Here are some helpful links to help you get started and remember you can always test your changes in your own branch *or* in the Pull Request first. Babylon runs in your browser and this game should work on your Phone, Tablet or PC - you can make and test your changes from any of those devices! If something doesn't work you can enter the developer mode of your browser (F12 on Edge or Chrome) and explore the errors in the console. This developer mode also lets you insert breakpoints if you want to debug further. + +* The [Babylon.JS Playground](https://playground.babylonjs.com/) will let you explore different community samples to learn how Babylon works! +* The [Babylon.JS API](https://doc.babylonjs.com/typedoc/modules/BABYLON) has documentation that can help you understand the API. + +We've also provided a file that should support launching from VS Code that will allow you to integrate your debugging experience there as well as a [devcontainer](https://code.visualstudio.com/docs/remote/create-dev-container) you can use to develop in if you choose with some recommended extensions pre-installed. + +This project is intended as a sandbox for you to learn about GitHub and contributing to Open Source. We're accepting most changes in support of that! From 402355d369439ddd1ced623bd9c40ce12e33163d Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sun, 14 Aug 2022 11:33:59 -0700 Subject: [PATCH 11/13] Change Scope of hudTexture --- game/src/hud.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/game/src/hud.js b/game/src/hud.js index 33892f2..0006709 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -2,9 +2,10 @@ var score = 0; var scoreText; var highScoreText2; var highScore = 0; +var hudTexture; var createHud = function() { - var hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); + hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); // Create a Text Block that can display the current score scoreText = new BABYLON.GUI.TextBlock(); From 9f9d2fc12ae36e8d8445f4b8059502fbcd16faab Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sun, 14 Aug 2022 21:35:49 -0700 Subject: [PATCH 12/13] Update the HUD High Score Text Update the HUD High Score Text to only display the high score text once when the score is first updated. --- game/src/hud.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/game/src/hud.js b/game/src/hud.js index 0006709..f703e44 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -3,6 +3,7 @@ var scoreText; var highScoreText2; var highScore = 0; var hudTexture; +var highScoreDisplayed = false; var createHud = function() { hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); @@ -40,7 +41,12 @@ var updateScoreText = function() { } highScoreText2.text = "High Score: " + highScore; - hudTexture.addControl(highScoreText2); + + if(!highScoreDisplayed){ + hudTexture.addControl(highScoreText2); + highScoreDisplayed = true; + } + } var resetScore = function() { @@ -49,6 +55,7 @@ var resetScore = function() { updateScoreText(); hudTexture.removeControl(highScoreText2); + highScoreDisplayed = false; } var addScore = function(points) { From 4b58f2a6c159b8d97427dbff120192d11829b436 Mon Sep 17 00:00:00 2001 From: Max <76268730+SpamMusubi153@users.noreply.github.com> Date: Sun, 14 Aug 2022 21:50:22 -0700 Subject: [PATCH 13/13] Remove Extraneous Variables --- game/src/hud.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/game/src/hud.js b/game/src/hud.js index f703e44..d389e91 100644 --- a/game/src/hud.js +++ b/game/src/hud.js @@ -3,7 +3,6 @@ var scoreText; var highScoreText2; var highScore = 0; var hudTexture; -var highScoreDisplayed = false; var createHud = function() { hudTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); @@ -31,6 +30,7 @@ var createHud = function() { updateScoreText(); hudTexture.addControl(scoreText); + hudTexture.addControl(highScoreText2); } @@ -38,14 +38,9 @@ var updateScoreText = function() { scoreText.text = "Score: " + score; if(score > highScore){ highScore = score; + highScoreText2.text = "High Score: " + highScore; } - highScoreText2.text = "High Score: " + highScore; - - if(!highScoreDisplayed){ - hudTexture.addControl(highScoreText2); - highScoreDisplayed = true; - } } @@ -53,9 +48,7 @@ var resetScore = function() { console.log("Score reset at: " + score); score = 0; updateScoreText(); - hudTexture.removeControl(highScoreText2); - highScoreDisplayed = false; } var addScore = function(points) {