Skip to content

Commit

Permalink
Refactor folders out
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanBacon committed Jul 2, 2020
1 parent 26e0aeb commit 26297fb
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 45 deletions.
48 changes: 27 additions & 21 deletions client/src/Game/Circle.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
import { CircleGeometry, Mesh, MeshPhongMaterial, Color } from "three";
import { CircleGeometry, Color, Mesh, MeshPhongMaterial } from "three";

class CircleMesh extends Mesh {
private _alpha = 1;
class AlphaMesh extends Mesh {
private _alpha: number = 1;

get alpha(): number {
return this._alpha;
}

set alpha(value: number) {
this._alpha = value;
this.setAlpha(value);
}

private setAlpha(value: number) {
const transparent = value !== 1;
if (Array.isArray(this.material)) {
this.material.map((material) => {
material.transparent = transparent;
material.opacity = value;
});
} else if (this.material) {
this.material.transparent = transparent;
this.material.opacity = value;
}
}
}

class CircleMesh extends AlphaMesh {
constructor({
radius,
color,
Expand All @@ -20,31 +44,13 @@ class CircleMesh extends Mesh {
);
}

set alpha(value) {
this._alpha = value;
const transparent = value !== 1;
if (Array.isArray(this.material)) {
this.material.map((material) => {
material.transparent = transparent;
material.opacity = value;
});
} else if (this.material) {
this.material.transparent = transparent;
this.material.opacity = value;
}
}

reset = () => {
this.visible = false;
this.scale.x = 0.001;
this.scale.y = 0.001;
this.alpha = 0.8;
};

get alpha() {
return this._alpha;
}

explode = () => {
// todo tween disapate animation
};
Expand Down
8 changes: 4 additions & 4 deletions client/src/Game/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import * as THREE from "three";
import Settings from "../constants/Settings";
import { dispatch } from "../rematch/store";
import GameObject from "./GameObject";
import Lighting from "./engine/entities/Lighting";
import PlatformObject from "./engine/entities/Platform";
import PlayerBall from "./engine/entities/PlayerBall";
import randomRange from "./engine/utils/randomRange";
import Lighting from "./entities/Lighting";
import PlatformObject from "./entities/Platform";
import PlayerBall from "./entities/PlayerBall";
import randomRange from "./utils/randomRange";
import GameScene from "./GameScene";
import GameStates from "./GameStates";
import MenuObject from "./MenuObject";
Expand Down
2 changes: 1 addition & 1 deletion client/src/Game/GameScene.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TweenMax } from "gsap";
import * as THREE from "three";

import randomRange from "./engine/utils/randomRange";
import randomRange from "./utils/randomRange";

export default class GameScene extends THREE.Scene {
private hue: number = 19;
Expand Down
1 change: 0 additions & 1 deletion client/src/Game/engine/utils/randomRange.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Haptics from "expo-haptics";
import { Platform } from "react-native";
import { MeshPhongMaterial } from "three";

import Colors from "../../../constants/Colors";
import Colors from "../../constants/Colors";
import Gem from "./Gem";

const DoubleGemMaterial = new MeshPhongMaterial({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CylinderGeometry, Mesh, MeshPhongMaterial } from "three";

import Colors from "../../../constants/Colors";
import GameObject from "../../GameObject";
import Colors from "../../constants/Colors";
import GameObject from "../GameObject";

let GemMaterial: MeshPhongMaterial = new MeshPhongMaterial({
color: Colors.blue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HemisphereLight, DirectionalLight } from "three";

import GameObject from "../../GameObject";
import GameObject from "../GameObject";

class Lighting extends GameObject {
get hemisphere() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TweenMax } from "gsap";

import { Color, Mesh, CylinderBufferGeometry, MeshPhongMaterial } from "three";
import GameObject from "../../GameObject";
import GameObject from "../GameObject";
import randomRange from "../utils/randomRange";
import Gem from "./Gem";
import Settings from "../../../constants/Settings";
import Settings from "../../constants/Settings";
import DoubleGem from "./DoubleGem";

const radius = 33.3333333 / 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Mesh, CylinderBufferGeometry, MeshPhongMaterial } from "three";

import { Power2 as Cubic, TweenMax } from "gsap";

import Colors from "../../../constants/Colors";
import Circle from "../../Circle";
import GameObject from "../../GameObject";
import Settings from "../../../constants/Settings";
import Colors from "../../constants/Colors";
import Circle from "../Circle";
import GameObject from "../GameObject";
import Settings from "../../constants/Settings";

const radius = 26.6666667 / 2;
const PlayerBallGeom = new CylinderBufferGeometry(radius, radius, 9, 24);
Expand All @@ -30,14 +30,6 @@ class PlayerBall extends GameObject {
await super.loadAsync(scene);
};

resetCircle = () => {
if (!this.circle) return;
this.circle.visible = false;
this.circle.scale.x = 0.001;
this.circle.scale.y = 0.001;
this.circle.alpha = 0.8;
};

hide = ({
onComplete,
duration = 0.7,
Expand Down
2 changes: 2 additions & 0 deletions client/src/Game/utils/randomRange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default (min: number, max: number): number =>
min + Math.random() * (max - min);

0 comments on commit 26297fb

Please sign in to comment.