more betterer breathing
This commit is contained in:
parent
f3332786d3
commit
3b7efa3ebc
@ -32,8 +32,8 @@ function drawEndUI() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function respiratoryUI(x, y, width, height){
|
function respiratoryUI(x, y, width, height){
|
||||||
cartesianRect(x,y,width,height, "black");
|
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, "teal");
|
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)+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -1,37 +1,64 @@
|
|||||||
|
|
||||||
let breath = 180;
|
let breath = 180;
|
||||||
let fullBreathTimer = 0;
|
let fullBreathTimer = 0;
|
||||||
|
let noBreathTimer = 0;
|
||||||
let heartRate = 60;
|
let heartRate = 60;
|
||||||
|
|
||||||
let heartBeat = false;
|
let heartBeat = false;
|
||||||
|
|
||||||
|
var breathMode = {
|
||||||
|
inhale: 0,
|
||||||
|
exhale: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
let currentBreathMode = breathMode.exhale;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function updateLife() {
|
function updateLife() {
|
||||||
|
|
||||||
if(keyDown[k.z]) {
|
if(keyDown[k.UP]) {
|
||||||
breathe();
|
currentBreathMode = breathMode.inhale;
|
||||||
} else {
|
|
||||||
breath--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(keyDown[k.DOWN]) {
|
||||||
|
currentBreathMode = breathMode.exhale;
|
||||||
|
}
|
||||||
|
|
||||||
|
breathe();
|
||||||
|
|
||||||
if(keyPress[k.x]) {
|
if(keyPress[k.x]) {
|
||||||
heartbeat();
|
heartbeat();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function breathe() {
|
function breathe() {
|
||||||
|
switch (currentBreathMode) {
|
||||||
breath += 5;
|
case breathMode.inhale:
|
||||||
|
breath += 1;
|
||||||
if(breath >= constants.lifeFuncs.breath.fullBreath) {
|
if(breath >= constants.lifeFuncs.breath.fullBreath) {
|
||||||
breath = constants.lifeFuncs.breath.fullBreath;
|
breath = constants.lifeFuncs.breath.fullBreath;
|
||||||
fullBreathTimer++;
|
fullBreathTimer++;
|
||||||
if(fullBreathTimer >= 60) {
|
if(fullBreathTimer >= 180) {
|
||||||
//cough and lose breath or something
|
//cough and lose breath or something
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fullBreathTimer = 0;
|
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() {
|
function heartbeat() {
|
||||||
|
Reference in New Issue
Block a user