Merge pull request #7 from rsninja722/blood-pressure
Added blood pressure system
This commit is contained in:
commit
44851e047a
@ -80,11 +80,18 @@ function heartBeatUI(x, y, width, height){
|
|||||||
//Backdrop
|
//Backdrop
|
||||||
rect(x+width/2,y+height/2,width,height,"black");
|
rect(x+width/2,y+height/2,width,height,"black");
|
||||||
|
|
||||||
|
//Pressure Meter
|
||||||
|
rect(x+width-8,y+height/2,16,height,"red");
|
||||||
|
rect(x+width-8,y+height/2,16,height/2,"yellow");
|
||||||
|
rect(x+width-8,y+height/2,16,height/6,"green");
|
||||||
|
let pressureHeight = Math.max(Math.min(y+height-(pressure/constants.lifeFuncs.cardio.optimalPressure*height/2),y+height),y);
|
||||||
|
line(x+width-16, pressureHeight,x+width,pressureHeight, 2,"black")
|
||||||
|
|
||||||
//Graph
|
//Graph
|
||||||
for (let index = 0; index < heartBeatHistory.length; index++) {
|
for (let index = 0; index < heartBeatHistory.length; index++) {
|
||||||
const qrsValueAtPosition = heartBeatHistory[index];
|
const qrsValueAtPosition = heartBeatHistory[index];
|
||||||
const qrsValueAtNextPosition = heartBeatHistory[index+1];
|
const qrsValueAtNextPosition = heartBeatHistory[index+1];
|
||||||
line(x+(index*width/heartBeatHistory.length), y+(2*height/3)+(qrsValueAtPosition*width/heartBeatHistory.length), x+((index+1)*width/heartBeatHistory.length), y+(2*height/3)+(qrsValueAtNextPosition*width/heartBeatHistory.length),Math.min(3,Math.max(3/beatTimeElapsed,1)), "red");
|
line(x+(index*(width-16)/heartBeatHistory.length), y+(2*height/3)+(qrsValueAtPosition*(width-16)/heartBeatHistory.length), x+((index+1)*(width-16)/heartBeatHistory.length), y+(2*height/3)+(qrsValueAtNextPosition*(width-16)/heartBeatHistory.length),Math.min(3,Math.max(3/beatTimeElapsed,1)), "red");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,12 @@ var constants = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
lifeFuncs:{
|
lifeFuncs:{
|
||||||
breath:{
|
breath:{
|
||||||
fullBreath: 200
|
fullBreath: 200
|
||||||
}
|
},
|
||||||
|
cardio:{
|
||||||
|
optimalPressure: 50
|
||||||
|
}
|
||||||
},
|
},
|
||||||
legs:{
|
legs:{
|
||||||
size:{
|
size:{
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
let breath = 180;
|
let breath = 180;
|
||||||
let fullBreathTimer = 0;
|
let fullBreathTimer = 0;
|
||||||
let noBreathTimer = 0;
|
let noBreathTimer = 0;
|
||||||
let heartRate = 60;
|
let pressure = 50;
|
||||||
|
|
||||||
let heartBeat = false;
|
let heartBeat = false;
|
||||||
|
|
||||||
@ -17,11 +17,11 @@ let currentBreathMode = breathMode.exhale;
|
|||||||
|
|
||||||
function updateLife() {
|
function updateLife() {
|
||||||
|
|
||||||
if(keyDown[k.UP]) {
|
if(keyDown[k.w]) {
|
||||||
if(breath === 0) currentBreathMode = breathMode.inhale;
|
if(breath === 0) currentBreathMode = breathMode.inhale;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keyDown[k.DOWN]) {
|
if(keyDown[k.s]) {
|
||||||
if(breath === constants.lifeFuncs.breath.fullBreath) currentBreathMode = breathMode.exhale;
|
if(breath === constants.lifeFuncs.breath.fullBreath) currentBreathMode = breathMode.exhale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +30,11 @@ function updateLife() {
|
|||||||
if(keyPress[k.x]) {
|
if(keyPress[k.x]) {
|
||||||
heartbeat();
|
heartbeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pressure-=0.25;
|
||||||
|
if(pressure<=0){
|
||||||
|
pressure = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function breathe() {
|
function breathe() {
|
||||||
@ -39,7 +44,7 @@ function breathe() {
|
|||||||
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 >= 180) {
|
if(fullBreathTimer >= 600) {
|
||||||
//cough and lose breath or something
|
//cough and lose breath or something
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -47,11 +52,11 @@ function breathe() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case breathMode.exhale:
|
case breathMode.exhale:
|
||||||
breath -= 1;
|
breath -= 2;
|
||||||
if(breath <= 0) {
|
if(breath <= 0) {
|
||||||
breath = 0;
|
breath = 0;
|
||||||
noBreathTimer++;
|
noBreathTimer++;
|
||||||
if(noBreathTimer >= 180) {
|
if(noBreathTimer >= 300) {
|
||||||
//cough and lose breath or something
|
//cough and lose breath or something
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -62,5 +67,9 @@ function breathe() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function heartbeat() {
|
function heartbeat() {
|
||||||
|
pressure+=10;
|
||||||
|
if(pressure>=100){
|
||||||
|
pressure = 100;
|
||||||
|
}
|
||||||
heartBeat = true;
|
heartBeat = true;
|
||||||
};
|
};
|
Reference in New Issue
Block a user