block place / break test (WIP)
This commit is contained in:
parent
1afdddc882
commit
95adfdabdf
4 changed files with 227 additions and 14 deletions
10
js/motion.js
10
js/motion.js
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue