This commit is contained in:
schmelczerandras 2020-08-04 22:07:39 +02:00
parent 24cc572e47
commit 345e183e34
30 changed files with 628 additions and 187 deletions

View file

@ -1,22 +1,35 @@
import { vec2, vec3 } from 'gl-matrix';
import { ObjectContainer } from '../object-container';
import { Lamp } from '../types/lamp';
import { Objects } from '../objects';
import { Tunnel } from '../types/tunnel';
import { Physics } from '../../physics/physics';
import { GameObject } from '../game-object';
export const createDungeon = (objects: ObjectContainer) => {
export const createDungeon = (objects: Objects, physics: Physics): Tunnel => {
let previousRadius = 350;
let previousEnd = vec2.create();
for (let i = 0; i < 500000; i += 500) {
let first: Tunnel;
for (let i = 0; i < 1; i += 500) {
const deltaHeight = (Math.random() - 0.5) * 2000;
const height = previousEnd.y + deltaHeight;
const currentEnd = vec2.fromValues(i, height);
const currentToRadius = Math.random() * 300 + 150;
objects.addObject(
new Tunnel(previousEnd, currentEnd, previousRadius, currentToRadius)
const tunnel = new Tunnel(
physics,
previousEnd,
currentEnd,
previousRadius,
currentToRadius
);
if (!first) {
first = tunnel;
}
objects.addObject(tunnel);
/*if (deltaHeight > 0 && Math.random() > 0.8) {
objects.addObject(
new Lamp(
@ -35,4 +48,6 @@ export const createDungeon = (objects: ObjectContainer) => {
previousEnd = currentEnd;
previousRadius = currentToRadius;
}
return first;
};