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
rsninja722 0b4a1cdb92 day1
2020-04-18 00:15:33 -04:00

44 lines
658 B
JavaScript

var breath = 180;
var fullBreathTimer = 0;
var heartRate = 60;
var timeSinceLastBeat = 0;
function updateLife() {
if(keyDown[k.Z]) {
breathe();
} else {
breath--;
}
if(keyPress[k.X]) {
heartbeat();
} else {
timeSinceLastBeat++;
}
};
function breathe() {
breath += 5;
if(breath >= 200) {
breath = 200;
fullBreathTimer++;
if(fullBreathTimer >= 60) {
//cough and lose breath or something
}
} else {
fullBreathTimer = 0;
}
};
function heartbeat() {
timeSinceLastBeat = 0;
};