Skip to content

Commit

Permalink
Merge pull request #83 from jm1021/main
Browse files Browse the repository at this point in the history
Reduce Platform Files
  • Loading branch information
jm1021 authored May 19, 2024
2 parents 61ced2e + 32587b4 commit 33b1b97
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 189 deletions.
25 changes: 0 additions & 25 deletions assets/js/platformer3x/BackgroundCoral.js

This file was deleted.

24 changes: 0 additions & 24 deletions assets/js/platformer3x/BackgroundFish.js

This file was deleted.

25 changes: 0 additions & 25 deletions assets/js/platformer3x/BackgroundHills.js

This file was deleted.

18 changes: 0 additions & 18 deletions assets/js/platformer3x/BackgroundMountains.js

This file was deleted.

24 changes: 0 additions & 24 deletions assets/js/platformer3x/BackgroundNarwhal.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import GameEnv from './GameEnv.js';
import Background from './Background.js';

export class BackgroundClouds extends Background {
export class BackgroundParallax extends Background {
constructor(canvas, image, data) {
super(canvas, image, data);

this.parallaxSpeed = 1;
this.parallaxSpeed = data.parallaxSpeed || 1;
this.moveOnKeyAction = data.moveOnKeyAction || false;
}

// speed is used to background parallax behavior
update() {
this.speed = this.parallaxSpeed;
this.speed = this.moveOnKeyAction ? this.parallaxSpeed * GameEnv.backgroundDirection : this.parallaxSpeed;
super.update();
}

Expand All @@ -21,4 +22,4 @@ export class BackgroundClouds extends Background {

}

export default BackgroundClouds;
export default BackgroundParallax;
24 changes: 0 additions & 24 deletions assets/js/platformer3x/BackgroundPlayers.js

This file was deleted.

25 changes: 0 additions & 25 deletions assets/js/platformer3x/BackgroundWinter.js

This file was deleted.

34 changes: 14 additions & 20 deletions assets/js/platformer3x/GameSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@ import GameEnv from './GameEnv.js';
import GameLevel from './GameLevel.js';
// To build GameLevels, each contains GameObjects from below imports
import Background from './Background.js'
import BackgroundHills from './BackgroundHills.js';
import BackgroundCoral from './BackgroundCoral.js';
import BackgroundMountains from './BackgroundMountains.js';
import BackgroundParallax from './BackgroundParallax.js';
import BackgroundTransitions from './BackgroundTransitions.js';
import BackgroundClouds from './BackgroundClouds.js';
import BackgroundFish from './BackgroundFish.js';
import BackgroundWinter from './BackgroundWinter.js';
import BackgroundNarwhal from './BackgroundNarwhal.js';
import BackgroundSnow from './BackgroundSnow.js';
import Platform from './Platform.js';
import JumpPlatform from './JumpPlatform.js';
Expand Down Expand Up @@ -299,20 +293,20 @@ const GameSetup = {
backgrounds: {
boss: { src: "/images/platformer/backgrounds/BossBackground.png" },
start: { src: "/images/platformer/backgrounds/home.png" },
hills: { src: "/images/platformer/backgrounds/hills.png" },
hills: { src: "/images/platformer/backgrounds/hills.png", parallaxSpeed: 0.4, moveOnKeyAction: true },
greece: { src: "/images/platformer/backgrounds/greek.png" },
mountains: { src: "/images/platformer/backgrounds/mountains.jpg" },
clouds: { src: "/images/platformer/backgrounds/clouds.png" },
mountains: { src: "/images/platformer/backgrounds/mountains.jpg", parallaxSpeed: 0.1, moveOnKeyAction: true },
clouds: { src: "/images/platformer/backgrounds/clouds.png", parallaxSpeed: 0.5 },
water: { src: "/images/platformer/backgrounds/water.png" },
fish: { src: "/images/platformer/backgrounds/school-fish.png" },
fish: { src: "/images/platformer/backgrounds/school-fish.png", parallaxSpeed: -0.5 },
reef: { src: "/images/platformer/backgrounds/reef.png" },
quidditch: { src: "/images/platformer/backgrounds/quidditch2.jpg" },
miniHogwarts: { src: "/images/platformer/backgrounds/miniHogwarts.png"},
space: { src: "/images/platformer/backgrounds/planet.jpg" },
castles: { src: "/images/platformer/backgrounds/castles.png" },
winter: { src: "/images/platformer/backgrounds/winter.png" },
winter: { src: "/images/platformer/backgrounds/winter.png", parallaxSpeed: 0.4, moveOnKeyAction: true },
snow: { src: "/images/platformer/backgrounds/snowfall.png" },
narwhal: { src: "/images/platformer/backgrounds/narwhal.png" },
narwhal: { src: "/images/platformer/backgrounds/narwhal.png", parallaxSpeed: 2 },
mini: { src: "/images/platformer/backgrounds/mini.png" },
},
transitions: {
Expand Down Expand Up @@ -657,9 +651,9 @@ const GameSetup = {

// Hills Game Level defintion...
const allHillsGameObjects = [
{ name: 'mountains', id: 'background', class: BackgroundMountains, data: this.assets.backgrounds.mountains },
{ name: 'clouds', id: 'background', class: BackgroundClouds, data: this.assets.backgrounds.clouds },
{ name: 'hills', id: 'background', class: BackgroundHills, data: this.assets.backgrounds.hills },
{ name: 'mountains', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.mountains },
{ name: 'clouds', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.clouds },
{ name: 'hills', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.hills },
{ name: 'grass', id: 'floor', class: Platform, data: this.assets.platforms.grass },
{ name: 'blocks', id: 'jumpPlatform', class: MovingPlatform, data: this.assets.platforms.block, xPercentage: 0.2, yPercentage: 0.85 },
{ name: 'blocks', id: 'jumpPlatform', class: MovingPlatform, data: this.assets.platforms.block, xPercentage: 0.2368, yPercentage: 0.85 },
Expand Down Expand Up @@ -837,8 +831,8 @@ const GameSetup = {
// Under Water Game Level defintion...
const allWaterGameObjects = [
{ name: 'water', id: 'background', class: Background, data: this.assets.backgrounds.water },
{ name: 'fish', id: 'background', class: BackgroundFish, data: this.assets.backgrounds.fish },
{ name: 'reef', id: 'background', class: BackgroundCoral, data: this.assets.backgrounds.reef },
{ name: 'fish', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.fish },
{ name: 'reef', id: 'background', class: Background, data: this.assets.backgrounds.reef },
{ name: 'sand', id: 'floor', class: Platform, data: this.assets.platforms.sand },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.block, xPercentage: 0.2, yPercentage: 0.85 },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.block, xPercentage: 0.2368, yPercentage: 0.85 },
Expand Down Expand Up @@ -996,8 +990,8 @@ const GameSetup = {

const winterObjects = [
// GameObject(s), the order is important to z-index...
{ name: 'winter', id: 'background', class: BackgroundWinter, data: this.assets.backgrounds.winter },
{ name: 'narwhal', id: 'background', class: BackgroundNarwhal, data: this.assets.backgrounds.narwhal },
{ name: 'winter', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.winter },
{ name: 'narwhal', id: 'background', class: BackgroundParallax, data: this.assets.backgrounds.narwhal },
{ name: 'snow', id: 'background', class: BackgroundSnow, data: this.assets.backgrounds.snow },
{ name: 'snowyfloor', id: 'platform', class: Platform, data: this.assets.platforms.snowyfloor },
{ name: 'blocks', id: 'jumpPlatform', class: BlockPlatform, data: this.assets.platforms.snowywood, xPercentage: 0.2, yPercentage: 0.82 },
Expand Down

0 comments on commit 33b1b97

Please sign in to comment.