Make physics more fun

This commit is contained in:
schmelczerandras 2020-10-16 11:48:52 +02:00
parent 155e360c8e
commit 89fafeafd3
41 changed files with 511 additions and 334 deletions

View file

@ -27,7 +27,7 @@ export class Camera extends GameObject implements ViewObject {
renderer.setViewArea(viewArea.topLeft, viewArea.size);
renderer.setRuntimeSettings({
backgroundColor: mixRgb(
ambientLight: mixRgb(
settings.backgroundGradient[0],
settings.backgroundGradient[1],
(this.center.x - settings.worldLeftEdge) /

View file

@ -1,11 +1,11 @@
import { vec2 } from 'gl-matrix';
import { Drawable, Renderer } from 'sdf-2d';
import { CommandExecutors, Id, Random, StoneBase } from 'shared';
import { CommandExecutors, Id, Random, PlanetBase } from 'shared';
import { RenderCommand } from '../commands/types/render';
import { Polygon } from '../shapes/polygon';
import { ViewObject } from './view-object';
export class StoneView extends StoneBase implements ViewObject {
export class PlanetView extends PlanetBase implements ViewObject {
private shape: Drawable;
protected commandExecutors: CommandExecutors = {
@ -14,11 +14,12 @@ export class StoneView extends StoneBase implements ViewObject {
constructor(id: Id, vertices: Array<vec2>) {
super(id, vertices);
this.shape = new Polygon(vertices, Random.getRandom());
this.shape = new Polygon(vertices);
(this.shape as any).randomOffset = Random.getRandom();
}
public step(deltaTimeInMilliseconds: number): void {
this.shape.randomOffset += deltaTimeInMilliseconds / 5000;
(this.shape as any).randomOffset += deltaTimeInMilliseconds / 4000;
}
public draw(renderer: Renderer): void {

View file

@ -1,10 +1,11 @@
import { vec2 } from 'gl-matrix';
import { Circle, CircleLight, Renderer } from 'sdf-2d';
import { CircleLight, Renderer } from 'sdf-2d';
import { Id, ProjectileBase, rgb } from 'shared';
import { ViewObject } from './view-object';
import { Circle } from '../shapes/circle';
export class ProjectileView extends ProjectileBase implements ViewObject {
private circle: Circle;
private circle: InstanceType<typeof Circle>;
private light: CircleLight;
constructor(id: Id, center: vec2, radius: number) {