Implement positioning for revealables
This commit is contained in:
parent
4b26687724
commit
8ad126c8d8
5 changed files with 30 additions and 1 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
"type": "LEGACY",
|
"type": "LEGACY",
|
||||||
"name": "trieNode",
|
"name": "trieNode",
|
||||||
"path": "src/trieNode.ts",
|
"path": "src/trieNode.ts",
|
||||||
|
"size": 85,
|
||||||
"contents": "This file is a bit long, you might want to take a clear look and refactor it. The contributors of this subpackage could help here. Try to reveal them to see their contact info.",
|
"contents": "This file is a bit long, you might want to take a clear look and refactor it. The contributors of this subpackage could help here. Try to reveal them to see their contact info.",
|
||||||
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/trie/src/trieNode.ts",
|
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/trie/src/trieNode.ts",
|
||||||
"imageUrl": null
|
"imageUrl": null
|
||||||
|
|
@ -17,6 +18,7 @@
|
||||||
"type": "CONTRIBUTOR",
|
"type": "CONTRIBUTOR",
|
||||||
"name": "Holger Drewes (holgerd77)",
|
"name": "Holger Drewes (holgerd77)",
|
||||||
"path": null,
|
"path": null,
|
||||||
|
"size": 40,
|
||||||
"contents": "This contributor has a lot of commits in this sub package, below you can find the contact information and a few commits from this repo.",
|
"contents": "This contributor has a lot of commits in this sub package, below you can find the contact information and a few commits from this repo.",
|
||||||
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/trie/src/trieNode.ts",
|
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/trie/src/trieNode.ts",
|
||||||
"imageUrl": "https://avatars.githubusercontent.com/u/931137?v=4"
|
"imageUrl": "https://avatars.githubusercontent.com/u/931137?v=4"
|
||||||
|
|
@ -25,6 +27,7 @@
|
||||||
"type": "PACKAGE",
|
"type": "PACKAGE",
|
||||||
"name": "chalk",
|
"name": "chalk",
|
||||||
"path": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/client/package.json",
|
"path": "https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/client/package.json",
|
||||||
|
"size": 65,
|
||||||
"contents": "This package is used in this part of the project. Take a look at the documentation in order to make yourself familiar with it",
|
"contents": "This package is used in this part of the project. Take a look at the documentation in order to make yourself familiar with it",
|
||||||
"url": "https://github.com/chalk/chalk",
|
"url": "https://github.com/chalk/chalk",
|
||||||
"imageUrl": null
|
"imageUrl": null
|
||||||
|
|
|
||||||
|
|
@ -89,3 +89,18 @@ export function getRevealablesforSubproject(
|
||||||
type: RevealableTypes[revealable.type],
|
type: RevealableTypes[revealable.type],
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function generateRevealableCoords(): Coordinates[] {
|
||||||
|
const areaWidth = mp5.width / 3;
|
||||||
|
const rowHeight = mp5.height / 2;
|
||||||
|
|
||||||
|
// Max. 6 revealables one in each area
|
||||||
|
return [
|
||||||
|
{ x: mp5.random(25, areaWidth), y: mp5.random(25, rowHeight) },
|
||||||
|
{ x: mp5.random(areaWidth, areaWidth * 2), y: mp5.random(25, rowHeight) },
|
||||||
|
{ x: mp5.random(areaWidth * 2, areaWidth * 3), y: mp5.random(25, rowHeight) },
|
||||||
|
{ x: mp5.random(25, areaWidth), y: mp5.random(rowHeight, rowHeight * 2) },
|
||||||
|
{ x: mp5.random(areaWidth, areaWidth * 2), y: mp5.random(rowHeight, rowHeight * 2) },
|
||||||
|
{ x: mp5.random(areaWidth * 2, areaWidth * 3), y: mp5.random(rowHeight, rowHeight * 2) },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
import { mp5 } from '../../main';
|
import { mp5 } from '../../main';
|
||||||
import { colors } from '../constants/colors';
|
import { colors } from '../constants/colors';
|
||||||
|
import { generateRevealableCoords } from '../helpers';
|
||||||
import { Player } from '../sketchObjects/Player';
|
import { Player } from '../sketchObjects/Player';
|
||||||
import { Revealable, RevealableInterface } from '../sketchObjects/Revealable';
|
import { Revealable, RevealableInterface } from '../sketchObjects/Revealable';
|
||||||
import store from '../store';
|
import store from '../store';
|
||||||
|
import { Coordinates } from '../types';
|
||||||
|
|
||||||
export class DetailScene {
|
export class DetailScene {
|
||||||
player: Player;
|
player: Player;
|
||||||
revealables: RevealableInterface[];
|
revealables: RevealableInterface[];
|
||||||
|
revealableCoords: Coordinates[];
|
||||||
revealableObjects: Revealable[];
|
revealableObjects: Revealable[];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -14,8 +17,14 @@ export class DetailScene {
|
||||||
|
|
||||||
store.subscribe((state) => {
|
store.subscribe((state) => {
|
||||||
this.revealables = state.revealables;
|
this.revealables = state.revealables;
|
||||||
|
this.revealableCoords = generateRevealableCoords();
|
||||||
this.revealableObjects = this.revealables.map(
|
this.revealableObjects = this.revealables.map(
|
||||||
(revealable) => new Revealable(revealable, { x: 100, y: 200, w: 65 })
|
(revealable, i) =>
|
||||||
|
new Revealable(revealable, {
|
||||||
|
x: this.revealableCoords[i].x,
|
||||||
|
y: this.revealableCoords[i].y,
|
||||||
|
w: this.revealables[i].size,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export interface RevealableInterface {
|
||||||
name: string;
|
name: string;
|
||||||
contents: string;
|
contents: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
size: number;
|
||||||
path?: string;
|
path?: string;
|
||||||
imageUrl?: string;
|
imageUrl?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export interface JSONSubproject {
|
||||||
name: string;
|
name: string;
|
||||||
contents: string;
|
contents: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
size: number;
|
||||||
path?: string;
|
path?: string;
|
||||||
imageUrl?: string;
|
imageUrl?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
|
||||||
Reference in a new issue