Settings invented, restructuring of graphics folders and enhancements for target point.

This commit is contained in:
Mal
2020-02-12 21:29:06 +01:00
parent 9d1bd467b5
commit b06186043f
9 changed files with 32 additions and 27 deletions

View File

@@ -6,6 +6,7 @@ import RetroArchitecture from "./retro/RetroArchitecture.js";
import FileLoader from "./FileLoader.js";
import Camera from "./Camera.js";
import Gisela from "./Gisela.js";
import Setting from "./Setting.js";
class ImageLoader
{
@@ -116,18 +117,6 @@ function MainLoop(timestamp)
);
}
if (!gameFinished && architecture.isMovableInsideTargetPosition(mrCroc)) {
gameFinished = true;
setTimeout(
function () {
alert('Gisela: "Thanks for showing up, Mr. Croc, but I\'m not in danger."');
lastTimestamp = timestamp;
lastRendered = timestamp;
}, 1000
)
}
camera.focusPosition(
mrCroc.position.x - mrCroc.getWidth() * 0.5,
mrCroc.position.y - mrCroc.getHeight() * 0.5,
@@ -139,7 +128,6 @@ function MainLoop(timestamp)
if (timestamp - lastRendered >= FRAME_DURATION) {
context.clearRect(0, 0, window.innerWidth, window.innerHeight);
// camera.centerCamera(mrCroc.position.x - mrCroc.getWidth() * 0.5, mrCroc.position.y - mrCroc.getHeight() * 0.5);
architecture.draw(context, camera);
mrCroc.draw(context, camera);
gisela.draw(context, camera);
@@ -149,10 +137,21 @@ function MainLoop(timestamp)
lastTimestamp = timestamp;
if (!gameFinished && mrCroc.isJumping === false && architecture.isMovableInsideTargetPosition(mrCroc)) {
gameFinished = true;
KeyLeft.pressed = false;
KeyRight.pressed = false;
KeyJump.pressed = false;
lastTimestamp = undefined;
lastRendered = undefined;
alert('Gisela: "Thanks for showing up, Mr. Croc, but I\'m not in danger."');
}
window.requestAnimationFrame(MainLoop);
}
const FPS = 60;
const FPS = 120;
const FRAME_DURATION = 1000 / FPS;
const GAME_SPEED = 1;
const GRAVITY = 2;
@@ -176,19 +175,19 @@ let KeyJump = new Key('Space');
let loader = new ImageLoader();
let imgAnimation = new Image();
imgAnimation.src = 'graphics/mr-croc-walk-right.png';
imgAnimation.src = Setting.GRAPHICS_LOCATION + 'mr-croc-walk-right.png';
loader.addImage(imgAnimation);
let imgAnimationB = new Image();
imgAnimationB.src = 'graphics/mr-croc-walk-left.png';
imgAnimationB.src = Setting.GRAPHICS_LOCATION + 'mr-croc-walk-left.png';
loader.addImage(imgAnimationB);
let imgArch = new Image();
imgArch.src = 'graphics/tileset-landscape01.jpg';
imgArch.src = Setting.TILESET_LOCATION + 'landscape01.jpg';
loader.addImage(imgArch);
let imgGisela = new Image();
imgGisela.src = 'graphics/gisela-right.png';
imgGisela.src = Setting.GRAPHICS_LOCATION + 'gisela-right.png';
loader.addImage(imgGisela);
window.addEventListener(