-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kinematic model of vehicle done! God bless AMR and Oriolo
- Loading branch information
1 parent
3c0d21a
commit 7c12349
Showing
3 changed files
with
178 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
function getRandomInt(max) { | ||
return Math.floor(Math.random() * Math.floor(max)); | ||
} | ||
} | ||
|
||
KeyPressListener = (function () { | ||
var leftKey = 'ArrowLeft', upKey = 'ArrowUp', rightKey = 'ArrowRight', downKey = 'ArrowDown'; | ||
var keystate = {}; | ||
document.addEventListener("keydown", function (e) { | ||
keystate[e.key] = true; | ||
//console.log(e.key); | ||
}); | ||
document.addEventListener("keyup", function (e) { | ||
delete keystate[e.key]; | ||
//console.log("Release " + e.key); | ||
}); | ||
|
||
function isKeyPressed (key) { | ||
return keystate[key]; | ||
} | ||
|
||
function KeyPressListener() { | ||
|
||
} | ||
|
||
KeyPressListener.prototype = { | ||
|
||
constructor: KeyPressListener, | ||
|
||
isUpPressed: function () { | ||
return isKeyPressed(upKey); | ||
}, | ||
|
||
isDownPressed: function () { | ||
return isKeyPressed(downKey); | ||
}, | ||
|
||
isLeftPressed: function () { | ||
return isKeyPressed(leftKey); | ||
}, | ||
|
||
isRightPressed: function () { | ||
return isKeyPressed(rightKey); | ||
} | ||
}; | ||
|
||
return KeyPressListener | ||
})(); | ||
|
||
function shift(object, x = 0, y = 0, z = 0) { | ||
object.position.x += x; | ||
object.position.y += y; | ||
object.position.z += z; | ||
} |