Pārlūkot izejas kodu

make movement speed configurable.

Lucas Stadler 12 gadi atpakaļ
vecāks
revīzija
25d2b2f19c
1 mainītis faili ar 7 papildinājumiem un 5 dzēšanām
  1. 7 5
      js/pixl/public/trixl.html

+ 7 - 5
js/pixl/public/trixl.html

@ -242,6 +242,8 @@
242 242
243 243
		trixl.start();
244 244
245
		trixl.speed = { move: 0.1, turn: 0.01 }
246
245 247
		trixl.input = {};
246 248
		trixl.input.keys = new Set();
247 249
		document.addEventListener("keydown", function(ev) {
@ -259,16 +261,16 @@
259 261
			}
260 262
261 263
			if (isPressed(37) || isPressed(65)) { // left || a
262
				trixl.camera.sideways(-0.1);
264
				trixl.camera.sideways(-trixl.speed.move);
263 265
			}
264 266
			if (isPressed(38) || isPressed(87)) { // up || w
265
				trixl.camera.forward(-0.1);
267
				trixl.camera.forward(-trixl.speed.move);
266 268
			}
267 269
			if (isPressed(39) || isPressed(68)) { // right || d
268
				trixl.camera.sideways(0.1);
270
				trixl.camera.sideways(trixl.speed.move);
269 271
			}
270 272
			if (isPressed(40) || isPressed(83)) { // down || s
271
				trixl.camera.forward(0.1);
273
				trixl.camera.forward(trixl.speed.move);
272 274
			}
273 275
		});
274 276
@ -285,7 +287,7 @@
285 287
			}
286 288
287 289
			var diff = { x: mouse.last.x - ev.clientX, y: mouse.last.y - ev.clientY };
288
			trixl.camera.rotate(diff.x * 0.01, diff.y * 0.01);
290
			trixl.camera.rotate(diff.x * trixl.speed.turn, diff.y * trixl.speed.turn);
289 291
290 292
			mouse.last = {x: ev.clientX, y: ev.clientY};
291 293
		});