Skip to content

Commit

Permalink
Merge pull request #22 from Nichodon/develop
Browse files Browse the repository at this point in the history
Overhaul game aesthetic
  • Loading branch information
briarsychung authored Dec 12, 2021
2 parents 8a86b98 + 22b6220 commit f596939
Show file tree
Hide file tree
Showing 89 changed files with 291 additions and 117 deletions.
Binary file added assets/background/inside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/background/outside.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/catch-me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/empty-angry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/empty-normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/hahaha.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/this-ends-here.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/dialogue/you-found-me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/effects/magic-big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/effects/magic-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/effects/smoke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-big-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-big-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-cracked-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-cracked-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-small-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-small-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/brick-small-thin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/ground/button.png
Binary file not shown.
Binary file removed assets/ground/goal.png
Binary file not shown.
Binary file added assets/ground/ground-middle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ground/ground-side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/ground/ground.png
Binary file not shown.
Binary file removed assets/ground/platform.png
Binary file not shown.
Binary file added assets/icons/arrow-left.png
Binary file added assets/icons/arrow-right.png
Binary file added assets/icons/player-blue.png
Binary file added assets/icons/player-red.png
Binary file added assets/interactive/box-big.png
Binary file added assets/interactive/box-small.png
Binary file added assets/interactive/button-down.png
Binary file added assets/interactive/button-up.png
Binary file added assets/interactive/portal-active1.png
Binary file added assets/interactive/portal-active2.png
Binary file added assets/interactive/portal-inactive.png
Binary file added assets/interactive/pulley-cable.png
Binary file added assets/interactive/pulley-wheel.png
Binary file added assets/interactive/spike-big.png
Binary file added assets/interactive/spike-small.png
Binary file added assets/npc/wizard.png
Binary file added assets/player/player-blue-dead.png
Binary file added assets/player/player-blue-idle1.png
Binary file added assets/player/player-blue-idle2.png
Binary file added assets/player/player-blue-jump.png
Binary file added assets/player/player-blue-run1.png
Binary file added assets/player/player-blue-run2.png
Binary file added assets/player/player-blue-run3.png
Binary file added assets/player/player-main-dead.png
Binary file added assets/player/player-main-idle1.png
Binary file added assets/player/player-main-idle2.png
Binary file added assets/player/player-main-jump.png
Binary file added assets/player/player-main-run1.png
Binary file added assets/player/player-main-run2.png
Binary file added assets/player/player-main-run3.png
Binary file added assets/player/player-red-dead.png
Binary file added assets/player/player-red-idle1.png
Binary file added assets/player/player-red-idle2.png
Binary file added assets/player/player-red-jump.png
Binary file added assets/player/player-red-run1.png
Binary file added assets/player/player-red-run2.png
Binary file added assets/player/player-red-run3.png
Binary file removed assets/player/player.png
Diff not rendered.
Binary file added icon.png
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

<head>
<meta charset="utf-8">
<title>Final</title>
<title>Final v0.2</title>
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="main.css">
</head>

<body>
<div class="contain" id="menu" style="visibility: visible;">
<h1>Insert Name Here</h1>
<button id="start">Start Game</button>
<p>Version 0.1<br><br>By Robert Qu<br>and Brandon Chung</p>
<p>Version 0.2<br><br>By Robert Qu<br>and Brandon Chung</p>
</div>
<div class="contain" id="game">
<canvas id="canvas"></canvas>
Expand Down
81 changes: 56 additions & 25 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import { Game } from './modules/game.mjs';
import { Canvas } from './modules/canvas.mjs';
import { Level } from './modules/level.mjs';
import { Texture } from './modules/texture.mjs';
import { Animated } from './modules/animated.mjs';
import { Player } from './modules/player.mjs';
import { Sprite } from './modules/sprite.mjs';
import { Input } from './modules/input.mjs';
import { Level } from './modules/level.mjs';
import { Spawn } from './modules/spawn.mjs';
import { Box } from './modules/box.mjs';
import { Ground } from './modules/ground.mjs';
import { Spike } from './modules/spike.mjs';
import { Platform } from './modules/platform.mjs';
import { Cracked } from './modules/cracked.mjs';
import { Door } from './modules/door.mjs';
import { Portal } from './modules/portal.mjs';
import { Platform } from './modules/platform.mjs';
import { Spike } from './modules/spike.mjs';
import { Boost } from './modules/boost.mjs';
import { Door } from './modules/door.mjs';
import { Link } from './modules/link.mjs';
import { Portal } from './modules/portal.mjs';
import { Box } from './modules/box.mjs';
import { Goal } from './modules/goal.mjs';

const GAME = new Game(new Canvas(document.getElementById('canvas')));

let players = [new Player('../assets/player/player.png'), new Player('../assets/player/player.png')];

GAME.addPlayer(players[0]);
GAME.addPlayer(players[1]);

