Update bit

This commit is contained in:
giongto35 2019-04-12 01:02:42 +08:00
parent 5102ac9a41
commit 1e6684044c
2 changed files with 3 additions and 1 deletions

View file

@ -138,6 +138,7 @@ document.body.onkeydown = function (e) {
}
}
// game keys
setState(e, true);
}
};

View file

@ -69,7 +69,8 @@ func (view *GameView) ListenToInputChannel() {
for {
keysInBinary := <-view.inputChannel
for i := 0; i < NumKeys*2; i++ {
view.keyPressed[i] = ((keysInBinary & 1) == 1)
b := ((keysInBinary & 1) == 1)
view.keyPressed[i] = (view.keyPressed[i] && b) || b
keysInBinary = keysInBinary >> 1
}
}