Skip to content

Commit 0d77eeb

Browse files
committed
mesh translations
1 parent ba685e3 commit 0d77eeb

File tree

30 files changed

+261
-162
lines changed

30 files changed

+261
-162
lines changed

Client/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta charset="utf-8" />
66
<link rel="preconnect" href="https://registry.daud.io" />
77
<link rel="preconnect" href="https://www.googletagmanager.com" />
8-
<link rel="canonical" href="https://daud.io/" />
98
<meta name="viewport"
109
content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover, user-scalable=no" />
1110
<title>DAUD.io | Play for free online!</title>

Client/public/assets/base/info.json renamed to Client/public/assets/base/info.unused.json

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"ship": {
44
"abstract": true,
55
"modes": {
6+
"armed": "armed",
67
"default": "ship",
78
"defenseupgrade": "defenseupgrade",
89
"offenseupgrade": "offenseupgrade",
@@ -194,6 +195,12 @@
194195
"height": 1,
195196
"size": 0.02
196197
},
198+
"armed": {
199+
"url": "particle.png",
200+
"height": 1,
201+
"width": 1,
202+
"size": 1
203+
},
197204
"boost": {
198205
"url": "thruster.png",
199206
"offset": {

Client/public/assets/themes/original/info.json renamed to Client/public/assets/themes/original/info.unused.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
2-
"sprites": {},
2+
"sprites": {
3+
4+
5+
},
36
"textures": {
47
"ship": {
58
"size": 2.56,
@@ -11,6 +14,12 @@
1114
"url": "ship0.png",
1215
"extends": "ship"
1316
},
17+
"armed": {
18+
"url": "ship_armed.png",
19+
"size": 2.56,
20+
"width": 128,
21+
"height": 128
22+
},
1423
"ship_flash": {
1524
"url": "ship_flash.png",
1625
"extends": "ship"
Loading

Client/src/assets/base.json

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"ship": {
44
"abstract": true,
55
"modes": {
6+
"armed": "armed",
67
"default": "ship",
78
"defenseupgrade": "defenseupgrade",
89
"offenseupgrade": "offenseupgrade",
@@ -188,6 +189,12 @@
188189
"height": 44,
189190
"size": 0.02
190191
},
192+
"armed": {
193+
"url": "particle.png",
194+
"width": 1,
195+
"height": 1,
196+
"size": 0
197+
},
191198
"ship_haste": {
192199
"url": "particle.png",
193200
"width": 1,

Client/src/assets/original.json

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
"width": 128,
88
"height": 128
99
},
10+
"armed": {
11+
"size": 2.56,
12+
"url": "ship_armed.png",
13+
"width": 128,
14+
"height": 128
15+
},
1016
"ship0": {
1117
"url": "ship0.png",
1218
"extends": "ship"

Client/src/cache.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class Cache {
133133
const groupDeletesLength = newView.groupdeletesLength();
134134
for (let d = 0; d < groupDeletesLength; d++) {
135135
const key = newView.groupdeletes(d)!;
136-
console.log(`delete group: ${key}`)
136+
//console.log(`delete group: ${key}`)
137137
const group = this.getGroup(key);
138138
if (!group) console.log("group delete on object not in cache");
139139
if (group && group.renderer) group.renderer.dispose();
@@ -148,7 +148,7 @@ export class Cache {
148148
newView.groups(u, group)!;
149149
let existing = this.getGroup(group.group());
150150
if (!existing) {
151-
console.log(`new group ${group.group()} ${group.type()} ${group.caption()}`);
151+
//console.log(`new group ${group.group()} ${group.type()} ${group.caption()}`);
152152
const clientGroup = this.groupFromServer(group);
153153
if (clientGroup.Type == 1)
154154
clientGroup.renderer = new Fleet(this.container);

Client/src/controls.ts

+51-40
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Cookies } from "./cookies";
33
import { Picker } from "emoji-picker-element";
44
import { GameContainer } from "./gameContainer";
55
import * as bus from "./bus";
6-
import { Matrix } from "@babylonjs/core";
6+
import { ContainerAssetTask, Matrix, SubEmitter } from "@babylonjs/core";
77

88
const secretShips = ["ship_secret", "ship_zed"];
99

@@ -59,44 +59,48 @@ bus.on("pageReady", function () {
5959
});
6060

6161
window.addEventListener("keydown", ({ key }) => {
62-
if (key.toLowerCase() == "s") {
63-
Controls.boostKeyboard = true;
64-
sendControlPacket();
65-
}
66-
if (key == " ") {
67-
Controls.shootKeyboard = true;
68-
sendControlPacket();
69-
}
70-
71-
if (key.toLowerCase() == "m") {
72-
bus.emit("mapShow");
62+
if (Controls.container?.alive) {
63+
switch (key.toLowerCase()) {
64+
case "s":
65+
Controls.boostKeyboard = true;
66+
sendControlPacket();
67+
break;
68+
case " ":
69+
Controls.shootKeyboard = true;
70+
sendControlPacket();
71+
break;
72+
}
7373
}
7474

75-
76-
if (key.toLowerCase() == "e" && document.body.classList.contains("alive")) {
77-
// Autofire
78-
Controls.toggleAutofire();
79-
}
75+
if (Controls.container?.alive || Controls.container?.spectating) {
76+
switch (key.toLowerCase()) {
77+
case "m":
78+
Controls.toggleMapView();
79+
break;
80+
case "e":
81+
Controls.toggleAutofire();
82+
break;
83+
}
84+
}
8085
});
8186

8287
window.addEventListener("keyup", ({ key }) => {
83-
if (key.toLowerCase() == "s") {
84-
Controls.boostKeyboard = false;
85-
sendControlPacket();
86-
}
87-
if (key == " ") {
88-
Controls.shootKeyboard = false;
89-
sendControlPacket();
90-
}
91-
92-
if (key.toLowerCase() == "m") {
93-
bus.emit("mapHide");
88+
if (Controls.container?.alive) {
89+
switch (key.toLowerCase()) {
90+
case "s":
91+
Controls.boostKeyboard = false;
92+
sendControlPacket();
93+
break;
94+
case " ":
95+
Controls.shootKeyboard = false;
96+
sendControlPacket();
97+
break;
98+
}
9499
}
95-
96100
});
97101

98102
document.body.addEventListener("contextmenu", (e) => {
99-
if (document.body.classList.contains("alive")) {
103+
if (Controls.container?.alive) {
100104
e.preventDefault();
101105
return false;
102106
}
@@ -153,6 +157,7 @@ export const Controls = {
153157

154158
spectateControl: "" as string | undefined,
155159
spectateDebounce: false,
160+
mapView: false,
156161

157162
requestPointerLock() {
158163
console.log('requesting lock');
@@ -191,10 +196,18 @@ export const Controls = {
191196
autofTgg.innerHTML = "OFF";
192197
}
193198
sendControlPacket();
199+
},
200+
201+
toggleMapView() {
202+
if (!Controls.mapView)
203+
bus.emit('mapShow');
204+
else
205+
bus.emit('mapHide');
206+
207+
Controls.mapView = !Controls.mapView;
194208
}
195209
};
196210

197-
198211
bus.on('postrender', (gametime) => {
199212
Controls.pointerSpeed += Math.abs(Controls.mouseX - Controls.previousMouseX) + Math.abs(Controls.mouseY - Controls.previousMouseY);
200213
Controls.pointerSpeed *= 0.9;
@@ -208,7 +221,7 @@ function sendControlPacket() {
208221
}
209222

210223
function mouseUp(this: any, ev: MouseEvent): any {
211-
224+
212225
switch (ev.button) {
213226
case 2:
214227
Controls.boostPointer = false;
@@ -220,8 +233,7 @@ function mouseUp(this: any, ev: MouseEvent): any {
220233
sendControlPacket();
221234
}
222235

223-
function spectateActionNext()
224-
{
236+
function spectateActionNext() {
225237
console.log('spectate next');
226238
Controls.spectateControl = "action:next";
227239
sendControlPacket();
@@ -249,14 +261,13 @@ function mouseMove(this: any, ev: MouseEvent): any {
249261
let scale = 1.5;
250262

251263
if (Controls.container!.pointerLocked) {
252-
264+
253265
Controls.mouseX += ev.movementX * scale;
254266
Controls.mouseY -= ev.movementY * scale;
255267
Controls.mouseX = Math.max(Math.min(Controls.mouseX, rect.width * scale), -rect.width * scale);
256268
Controls.mouseY = Math.max(Math.min(Controls.mouseY, rect.height * scale), -rect.height * scale);
257269
}
258-
else
259-
{
270+
else {
260271
const container = Controls.container!;
261272
const ray = container.scene.createPickingRay(ev.clientX, ev.clientY, Matrix.Identity(), container.camera);
262273
const pos = ray.intersectsAxis("y", 100);
@@ -279,13 +290,13 @@ export function registerContainer(container: GameContainer): void {
279290
joystick = new VirtualJoystick({
280291
container: document.getElementById("nipple-zone")!,
281292
});
282-
293+
283294
document.body.classList.add('touchscreen');
284-
295+
285296
Controls.container!.touchscreen = true;
286297
Controls.toggleAutofire();
287298
}
288-
299+
289300
joystick.onExtraTap((x: number, y: number) => {
290301
const ray = container.scene.createPickingRay(x, y, Matrix.Identity(), container.camera);
291302
const pos = ray.intersectsAxis("y", 100);

Client/src/game.ts

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ bus.on("dead", () => {
8282
document.body.classList.remove("alive");
8383
document.body.classList.add("spectating");
8484
document.body.classList.add("dead");
85+
container.spectating = true;
8586
});
8687

8788
bus.on("worldview", (newView: NetWorldView) => {
@@ -135,6 +136,7 @@ bus.on("worldview", (newView: NetWorldView) => {
135136
function doSpawn() {
136137
document.body.classList.remove("dead");
137138
document.body.classList.remove("spectating");
139+
container.spectating = false;
138140
document.body.classList.add("alive");
139141
connection.sendSpawn(Controls.emoji + Controls.nick, Controls.color, Controls.ship, getToken());
140142
container.focus();
@@ -168,6 +170,7 @@ document.getElementById('nick')?.addEventListener("selectstart", (e) => {
168170
function startSpectate(hideButton = false) {
169171
document.body.classList.add("spectating");
170172
document.body.classList.add("dead");
173+
container.spectating = true;
171174

172175
if (hideButton) {
173176
document.body.classList.add("spectate_only");
@@ -179,6 +182,7 @@ document.getElementById("spectate")!.addEventListener("click", () => startSpecta
179182
function stopSpectate() {
180183
document.body.classList.remove("spectating");
181184
document.body.classList.remove("spectate_only");
185+
container.spectating = false;
182186
}
183187

184188
const deathScreen = document.getElementById("deathScreen")!;

Client/src/gameContainer.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class GameContainer {
6161
boundingRect: DOMRect;
6262
pointerLocked: boolean = false;
6363
alive: boolean = false;
64+
spectating: boolean = false;
6465
touchscreen: boolean = false;
6566
backgrounded: boolean = false;
6667
lastGameTime: number = 0;
@@ -130,7 +131,6 @@ export class GameContainer {
130131
this.alive = false;
131132
});
132133
bus.emit("dead");
133-
134134
}
135135

136136
focus() {
@@ -146,12 +146,13 @@ export class GameContainer {
146146
this.scene.detachControl();
147147
camera.detachControl();
148148

149+
149150
return camera;
150151
}
151152

152153
setupLights() {
153154
this.light = new HemisphericLight("containerLight", new Vector3(0, 1, 0), this.scene);
154-
this.light.intensity *= 0.3;
155+
this.light.intensity *= 0.4;
155156
}
156157

157158
positionCamera(newPosition: Vector2) {

0 commit comments

Comments
 (0)