block place / break test (WIP)

This commit is contained in:
biglyderv 2024-09-13 21:25:41 -04:00
parent 1afdddc882
commit 95adfdabdf
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954
4 changed files with 227 additions and 14 deletions

View file

@ -4,7 +4,11 @@ let vel = [0, 0];
let id = '';
function down(e) {
keys[e.key.toLowerCase()] = true;
let k = e.key.toLowerCase();
keys[k] = true;
if (k == 'r') game.placeBlock(6);
if (k == 'f') game.placeBlock(5);
};
function up(e) {
@ -13,8 +17,8 @@ function up(e) {
function move() {
var isShift = keys['q'];
vel[0] += ((keys['a'] ? 1 : 0) - (keys['d'] ? 1 : 0)) * (isShift ? 5 : 1);
vel[1] += ((keys['w'] ? 1 : 0) - (keys['s'] ? 1 : 0)) * (isShift ? 5 : 1);
vel[0] += ((keys['a'] ? 1 : 0) - (keys['d'] ? 1 : 0)) * (isShift ? 2.3 : 1);
vel[1] += ((keys['w'] ? 1 : 0) - (keys['s'] ? 1 : 0)) * (isShift ? 2.3 : 1);
vel[0] *= 0.8;
vel[1] *= 0.8;