GAME.addInput(new Input(players[0]));
GAME.addInput(new Input(players[1], { left: 'arrowleft', right: 'arrowright', up: 'arrowup' }));
let speed = 0;

generateLevels();

Expand All @@ -39,37 +36,71 @@ document.getElementById('reset').addEventListener('click', () => {
document.getElementById('menu').style.visibility = 'visible';
});

document.addEventListener('keydown', e => {
switch (e.key.toLowerCase()) {
case 'p':
GAME.debug = !GAME.debug;
if (!GAME.debug) speed = 0;
break;
case '0':
if (GAME.debug) speed = 0;
break;
case '9':
if (GAME.debug) speed = 300;
break;
case '8':
if (GAME.debug) speed = 100;
break;
case ',':
if (GAME.debug) GAME.resetLevel();
break;
case '.':
if (GAME.debug) GAME.nextLevel();
break;
}
});

function loop() {
GAME.update();
if (GAME.stage === 'win') {
document.getElementById('game').style.visibility = 'hidden';
document.getElementById('end').style.visibility = 'visible';
} else {
setTimeout(() => { window.requestAnimationFrame(loop) }, 0);
setTimeout(() => { window.requestAnimationFrame(loop) }, speed);
}
}

function generateLevels() {
let players = [new Player(new Sprite('../assets/player/player-blue-')), new Player(new Sprite('../assets/player/player-red-'))];

GAME.addPlayer(players[0]);
GAME.addPlayer(players[1]);

GAME.addInput(new Input(players[0]));
GAME.addInput(new Input(players[1], { left: 'arrowleft', right: 'arrowright', up: 'arrowup' }));

let stair = new Level();

stair.addSpawn(new Spawn(players[0], { x: 0, y: -25 }));
stair.addSpawn(new Spawn(players[1], { x: 20, y: -25 }));
stair.addBackground(new Texture('../assets/background/outside.png', { w: 1024, h: 1024 }));

stair.addSpawn(new Spawn({ x: 300, y: 475 }, players[0]));
stair.addSpawn(new Spawn({ x: 325, y: 475 }, players[1]));

stair.addObject(new Ground('../assets/ground/ground.png', { x: 10, y: 25 }, { w: 40, h: 50 }));
stair.addObject(new Ground('../assets/ground/ground.png', { x: 60, y: -25 }, { w: 40, h: 50 }));
stair.addObject(new Ground('../assets/ground/ground.png', { x: 110, y: -75 }, { w: 40, h: 50 }));
stair.addObject(new Ground({ x: 310, y: 525 }, { w: 40, h: 50 }, new Texture('../assets/ground/brick-small-middle.png', { w: 40, h: 50 })));
stair.addObject(new Ground({ x: 360, y: 475 }, { w: 40, h: 50 }, new Texture('../assets/ground/brick-small-middle.png', { w: 40, h: 50 })));
stair.addObject(new Ground({ x: 410, y: 425 }, { w: 40, h: 50 }, new Texture('../assets/ground/brick-small-middle.png', { w: 40, h: 50 })));

let stairP1 = new Platform('../assets/ground/platform.png', [{ x: 35, y: 25 }, { x: 35, y: -25 }], { w: 10, h: 50 }, 3, 'pause');
let stairP2 = new Platform('../assets/ground/platform.png', [{ x: 85, y: -25 }, { x: 85, y: -75 }], { w: 10, h: 50 }, 3, 'pause');
let stairP1 = new Platform([{ x: 335, y: 525 }, { x: 335, y: 475 }], { w: 10, h: 50 }, new Texture('../assets/ground/brick-cracked-middle.png', { w: 10, h: 50 }), { x: 0, y: 0 }, 3, 'pause');
let stairP2 = new Platform([{ x: 385, y: 475 }, { x: 385, y: 425 }], { w: 10, h: 50 }, new Texture('../assets/ground/brick-cracked-middle.png', { w: 10, h: 50 }), { x: 0, y: 0 }, 3, 'pause');

stair.addObject(stairP1);
stair.addObject(stairP2);

stair.addObject(new Door('../assets/ground/button.png', { x: 60, y: -50 }, { w: 25, h: 2 }, stairP1));
stair.addObject(new Door('../assets/ground/button.png', { x: 110, y: -100 }, { w: 25, h: 2 }, stairP2));
stair.addObject(new Door({ x: 360, y: 448.5 }, { w: 16, h: 3 }, [new Texture('../assets/interactive/button-up.png', { w: 16, h: 6 }), new Texture('../assets/interactive/button-down.png', { w: 16, h: 6 })], { x: 0, y: -1.5 }, stairP1));
stair.addObject(new Door({ x: 410, y: 398.5 }, { w: 16, h: 3 }, [new Texture('../assets/interactive/button-up.png', { w: 16, h: 6 }), new Texture('../assets/interactive/button-down.png', { w: 16, h: 6 })], { x: 0, y: -1.5 }, stairP2));

stair.addGoal(new Goal('../assets/ground/goal.png', { x: 170, y: -75 }));
stair.addGoal(new Goal('../assets/ground/goal.png', { x: 150, y: -75 }));
stair.addGoal(new Goal({ x: 470, y: 425 }, { w: 16, h: 6 }, new Texture('../assets/ground/brick-cracked-middle.png', { w: 16, h: 6 })));
stair.addGoal(new Goal({ x: 450, y: 425 }, { w: 16, h: 6 }, new Texture('../assets/ground/brick-cracked-middle.png', { w: 16, h: 6 })));

GAME.addLevel(stair);
}
28 changes: 28 additions & 0 deletions modules/animated.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Texture } from "./texture.mjs";

