Improve physics
This commit is contained in:
parent
c21025caf6
commit
4ad60813c9
33 changed files with 458 additions and 383 deletions
|
|
@ -1,25 +0,0 @@
|
|||
**/.classpath
|
||||
**/.dockerignore
|
||||
**/.env
|
||||
**/.git
|
||||
**/.gitignore
|
||||
**/.project
|
||||
**/.settings
|
||||
**/.toolstarget
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/*.*proj.user
|
||||
**/*.dbmdl
|
||||
**/*.jfm
|
||||
**/azds.yaml
|
||||
**/bin
|
||||
**/charts
|
||||
**/docker-compose*
|
||||
**/Dockerfile*
|
||||
**/node_modules
|
||||
**/npm-debug.log
|
||||
**/obj
|
||||
**/secrets.dev.yaml
|
||||
**/values.dev.yaml
|
||||
LICENSE
|
||||
README.md
|
||||
4
config/ConfigurationServer/.gitignore
vendored
4
config/ConfigurationServer/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
|||
bin
|
||||
obj
|
||||
.vs
|
||||
*.user
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>.</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30309.148
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigurationServer", "ConfigurationServer.csproj", "{CD78C1FA-1A88-4299-961B-2B5424DBEEDF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{CD78C1FA-1A88-4299-961B-2B5424DBEEDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CD78C1FA-1A88-4299-961B-2B5424DBEEDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CD78C1FA-1A88-4299-961B-2B5424DBEEDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CD78C1FA-1A88-4299-961B-2B5424DBEEDF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5CE906F0-BAD5-4BD3-B3D7-1D26E4D6385C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ConfigurationServer.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
var rng = new Random();
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateTime.Now.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
|
||||
WORKDIR /src
|
||||
COPY ["ConfigurationServer.csproj", ""]
|
||||
RUN dotnet restore "./ConfigurationServer.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/."
|
||||
RUN dotnet build "ConfigurationServer.csproj" -c Release -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "ConfigurationServer.csproj" -c Release -o /app/publish
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
ENTRYPOINT ["dotnet", "ConfigurationServer.dll"]
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ConfigurationServer
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:63198",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"ConfigurationServer": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/weatherforecast",
|
||||
"publishAllPorts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace ConfigurationServer
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace ConfigurationServer
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"projects": {
|
||||
"default": "decla-red"
|
||||
"default": "decla-red
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,5 +60,8 @@
|
|||
"webpack": "^4.43.0",
|
||||
"webpack-cli": "^3.3.11",
|
||||
"webpack-dev-server": "^3.10.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase": "^7.22.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
||||
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
|
||||
|
||||
<title>Decla.red</title>
|
||||
<title>decla.red</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>Javascript is required for this website.</noscript>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { glMatrix } from 'gl-matrix';
|
||||
import { Configuration } from './scripts/config/configuration';
|
||||
import { Game } from './scripts/game';
|
||||
import { Random } from './scripts/helper/random';
|
||||
import './styles/main.scss';
|
||||
|
|
@ -6,6 +7,8 @@ import './styles/main.scss';
|
|||
glMatrix.setMatrixArrayType(Array);
|
||||
|
||||
const main = async () => {
|
||||
await Configuration.initialize();
|
||||
|
||||
try {
|
||||
Random.seed = 42;
|
||||
await new Game().start();
|
||||
|
|
|
|||
30
frontend/src/scripts/config/configuration.ts
Normal file
30
frontend/src/scripts/config/configuration.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import * as firebase from 'firebase/app';
|
||||
import 'firebase/firebase-remote-config';
|
||||
|
||||
export class Configuration {
|
||||
public static async initialize(): Promise<void> {
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyBG85dp-AhaCW-qi_6mu77wDPSipzipIF4',
|
||||
authDomain: 'decla-red.firebaseapp.com',
|
||||
projectId: 'decla-red',
|
||||
appId: '1:635208271441:web:c910843ae7e0549dadda70',
|
||||
};
|
||||
|
||||
firebase.initializeApp(firebaseConfig);
|
||||
|
||||
const remoteConfig = firebase.remoteConfig();
|
||||
remoteConfig.defaultConfig = {
|
||||
online_servers: 'hi',
|
||||
};
|
||||
|
||||
remoteConfig.settings = {
|
||||
minimumFetchIntervalMillis: 3600 * 1000,
|
||||
fetchTimeoutMillis: 15 * 1000,
|
||||
} as any;
|
||||
|
||||
await remoteConfig.ensureInitialized();
|
||||
await remoteConfig.fetchAndActivate();
|
||||
|
||||
console.log(remoteConfig.getValue('online_servers'));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { CircleLight, compile, Flashlight, InvertedTunnel, Renderer } from 'sdf-2d';
|
||||
import {
|
||||
Circle,
|
||||
CircleLight,
|
||||
compile,
|
||||
Flashlight,
|
||||
InvertedTunnel,
|
||||
Renderer,
|
||||
} from 'sdf-2d';
|
||||
import { CommandBroadcaster } from './commands/command-broadcaster';
|
||||
import { MoveToCommand } from './commands/move-to';
|
||||
import { RenderCommand } from './commands/render';
|
||||
import { StepCommand } from './commands/step';
|
||||
import { TeleportToCommand } from './commands/teleport-to';
|
||||
import { DeltaTimeCalculator } from './helper/delta-time-calculator';
|
||||
import { prettyPrint } from './helper/pretty-print';
|
||||
import { rgb } from './helper/rgb';
|
||||
|
|
@ -12,6 +18,7 @@ import { IGame } from './i-game';
|
|||
import { KeyboardListener } from './input/keyboard-listener';
|
||||
import { MouseListener } from './input/mouse-listener';
|
||||
import { TouchListener } from './input/touch-listener';
|
||||
import { GameObject } from './objects/game-object';
|
||||
import { Objects } from './objects/objects';
|
||||
import { Camera } from './objects/types/camera';
|
||||
import { Character } from './objects/types/character';
|
||||
|
|
@ -49,17 +56,21 @@ export class Game implements IGame {
|
|||
...InvertedTunnel.descriptor,
|
||||
shaderCombinationSteps: [0, 2, 4, 8, 16],
|
||||
},
|
||||
{
|
||||
...Flashlight.descriptor,
|
||||
shaderCombinationSteps: [0, 1],
|
||||
},
|
||||
{
|
||||
...BlobShape.descriptor,
|
||||
shaderCombinationSteps: [0, 1],
|
||||
},
|
||||
{
|
||||
...Circle.descriptor,
|
||||
shaderCombinationSteps: [0, 2, 4, 8, 16],
|
||||
},
|
||||
{
|
||||
...CircleLight.descriptor,
|
||||
shaderCombinationSteps: [0, 1, 2, 4, 8, 16],
|
||||
shaderCombinationSteps: [0, 1, 2, 4, 8],
|
||||
},
|
||||
{
|
||||
...Flashlight.descriptor,
|
||||
shaderCombinationSteps: [0, 1],
|
||||
},
|
||||
],
|
||||
{
|
||||
|
|
@ -68,8 +79,6 @@ export class Game implements IGame {
|
|||
enableStopwatch: true,
|
||||
}
|
||||
);
|
||||
this.initializeScene();
|
||||
this.physics.start();
|
||||
}
|
||||
|
||||
public async start(): Promise<void> {
|
||||
|
|
@ -89,6 +98,8 @@ export class Game implements IGame {
|
|||
enableHighDpiRendering: false,
|
||||
lightCutoffDistance: settings.lightCutoffDistance,
|
||||
});
|
||||
this.initializeScene();
|
||||
this.physics.start();
|
||||
requestAnimationFrame(this.gameLoop.bind(this));
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +111,10 @@ export class Game implements IGame {
|
|||
return this.physics.findIntersecting(box);
|
||||
}
|
||||
|
||||
public displayToWorldCoordinates(p: vec2): vec2 {
|
||||
return this.renderer.displayToWorldCoordinates(p);
|
||||
}
|
||||
|
||||
private initializeScene() {
|
||||
createDungeon(this.objects, this.physics);
|
||||
createDungeon(this.objects, this.physics);
|
||||
|
|
@ -109,9 +124,6 @@ export class Game implements IGame {
|
|||
this.character = new Character(this.physics, this);
|
||||
this.objects.addObject(this.character);
|
||||
this.objects.addObject(this.camera);
|
||||
let pos: any = localStorage.getItem('characterPosition');
|
||||
pos = pos ? JSON.parse(pos) : vec2.fromValues(0, 0);
|
||||
this.character.sendCommand(new TeleportToCommand(pos));
|
||||
}
|
||||
|
||||
private deltaTimeCalculator = new DeltaTimeCalculator();
|
||||
|
|
@ -134,7 +146,14 @@ export class Game implements IGame {
|
|||
this.renderer.renderDrawables();
|
||||
|
||||
this.overlay.innerText = prettyPrint(this.renderer.insights);
|
||||
localStorage.setItem('characterPosition', JSON.stringify(this.character.position));
|
||||
requestAnimationFrame(this.gameLoop.bind(this));
|
||||
}
|
||||
|
||||
public addObject(o: GameObject) {
|
||||
this.objects.addObject(o);
|
||||
}
|
||||
|
||||
public removeObject(o: GameObject) {
|
||||
this.objects.removeObject(o);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { GameObject } from './objects/game-object';
|
||||
import { BoundingBoxBase } from './physics/bounds/bounding-box-base';
|
||||
|
||||
export interface IGame {
|
||||
readonly viewArea: BoundingBoxBase;
|
||||
findIntersecting(box: BoundingBoxBase): Array<BoundingBoxBase>;
|
||||
displayToWorldCoordinates(p: vec2): vec2;
|
||||
addObject(o: GameObject): void;
|
||||
removeObject(o: GameObject): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
import { CommandGenerator } from '../commands/command-generator';
|
||||
import { clamp01 } from '../helper/clamp';
|
||||
import { CursorMoveCommand } from './commands/cursor-move-command';
|
||||
import { PrimaryActionCommand } from './commands/primary-action';
|
||||
import { SecondaryActionCommand } from './commands/secondary-action';
|
||||
|
|
@ -12,7 +11,7 @@ export class MouseListener extends CommandGenerator {
|
|||
|
||||
private isMouseDown = false;
|
||||
|
||||
constructor(private target: Element) {
|
||||
constructor(target: Element) {
|
||||
super();
|
||||
|
||||
target.addEventListener('mousedown', (event: MouseEvent) => {
|
||||
|
|
@ -59,11 +58,6 @@ export class MouseListener extends CommandGenerator {
|
|||
}
|
||||
|
||||
private positionFromEvent(event: MouseEvent): vec2 {
|
||||
const bb = this.target.getBoundingClientRect();
|
||||
|
||||
return vec2.fromValues(
|
||||
clamp01((event.clientX - bb.x) / bb.width),
|
||||
clamp01(1 - (event.clientY - bb.y) / bb.height)
|
||||
);
|
||||
return vec2.fromValues(event.clientX, event.clientY);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue