Просмотр исходного кода

make movement speed configurable.

Lucas Stadler лет назад: 12
Родитель
Сommit
25d2b2f19c
1 измененных файлов с 7 добавлено и 5 удалено
  1. 7 5
      js/pixl/public/trixl.html

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

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