class Animated extends Texture {
constructor(urls, dim, reverse = false, length = 20) {
super(urls[0], dim, reverse);

this.urls = urls;
this.length = length;

this.frame = 0;
this.images = [];

for (let i = 0; i < this.urls.length; i++) {
this.images.push(this.generate(this.urls[i], this.reverse));
}
}

start() {
this.frame = 0;
}

draw() {
this.frame = this.frame === this.length * this.urls.length ? 1 : this.frame + 1;
return this.images[Math.floor((this.frame - 1) / this.length)];
}
}

export { Animated };
4 changes: 2 additions & 2 deletions modules/boost.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Interactive } from './interactive.mjs';

class Boost extends Interactive {
constructor(url, pos, dim, acc) {
super(url, pos, dim);
constructor(pos, dim, texture, offset, acc) {
super(pos, dim, texture, offset);

this.acc = acc;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/box.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Mover } from './mover.mjs';

class Box extends Mover {
constructor(url, pos, dim) {
super(url, pos, dim);
constructor(pos, dim, texture, offset) {
super(pos, dim, texture, offset);
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/button.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Interactive } from './interactive.mjs';

class Button extends Interactive {
constructor(url, pos, dim) {
super(url, pos, dim);
constructor(pos, dim, texture, offset) {
super(pos, dim, texture, offset);
}
}

Expand Down
32 changes: 8 additions & 24 deletions modules/camera.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
class Camera {
constructor(pos = { x: 0, y: 0 }, range = { min: 2, max: 3 }, smooth = { pos: 0.75, zoom: 0.875 }) {
constructor(pos = { x: 0, y: 0 }, limit = 2, smooth = { pos: 0.75, zoom: 0.875 }) {
this.pos = pos;
this.range = range;
this.limit = limit;
this.smooth = smooth;

this.zoom = range.min;
this.zoom = limit;
}

update(players) {
let max = {
x: 750 / Math.abs(players[0].pos.x - players[1].pos.x),
y: 750 / Math.abs(players[0].pos.y - players[1].pos.y)
};
let target = {
pos: { x: 0, y: 0 },
zoom: {}
};

if (max.x < this.range.min || max.y < this.range.min) {
target.pos = { ...players[0].pos };
target.zoom = this.range.min;
} else {
target.pos = {
pos: {
x: (players[0].pos.x + players[1].pos.x) / 2,
y: (players[0].pos.y + players[1].pos.y) / 2
};

max = {
x: Math.max(Math.min(max.x, this.range.max), this.range.min),
y: Math.max(Math.min(max.y, this.range.max), this.range.min)
};
target.zoom = Math.min(max.x, max.y);
}
},
zoom: Math.min(500 / Math.abs(players[0].pos.x - players[1].pos.x),
500 / Math.abs(players[0].pos.y - players[1].pos.y), this.limit)
};

this.zoom = this.smooth.zoom * this.zoom + (1 - this.smooth.zoom) * target.zoom;
this.pos.x = this.smooth.pos * this.pos.x + (1 - this.smooth.pos) * target.pos.x;
Expand Down
6 changes: 3 additions & 3 deletions modules/cracked.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Interactive } from './interactive.mjs';

class Cracked extends Interactive {
constructor(url, pos, dim, life = 60) {
super(url, pos, dim);
constructor(pos, dim, texture, offset, life = 60) {
super(pos, dim, texture, offset);

this.max = life;
this.life = life;
this.max = life;
}

init() {
Expand Down
12 changes: 9 additions & 3 deletions modules/door.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { Button } from './button.mjs';

class Door extends Button {
constructor(url, pos, dim, platform) {
super(url, pos, dim);
constructor(pos, dim, textures, offset, platform) {
super(pos, dim, textures[0], offset);

this.textures = textures;
this.platform = platform;
}

trigger() {
if (this.pressed.length) this.platform.play();
if (this.pressed.length) {
this.platform.play();
this.texture = this.textures[1];
} else {
this.texture = this.textures[0];
}

super.trigger();
}
Expand Down
Loading

0 comments on commit f596939

Please sign in to comment.