Skip to content

Commit

Permalink
Add bounds to pitch (#12)
Browse files Browse the repository at this point in the history
* Add bounds to pitch

* run linter
  • Loading branch information
AwesomestCode authored Feb 28, 2021
1 parent b6b6579 commit fb1e579
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const { WorldView, Viewer } = require('prismarine-viewer/viewer')
global.THREE = require('three')
const chat = require('./lib/chat')

const maxPitch = 0.5 * Math.PI
const minPitch = -0.5 * Math.PI

async function main () {
const viewDistance = 6
const host = prompt('Host', '95.111.249.143')
Expand Down Expand Up @@ -65,7 +68,9 @@ async function main () {

function moveCallback (e) {
bot.entity.pitch -= e.movementY * 0.01
bot.entity.pitch = Math.max(minPitch, Math.min(maxPitch, bot.entity.pitch))
bot.entity.yaw -= e.movementX * 0.01

viewer.setFirstPersonCamera(bot.entity.position, bot.entity.yaw, bot.entity.pitch)
}
function changeCallback () {
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
"client"
],
"author": "Romain Beaumont",
"contributors" : [
{"name":"AwesomestCode"},
{"name":"circuit10"}
"contributors": [
{
"name": "AwesomestCode"
},
{
"name": "circuit10"
}
],
"license": "MIT",
"bin": {
Expand Down

0 comments on commit fb1e579

Please sign in to comment.