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.
2020-04-20 02:28:48 -04:00

59 lines
1.2 KiB
JavaScript

var currentAlpha = 1.01;
function handleTransition(){
// Calculates alpha until its zero
if(currentAlpha > 0){
currentAlpha -= .005;
}
centerCameraOn(constants.player.defaultX, constants.player.defaultY);
if(camera.x > 898) {
camera.x = 898;
}
if(camera.x < -98) {
camera.x = -98;
}
if(camera.y < 245) {
camera.y = 245;
}
if(camera.y > 350) {
camera.y = 350;
}
}
// UI for level transition
function drawLevelTransitionUI() {
// centers camera on player
// sets alpha for background drawing
canvases.ctx.globalAlpha = 1;
// draws background sprites
drawWorldBlocks();
imgIgnoreCutoff(sprites.epic,0,0);
imgIgnoreCutoff(sprites.chandelier,770,-235,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;
}