This repository has been archived on 2020-04-21. You can view files and clone it, but cannot push or open issues or pull requests.
ludum-dare-46/docs/assets/js/player/lifeFunctions.js
2020-04-18 06:02:20 -04:00

39 lines
667 B
JavaScript

let breath = 180;
let fullBreathTimer = 0;
let heartRate = 60;
let heartBeat = false;
function updateLife() {
if(keyDown[k.z]) {
breathe();
} else {
breath--;
}
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;
}
};
function heartbeat() {
heartBeat = true;
};