Merge branch 'master' of github.com:rsninja722/LudumDare46
BIN
docs/assets/images/Capture.PNG
Normal file
After Width: | Height: | Size: 685 B |
BIN
docs/assets/images/blinkOverlay.png
Normal file
After Width: | Height: | Size: 470 KiB |
BIN
docs/assets/images/eye.png
Normal file
After Width: | Height: | Size: 381 B |
BIN
docs/assets/images/eyeDry.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
docs/assets/images/heartBack.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
docs/assets/images/heartCover.png
Normal file
After Width: | Height: | Size: 784 B |
BIN
docs/assets/images/tempIcon.png
Normal file
After Width: | Height: | Size: 189 B |
@ -2,9 +2,6 @@
|
|||||||
function drawTitleScreenUI() {
|
function drawTitleScreenUI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI for level transition
|
|
||||||
function drawLevelTransitionUI() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// UI for playing
|
// UI for playing
|
||||||
function drawPlayingUI() {
|
function drawPlayingUI() {
|
||||||
@ -16,6 +13,9 @@ function drawPlayingUI() {
|
|||||||
|
|
||||||
//Respiration Monitor
|
//Respiration Monitor
|
||||||
respiratoryUI(cw/8*5,ch/8*7-8, cw/16, ch/8);
|
respiratoryUI(cw/8*5,ch/8*7-8, cw/16, ch/8);
|
||||||
|
|
||||||
|
//Blink eye and overlay
|
||||||
|
blinkUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
//UI for pause screen
|
//UI for pause screen
|
||||||
@ -78,7 +78,16 @@ function heartBeatUI(x, y, width, height){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Backdrop
|
//Backdrop
|
||||||
rect(x+width/2,y+height/2,width,height,"black");
|
var BackdropColor;
|
||||||
|
if(pressure > 42 && pressure < 60) {
|
||||||
|
BackdropColor = "#0c2605";
|
||||||
|
} else if(pressure > 28 && pressure < 75) {
|
||||||
|
BackdropColor = "#2b2b06";
|
||||||
|
} else {
|
||||||
|
BackdropColor = "#260505";
|
||||||
|
}
|
||||||
|
rect(x+width/2,y+height/2,width,height,BackdropColor);
|
||||||
|
img(sprites.heartBack,cw-107,ch-46);
|
||||||
|
|
||||||
//Pressure Meter
|
//Pressure Meter
|
||||||
rect(x+width-8,y+height/2,16,height,"red");
|
rect(x+width-8,y+height/2,16,height,"red");
|
||||||
@ -93,6 +102,9 @@ function heartBeatUI(x, y, width, height){
|
|||||||
const qrsValueAtNextPosition = heartBeatHistory[index+1];
|
const qrsValueAtNextPosition = heartBeatHistory[index+1];
|
||||||
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");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cover
|
||||||
|
img(sprites.heartCover,cw-107,ch-46);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Determine next value to be added to the graph
|
//Determine next value to be added to the graph
|
||||||
@ -129,3 +141,21 @@ function pushNextBeatValue(){
|
|||||||
|
|
||||||
heartBeatHistory.push(nextBeatValue);
|
heartBeatHistory.push(nextBeatValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function blinkUI() {
|
||||||
|
// eye
|
||||||
|
img(sprites.eye,cw-350,ch-40,0,2,2);
|
||||||
|
var alpha = clamp(eyeDryness / constants.lifeFuncs.blink.dryTime,0,1);
|
||||||
|
curCtx.globalAlpha = alpha;
|
||||||
|
img(sprites.eyeDry,cw-350,ch-40,0,2,2);
|
||||||
|
|
||||||
|
// dry overlay
|
||||||
|
if(eyeDryness > constants.lifeFuncs.blink.dryTime) {
|
||||||
|
alpha = (eyeDryness - constants.lifeFuncs.blink.dryTime) / 350;
|
||||||
|
curCtx.globalAlpha = alpha;
|
||||||
|
img(sprites.blinkOverlay,cw/2,ch/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
curCtx.globalAlpha = 1;
|
||||||
|
}
|
@ -41,6 +41,9 @@ var constants = {
|
|||||||
},
|
},
|
||||||
cardio:{
|
cardio:{
|
||||||
optimalPressure: 50
|
optimalPressure: 50
|
||||||
|
},
|
||||||
|
blink: {
|
||||||
|
dryTime: 600
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
player:{
|
player:{
|
||||||
@ -53,7 +56,9 @@ var constants = {
|
|||||||
hip: {
|
hip: {
|
||||||
offset_x: 15,
|
offset_x: 15,
|
||||||
offset_y: 25
|
offset_y: 25
|
||||||
}
|
},
|
||||||
|
defaultX: 500,
|
||||||
|
defaultY: -70
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
@ -5,7 +5,12 @@ page_preloader.show(true);
|
|||||||
images = [
|
images = [
|
||||||
"assets/images/",
|
"assets/images/",
|
||||||
"level.png",
|
"level.png",
|
||||||
"level_2.png"
|
"level_2.png",
|
||||||
|
"heartCover.png",
|
||||||
|
"heartBack.png",
|
||||||
|
"blinkOverlay.png",
|
||||||
|
"eye.png",
|
||||||
|
"eyeDry.png"
|
||||||
];
|
];
|
||||||
|
|
||||||
audio = [
|
audio = [
|
||||||
@ -61,20 +66,28 @@ function draw() {
|
|||||||
|
|
||||||
// Handle game state
|
// Handle game state
|
||||||
switch (globalState) {
|
switch (globalState) {
|
||||||
|
|
||||||
// title screen
|
// title screen
|
||||||
case globalStates.titleScreen:
|
case globalStates.titleScreen:
|
||||||
drawTitleScreen();
|
drawTitleScreen();
|
||||||
break;
|
break;
|
||||||
// level transition
|
// level transition
|
||||||
case globalStates.levelTransition:
|
case globalStates.levelTransition:
|
||||||
|
handleTransition();
|
||||||
break;
|
break;
|
||||||
// playing
|
// playing
|
||||||
case globalStates.playing:
|
case globalStates.playing:
|
||||||
camera.zoom = 1;
|
if(!justBlinked) {
|
||||||
drawWorldBlocks();
|
|
||||||
imgIgnoreCutoff(sprites.level_2,0,0,0,4,4);
|
camera.zoom = 1;
|
||||||
player.draw();
|
drawWorldBlocks();
|
||||||
|
imgIgnoreCutoff(sprites.level_2,0,0,0,4,4);
|
||||||
|
player.draw();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
rect(-camera.x - difx + cw/2,-camera.y - dify + ch/2,cw,ch,"black");
|
||||||
|
justBlinked = false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// paused
|
// paused
|
||||||
case globalStates.paused:
|
case globalStates.paused:
|
||||||
|
@ -13,18 +13,19 @@ var breathMode = {
|
|||||||
|
|
||||||
let currentBreathMode = breathMode.exhale;
|
let currentBreathMode = breathMode.exhale;
|
||||||
|
|
||||||
|
let eyeDryness = 0;
|
||||||
|
let justBlinked = false;
|
||||||
|
|
||||||
function updateLife() {
|
function updateLife() {
|
||||||
|
|
||||||
if(keyDown[k.z]) {
|
if(keyDown[k.x]) {
|
||||||
if(breath === 0) currentBreathMode = breathMode.inhale;
|
if(breath === 0) currentBreathMode = breathMode.inhale;
|
||||||
else if(breath === constants.lifeFuncs.breath.fullBreath) currentBreathMode = breathMode.exhale;
|
else if(breath === constants.lifeFuncs.breath.fullBreath) currentBreathMode = breathMode.exhale;
|
||||||
}
|
}
|
||||||
|
|
||||||
breathe();
|
breathe();
|
||||||
|
|
||||||
if(keyPress[k.x]) {
|
if(keyPress[k.c]) {
|
||||||
heartbeat();
|
heartbeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,6 +33,12 @@ function updateLife() {
|
|||||||
if(pressure<=0){
|
if(pressure<=0){
|
||||||
pressure = 0;
|
pressure = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eyeDryness++;
|
||||||
|
|
||||||
|
if(keyPress[k.z]) {
|
||||||
|
blink();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function breathe() {
|
function breathe() {
|
||||||
@ -73,3 +80,8 @@ function heartbeat() {
|
|||||||
// Play the heartbeat sound
|
// Play the heartbeat sound
|
||||||
soundAssets.heartbeat.play();
|
soundAssets.heartbeat.play();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function blink() {
|
||||||
|
eyeDryness = 0;
|
||||||
|
justBlinked = true;
|
||||||
|
}
|
@ -4,10 +4,10 @@ class Player {
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
this.w = constants.player.width;
|
this.w = constants.player.width;
|
||||||
this.h = constants.player.height;
|
this.h = constants.player.height;
|
||||||
this.hipLeft = { x: this.x - constants.player.hip.offset_x, y: this.y + constants.player.hip.offset_y };
|
this.hipLeft = { x: this.x + constants.player.hip.offset_x, y: this.y + constants.player.hip.offset_y };
|
||||||
this.hipRight = { x: this.x + constants.player.hip.offset_x, y: this.y + constants.player.hip.offset_y };
|
this.hipRight = { x: this.x - constants.player.hip.offset_x, y: this.y + constants.player.hip.offset_y };
|
||||||
this.leftLeg = new Leg(this.hipLeft.x, this.hipLeft.y, 50, -Math.PI / 4);
|
this.leftLeg = new Leg(this.hipLeft.x, this.hipLeft.y, 50, Math.PI*2.5);
|
||||||
this.rightLeg = new Leg(this.hipRight.x, this.hipRight.y, 50, Math.PI / 2);
|
this.rightLeg = new Leg(this.hipRight.x, this.hipRight.y, 50, Math.PI*2.5);
|
||||||
this.legSelected = "R";
|
this.legSelected = "R";
|
||||||
this.shouldMoveLeg = false;
|
this.shouldMoveLeg = false;
|
||||||
this.collided = false;
|
this.collided = false;
|
||||||
@ -55,17 +55,8 @@ Player.prototype.update = function() {
|
|||||||
var targetPos = mousePosition();
|
var targetPos = mousePosition();
|
||||||
var curLeg = this.getActiveLeg();
|
var curLeg = this.getActiveLeg();
|
||||||
this.hover.active = false;
|
this.hover.active = false;
|
||||||
//left
|
|
||||||
if (distanceToLineSegment(this.leftLeg.x, this.leftLeg.y, this.leftLeg.x2, this.leftLeg.y2, targetPos.x, targetPos.y) < constants.player.select_range) {
|
|
||||||
this.hover.active = true;
|
|
||||||
this.hover.leg = "L";
|
|
||||||
if(mousePress[0]) {
|
|
||||||
this.shouldMoveLeg = true;
|
|
||||||
this.legSelected = "L";
|
|
||||||
this.hover.active = false;
|
|
||||||
}
|
|
||||||
// right
|
// right
|
||||||
} else if (distanceToLineSegment(this.rightLeg.x, this.rightLeg.y, this.rightLeg.x2, this.rightLeg.y2, targetPos.x, targetPos.y) < constants.player.select_range) {
|
if (distanceToLineSegment(this.rightLeg.x, this.rightLeg.y, this.rightLeg.x2, this.rightLeg.y2, targetPos.x, targetPos.y) < constants.player.select_range) {
|
||||||
this.hover.active = true;
|
this.hover.active = true;
|
||||||
this.hover.leg = "R";
|
this.hover.leg = "R";
|
||||||
if(mousePress[0]) {
|
if(mousePress[0]) {
|
||||||
@ -73,6 +64,15 @@ Player.prototype.update = function() {
|
|||||||
this.legSelected = "R";
|
this.legSelected = "R";
|
||||||
this.hover.active = false;
|
this.hover.active = false;
|
||||||
}
|
}
|
||||||
|
//left
|
||||||
|
} else if (distanceToLineSegment(this.leftLeg.x, this.leftLeg.y, this.leftLeg.x2, this.leftLeg.y2, targetPos.x, targetPos.y) < constants.player.select_range) {
|
||||||
|
this.hover.active = true;
|
||||||
|
this.hover.leg = "L";
|
||||||
|
if(mousePress[0]) {
|
||||||
|
this.shouldMoveLeg = true;
|
||||||
|
this.legSelected = "L";
|
||||||
|
this.hover.active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,6 @@ Player.prototype.moveLeg = function(){
|
|||||||
// console.log(curLeg.angle.toPrecision(5),pointTo(curLeg,target).toPrecision(5));
|
// console.log(curLeg.angle.toPrecision(5),pointTo(curLeg,target).toPrecision(5));
|
||||||
var angleDif = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed) - curLeg.angle;
|
var angleDif = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed) - curLeg.angle;
|
||||||
curLeg.angle += angleDif;
|
curLeg.angle += angleDif;
|
||||||
// var angle = pointTo(curLeg,target);
|
|
||||||
curLeg.x2 = curLeg.x + curLeg.len * Math.cos(curLeg.angle);
|
curLeg.x2 = curLeg.x + curLeg.len * Math.cos(curLeg.angle);
|
||||||
curLeg.y2 = curLeg.y + curLeg.len * Math.sin(curLeg.angle);
|
curLeg.y2 = curLeg.y + curLeg.len * Math.sin(curLeg.angle);
|
||||||
|
|
||||||
@ -109,15 +108,26 @@ Player.prototype.moveLeg = function(){
|
|||||||
curLeg.x2 = lastX;
|
curLeg.x2 = lastX;
|
||||||
curLeg.y2 = lastY;
|
curLeg.y2 = lastY;
|
||||||
curLeg.angle -= angleDif;
|
curLeg.angle -= angleDif;
|
||||||
|
|
||||||
|
// finer movement
|
||||||
|
angleDif = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed/8) - curLeg.angle;
|
||||||
|
curLeg.angle += angleDif;
|
||||||
|
curLeg.x2 = curLeg.x + curLeg.len * Math.cos(curLeg.angle);
|
||||||
|
curLeg.y2 = curLeg.y + curLeg.len * Math.sin(curLeg.angle);
|
||||||
|
|
||||||
|
|
||||||
|
// Collision
|
||||||
|
if(collidingWithWorld({x:curLeg.x2,y:curLeg.y2,w:2,h:2})){
|
||||||
|
this.collided = true;
|
||||||
|
curLeg.x2 = lastX;
|
||||||
|
curLeg.y2 = lastY;
|
||||||
|
curLeg.angle -= angleDif;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(collidingWithWorld({x:this.x, y:this.y, w:this.w, h:this.h})){
|
|
||||||
this.x = this.lastBodyX;
|
|
||||||
this.y = this.lastBodyY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (dist(curLeg, target) > curLeg.len) {
|
if (dist(curLeg, target) > curLeg.len) {
|
||||||
@ -169,7 +179,10 @@ Player.prototype.moveLeg = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(collidingWithWorld({x:this.x, y:this.y, w:this.w, h:this.h})){
|
||||||
|
this.x = this.lastBodyX;
|
||||||
|
this.y = this.lastBodyY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.lastBodyX = this.x;
|
this.lastBodyX = this.x;
|
||||||
@ -246,5 +259,9 @@ function distanceToLineSegment(lx1, ly1, lx2, ly2, px, py) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
var player = new Player(500,-70);
|
var player = new Player(constants.player.defaultX, constants.player.defaultY);
|
||||||
|
|
||||||
|
// why does this stop the legs from glitching on the first step???
|
||||||
|
player.rightLeg.angle = -pointTo({ x: player.rightLeg.x2, y: player.rightLeg.y2 }, player.hipRight);
|
||||||
|
player.leftLeg.angle = pointTo({ x: player.leftLeg.x2, y: player.leftLeg.y2 }, player.hipLeft);
|
||||||
|
player.moveLeg();
|
@ -24,7 +24,7 @@ function handleTitleScreen(){
|
|||||||
function handleMainScreen(){
|
function handleMainScreen(){
|
||||||
if(timer > 20){
|
if(timer > 20){
|
||||||
if(rectpoint({x:415, y:200, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
|
if(rectpoint({x:415, y:200, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
|
||||||
globalState = globalStates.playing;
|
globalState = globalStates.levelTransition;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
if(rectpoint({x:415, y:550, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
|
if(rectpoint({x:415, y:550, w: 300, h: 50}, {x:cursor.x, y:cursor.y}) && mouseDown[0]){
|
||||||
|
42
docs/assets/js/transition/transition.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
var currentAlpha = 1.01;
|
||||||
|
|
||||||
|
|
||||||
|
function handleTransition(){
|
||||||
|
|
||||||
|
// Calculates alpha until its zero
|
||||||
|
if(currentAlpha > 0){
|
||||||
|
currentAlpha -= .005;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UI for level transition
|
||||||
|
function drawLevelTransitionUI() {
|
||||||
|
|
||||||
|
// centers camera on player
|
||||||
|
centerCameraOn(constants.player.defaultX, constants.player.defaultY);
|
||||||
|
|
||||||
|
// sets alpha for background drawing
|
||||||
|
canvases.ctx.globalAlpha = 1;
|
||||||
|
|
||||||
|
// draws background sprites
|
||||||
|
drawWorldBlocks();
|
||||||
|
imgIgnoreCutoff(sprites.level_2,0,0,0,4,4);
|
||||||
|
player.draw();
|
||||||
|
|
||||||
|
// sets alpha to calculated alpha for black
|
||||||
|
canvases.ctx.globalAlpha = currentAlpha;
|
||||||
|
|
||||||
|
// draw a black rect unless less the 0 alpha then switches to actual game
|
||||||
|
if(currentAlpha > 0){
|
||||||
|
rect(0, 0, 2000, 2000, "black");
|
||||||
|
}else{
|
||||||
|
globalState = globalStates.playing;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resets alpha for rest of drawing
|
||||||
|
canvases.ctx.globalAlpha = 1;
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<!-- <link rel="icon" type="image/gif" href="icon.png"/> -->
|
<link rel="icon" type="image/gif" href="assets/images/tempIcon.png"/>
|
||||||
<title>html.aspx</title>
|
<title>error: title is undefined</title>
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
background-color: var(--theme-webpage-bg_color);
|
background-color: var(--theme-webpage-bg_color);
|
||||||
@ -13,7 +13,6 @@
|
|||||||
top:0;bottom:0;right:0;left:0;
|
top:0;bottom:0;right:0;left:0;
|
||||||
margin:auto;
|
margin:auto;
|
||||||
border: 5px solid var(--theme-webpage-canvas_border);
|
border: 5px solid var(--theme-webpage-canvas_border);
|
||||||
border-radius: 10px;
|
|
||||||
background-color: var(--theme-webpage-canvas_bg);
|
background-color: var(--theme-webpage-canvas_bg);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -21,6 +20,11 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<canvas width="800" height="600" id="game"></canvas>
|
<canvas width="800" height="600" id="game"></canvas>
|
||||||
|
<pre style="position: absolute;left: 0;bottom: 0;"> TODO REMOVE ME
|
||||||
|
z: blink
|
||||||
|
x: breath
|
||||||
|
c: beat heart
|
||||||
|
</pre>
|
||||||
|
|
||||||
<!-- Graphics Library -->
|
<!-- Graphics Library -->
|
||||||
<script src="assets/js/game.js"></script>
|
<script src="assets/js/game.js"></script>
|
||||||
@ -48,6 +52,7 @@
|
|||||||
|
|
||||||
<script src="assets/js/titleScreen/titleScreen.js"></script>
|
<script src="assets/js/titleScreen/titleScreen.js"></script>
|
||||||
<script src="assets/js/UI/ui.js"></script>
|
<script src="assets/js/UI/ui.js"></script>
|
||||||
|
<script src="assets/js/transition/transition.js"></script>
|
||||||
|
|
||||||
<!-- Webpage -->
|
<!-- Webpage -->
|
||||||
<script src="assets/js/injection/cssinjector.js"></script>
|
<script src="assets/js/injection/cssinjector.js"></script>
|
||||||
|