From 047f870f49ccb36842e582ecf3304cbf6396e93b Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Sat, 18 Apr 2020 06:23:05 -0400 Subject: [PATCH 1/3] Backdrop --- docs/assets/js/UI/ui.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/assets/js/UI/ui.js b/docs/assets/js/UI/ui.js index 5350b2e..60c8aa9 100644 --- a/docs/assets/js/UI/ui.js +++ b/docs/assets/js/UI/ui.js @@ -9,6 +9,8 @@ function drawLevelTransitionUI() { // UI for playing function drawPlayingUI() { + cartesianRect(0,ch/3*2, cw, ch/3, "#333333") + //Heart Rate Monitor heartBeatUI(cw/4*3-8,ch/8*7-8,cw/4,ch/8); From 3b7efa3ebcb43b3a24ce9185e4997d3ce655c3ae Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Sat, 18 Apr 2020 07:53:29 -0400 Subject: [PATCH 2/3] more betterer breathing --- docs/assets/js/UI/ui.js | 4 +- docs/assets/js/player/lifeFunctions.js | 57 +++++++++++++++++++------- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/docs/assets/js/UI/ui.js b/docs/assets/js/UI/ui.js index 5350b2e..d2bf028 100644 --- a/docs/assets/js/UI/ui.js +++ b/docs/assets/js/UI/ui.js @@ -32,8 +32,8 @@ function drawEndUI() { */ function respiratoryUI(x, y, width, height){ - cartesianRect(x,y,width,height, "black"); - cartesianRect(x,y+(height-breath/constants.lifeFuncs.breath.fullBreath*height), width, breath/constants.lifeFuncs.breath.fullBreath*height, "teal"); + cartesianRect(x,y,width,height, "rgb("+noBreathTimer/180*255+","+0+","+0+")"); + cartesianRect(x,y+(height-breath/constants.lifeFuncs.breath.fullBreath*height), width, breath/constants.lifeFuncs.breath.fullBreath*height, "rgb("+255+","+(255-fullBreathTimer/180*255)+","+(255-fullBreathTimer/180*255)+")"); } /*** diff --git a/docs/assets/js/player/lifeFunctions.js b/docs/assets/js/player/lifeFunctions.js index 0cd075e..6557e2c 100644 --- a/docs/assets/js/player/lifeFunctions.js +++ b/docs/assets/js/player/lifeFunctions.js @@ -1,37 +1,64 @@ let breath = 180; let fullBreathTimer = 0; +let noBreathTimer = 0; let heartRate = 60; let heartBeat = false; +var breathMode = { + inhale: 0, + exhale: 1 +}; + +let currentBreathMode = breathMode.exhale; + + function updateLife() { - if(keyDown[k.z]) { - breathe(); - } else { - breath--; + if(keyDown[k.UP]) { + currentBreathMode = breathMode.inhale; } + if(keyDown[k.DOWN]) { + currentBreathMode = breathMode.exhale; + } + + breathe(); + if(keyPress[k.x]) { heartbeat(); } }; function breathe() { - - breath += 5; - if(breath >= constants.lifeFuncs.breath.fullBreath) { - breath = constants.lifeFuncs.breath.fullBreath; - fullBreathTimer++; - if(fullBreathTimer >= 60) { - //cough and lose breath or something - } - } else { - fullBreathTimer = 0; + switch (currentBreathMode) { + case breathMode.inhale: + breath += 1; + if(breath >= constants.lifeFuncs.breath.fullBreath) { + breath = constants.lifeFuncs.breath.fullBreath; + fullBreathTimer++; + if(fullBreathTimer >= 180) { + //cough and lose breath or something + } + } else { + fullBreathTimer = 0; + } + break; + case breathMode.exhale: + breath -= 1; + if(breath <= 0) { + breath = 0; + noBreathTimer++; + if(noBreathTimer >= 180) { + //cough and lose breath or something + } + } else { + noBreathTimer = 0; + } + break; } - }; function heartbeat() { From ece0d97199b93052ffd1b5e72b38812a4791bab0 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Sat, 18 Apr 2020 13:50:38 -0400 Subject: [PATCH 3/3] Breath interval limit --- docs/assets/js/player/lifeFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/assets/js/player/lifeFunctions.js b/docs/assets/js/player/lifeFunctions.js index 6557e2c..1df2f12 100644 --- a/docs/assets/js/player/lifeFunctions.js +++ b/docs/assets/js/player/lifeFunctions.js @@ -18,11 +18,11 @@ let currentBreathMode = breathMode.exhale; function updateLife() { if(keyDown[k.UP]) { - currentBreathMode = breathMode.inhale; + if(breath === 0) currentBreathMode = breathMode.inhale; } if(keyDown[k.DOWN]) { - currentBreathMode = breathMode.exhale; + if(breath === constants.lifeFuncs.breath.fullBreath) currentBreathMode = breathMode.exhale; } breathe();