Fix collision detection

This commit is contained in:
schmelczerandras 2020-08-17 18:55:47 +02:00
parent 006ab3c4e6
commit 5b4e67cbf0
9 changed files with 169 additions and 49 deletions

View file

@ -2,6 +2,7 @@ import { vec2 } from 'gl-matrix';
import { Physics } from '../../physics/physics';
import { Objects } from '../objects';
import { Tunnel } from '../types/tunnel';
import { Random } from '../../helper/random';
export const createDungeon = (objects: Objects, physics: Physics): Tunnel => {
let previousRadius = 350;
@ -10,10 +11,10 @@ export const createDungeon = (objects: Objects, physics: Physics): Tunnel => {
let first: Tunnel;
for (let i = 0; i < 50000; i += 500) {
const deltaHeight = (Math.random() - 0.5) * 2000;
const deltaHeight = (Random.getRandom() - 0.5) * 2000;
const height = previousEnd.y + deltaHeight;
const currentEnd = vec2.fromValues(i, height);
const currentToRadius = Math.random() * 300 + 150;
const currentToRadius = Random.getRandom() * 300 + 150;
const tunnel = new Tunnel(
physics,
@ -29,15 +30,15 @@ export const createDungeon = (objects: Objects, physics: Physics): Tunnel => {
objects.addObject(tunnel);
/*if (deltaHeight > 0 && Math.random() > 0.8) {
/*if (deltaHeight > 0 && Random.getRandom() > 0.8) {
objects.addObject(
new Lamp(
currentEnd,
Math.random() * 20 + 30,
Random.getRandom() * 20 + 30,
vec3.scale(
vec3.create(),
vec3.normalize(vec3.create(), vec3.fromValues(0.5, 0.1, 0.8)),
Math.random() * 0.5 + 0.5
Random.getRandom() * 0.5 + 0.5
),
1
)