Draw subproject contents on screen

This commit is contained in:
Dennis Schoepf 2021-07-24 17:43:39 +02:00
parent cd858baf3a
commit db39a8cb42
4 changed files with 24 additions and 17 deletions

View file

@ -1,22 +1,27 @@
import { mp5 } from '../../main'; import { mp5 } from '../../main';
import { colors } from '../constants/colors'; import { colors } from '../constants/colors';
import { Contributor } from '../sketchObjects/Contributor';
import { Legacy } from '../sketchObjects/Legacy';
import { Package } from '../sketchObjects/Package';
import { Player } from '../sketchObjects/Player'; import { Player } from '../sketchObjects/Player';
import store from '../store'; import store from '../store';
import { Scenes } from './scenes'; import { Scenes } from './scenes';
export class DetailScene { export class DetailScene {
player: Player; player: Player;
contributors: any; contributors: any[];
legacy: any; legacy: any[];
packages: any; packages: any[];
constructor() { constructor() {
this.player = new Player(); this.player = new Player();
store.subscribe((state) => { store.subscribe((state) => {
this.contributors = state.currContributors; this.contributors = state.currContributors.map(
this.legacy = state.currLegacy; (contributor) => new Contributor(100, 200, 100)
this.packages = state.currPackages; );
this.legacy = state.currLegacy.map((legacy) => new Legacy(200, 300, 100));
this.packages = state.currPackages.map((currPackage) => new Package(400, 300, 100));
}); });
} }
@ -25,7 +30,15 @@ export class DetailScene {
this.player.follow(); this.player.follow();
this.player.move(); this.player.move();
// TODO: Draw what can be found this.contributors.forEach((contributor) => {
contributor.place();
});
this.legacy.forEach((legacyObj) => {
legacyObj.place();
});
this.packages.forEach((packageObj) => {
packageObj.place();
});
} }
onSceneClick() { onSceneClick() {

View file

@ -15,9 +15,7 @@ export class Contributor {
this.size = size; this.size = size;
} }
public place() {} public place() {
private draw() {
mp5.fill(mp5.color(colors.blueGrey)); mp5.fill(mp5.color(colors.blueGrey));
mp5.ellipse(this.x, this.y, this.size); mp5.ellipse(this.x, this.y, this.size);
} }

View file

@ -14,9 +14,7 @@ export class Legacy {
this.size = size; this.size = size;
} }
public place() {} private place() {
private draw() {
mp5.fill(mp5.color(colors.red)); mp5.fill(mp5.color(colors.red));
mp5.ellipse(this.x, this.y, this.size); mp5.ellipse(this.x, this.y, this.size);
} }

View file

@ -1,7 +1,7 @@
import { mp5 } from '../../main'; import { mp5 } from '../../main';
import { colors } from '../constants/colors'; import { colors } from '../constants/colors';
export class Contributor { export class Package {
x: number; x: number;
y: number; y: number;
size: number; size: number;
@ -14,9 +14,7 @@ export class Contributor {
this.size = size; this.size = size;
} }
public place() {} public place() {
private draw() {
mp5.fill(mp5.color(colors.redDark)); mp5.fill(mp5.color(colors.redDark));
mp5.ellipse(this.x, this.y, this.size); mp5.ellipse(this.x, this.y, this.size);
} }