Skip to content

Commit

Permalink
Committing a working game
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmiccoder committed Feb 8, 2022
1 parent df27df4 commit 6c81f11
Show file tree
Hide file tree
Showing 52 changed files with 33 additions and 27 deletions.
Binary file added images/HarshGeniusMap3.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 images/R&D Room Assets/1 Drones/1/Death.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 images/R&D Room Assets/1 Drones/1/Idle.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 images/R&D Room Assets/1 Drones/1/Scan.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 images/R&D Room Assets/1 Drones/1/Walk.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 images/R&D Room Assets/1 Drones/1/Walk_scan.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 images/R&D Room Assets/1 Drones/2/Bomb.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 images/R&D Room Assets/1 Drones/2/Drop.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 images/R&D Room Assets/1 Drones/3/Back.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 images/R&D Room Assets/1 Drones/3/Death.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 images/R&D Room Assets/1 Drones/3/Fire1.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 images/R&D Room Assets/1 Drones/3/Fire2.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 images/R&D Room Assets/1 Drones/3/Fire3.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 images/R&D Room Assets/1 Drones/3/Forward.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 images/R&D Room Assets/1 Drones/3/Idle.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 images/R&D Room Assets/1 Drones/4/Death.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 images/R&D Room Assets/1 Drones/4/Idle.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 images/R&D Room Assets/1 Drones/4/Landing.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 images/R&D Room Assets/1 Drones/4/Walk.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 images/R&D Room Assets/1 Drones/5/Death.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 images/R&D Room Assets/1 Drones/5/Idle.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 images/R&D Room Assets/1 Drones/5/Walk.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 images/R&D Room Assets/1 Drones/5_2/Death.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 images/R&D Room Assets/1 Drones/5_2/Idle.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 images/R&D Room Assets/1 Drones/5_2/Walk.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 images/R&D Room Assets/1 Drones/6/Capsule.png
Binary file added images/R&D Room Assets/1 Drones/6/Drop.png
Binary file added images/R&D Room Assets/1 Drones/6/Walk.png
Binary file added images/R&D Room Assets/1 Drones/6/Walk2.png
2 changes: 2 additions & 0 deletions images/R&D Room Assets/Font.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Future Millennium
https://www.dafont.com/futuremillennium.font
Binary file added images/R&D Room Assets/PSD/1.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/2.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/3.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/4.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/5_1.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/5_2.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/6.psd
Diff not rendered.
Binary file added images/R&D Room Assets/PSD/7.psd
Diff not rendered.
1 change: 1 addition & 0 deletions images/R&D Room Assets/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://craftpix.net/file-licenses/
Binary file added images/hero64.png
Binary file added images/ourLatestMap.png
Binary file added images/ourMap16.png
Binary file added images/ourMap32.png
Binary file added images/ourMap96.png
29 changes: 11 additions & 18 deletions js/GameObject.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
class GameObject {
class GameObject { // all people
constructor(config) {
this.id = null;
this.isMounted = false;
this.x = config.x || 0;
this.id = null; // name passed in overworld map like 'hero', 'npcA', 'npcB'
this.isMounted = false; // turns true once the game object gets mounted
this.x = config.x || 0; // current x and y coordinates of the character
this.y = config.y || 0;
this.direction = config.direction || "down";
this.direction = config.direction || "down"; // current direction of the character
this.sprite = new Sprite({
gameObject: this,
src: config.src || "./images/hero.png",
src: config.src || "./images/hero.png", // link to the character's spritesheet
});

this.behaviorLoop = config.behaviorLoop || [];
this.behaviorLoopIndex = 0;


this.behaviorLoop = config.behaviorLoop || []; // used for the behavior of npcs. This is a list of objects with the behavior type, which is defined in OverworldMap.js
this.behaviorLoopIndex = 0; // keeps track of
this.talking = config.talking || [];

}

mount(map) {
Expand All @@ -24,6 +21,7 @@ class GameObject {
map.addWall(this.x, this.y);

// if we have a behavior, kick it off after a short delay
// applies to the behavior of npcs
setTimeout(() => {
this.doBehaviorEvent(map);
}, 10);
Expand All @@ -32,15 +30,14 @@ class GameObject {
update() {
}

// mostly for npcs
async doBehaviorEvent(map) {

// maybe the game object has no current behaviour or there's a global event (like a cutscene)
// also return; if the person is currently standing
if(map.isCutscenePlaying || this.behaviorLoop.length === 0 || this.isStanding) {
return;
}


// setting up the event with the relevant info
let eventConfig = this.behaviorLoop[this.behaviorLoopIndex];
eventConfig.who = this.id;
Expand All @@ -54,11 +51,7 @@ class GameObject {
if(this.behaviorLoopIndex === this.behaviorLoop.length) {
this.behaviorLoopIndex = 0;
}

// fire the next behavior
this.doBehaviorEvent(map);


}

}
}
3 changes: 1 addition & 2 deletions js/OverworldEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class OverworldEvent {
}

textMessage(resolve) {

if(this.event.faceHero) { // this.event.faceHero = id of the npc to face that will face the hero
const obj = this.map.gameObjects[this.event.faceHero];
obj.direction = utils.oppositeDirection(this.map.gameObjects['hero'].direction);
Expand All @@ -74,7 +73,7 @@ class OverworldEvent {

sceneTransition.init(document.querySelector('.game-container'), () => {
this.map.overworld.startMap(window.OverworldMaps[this.event.map]); // the value this.event.map is referencing {type: "changeMap", map: "Kitchen"} in OverworldMap
resolve();
resolve();

sceneTransition.fadeOut();
});
Expand Down
18 changes: 13 additions & 5 deletions js/OverworldMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ class OverworldMap {
}
}



addWall(x,y) {
this.walls[`${x},${y}`] = true;
}
Expand All @@ -106,22 +104,32 @@ class OverworldMap {
const {x,y} = utils.nextPosition(wasX,wasY,direction);
this.addWall(x,y);
}


}

window.OverworldMaps = {
DemoRoom: {
// lowerSrc: "./images/DemoLower.png",
// lowerSrc: "./images/HarshGeniusMap1.png",
// lowerSrc: "./images/ourMap96.png",
lowerSrc: "./images/DemoLower.png",
upperSrc: "./images/DemoUpper.png",
gameObjects: {

hero: new Person({
isPlayerControlled: true,
// src: "./images/hero64.png",
x: utils.withGrid(5),
y: utils.withGrid(6)
}),

// myDrone: new Person({
// x: utils.withGrid(8),
// y: utils.withGrid(8),
// src: "./images/myDrone.png",
// animations: { // these values are according to the drone's spritesheet
// "spinning": [[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7]]
// },
// currentAnimation: "spinning",
// }),

npcA: new Person({
x: utils.withGrid(7),
Expand Down
4 changes: 2 additions & 2 deletions js/Sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Sprite {
"walk-left": [[1,3], [0,3], [3,3], [0,3]],
}

this.currentAnimation = "idle-right"//config.currentAnimation || "idle-down";
// this.currentAnimation = "idle-right" //config.currentAnimation || "idle-down";
this.currentAnimation = config.currentAnimation || "idle-right";
this.currentAnimationFrame = 0;

// how many game loop frames to show one cut from the sprite sheet
Expand All @@ -55,7 +56,6 @@ class Sprite {
}
}


updateAnimationProgress() {
// downtick current frame's progress
if(this.animationFrameProgress > 0) {
Expand Down
3 changes: 3 additions & 0 deletions styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ body {
outline: 1px solid white;

transform: scale(3) translateY(50%);
/* transform: scale(1.5) translateY(50%); */
/* transform: scale(1) translate(50%); */
/* transform:translateY(20%); */
}

.game-container canvas{
Expand Down

0 comments on commit 6c81f11

Please sign in to comment.