-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from FAC-11/shooting-socket
Shooting socket
- Loading branch information
Showing
13 changed files
with
271 additions
and
9,381 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let bulletData = {}; | ||
|
||
const getId = (id) => { | ||
return id ? bulletData[id] : bulletData; | ||
} | ||
|
||
const set = (id, data) =>{ | ||
return bulletData[id] = data; | ||
} | ||
|
||
module.exports = { getId, set}; |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
|
||
|
||
const THREE = require('three'); | ||
const pointLockers = require('./pointLockers'); | ||
const getScene = require('./getScene'); | ||
// const shoot = require('./shoot.js'); | ||
|
||
const {movements} = require('./controls'); | ||
const getRaycaster = require('./getRaycaster'); | ||
|
||
|
||
const velocity = new THREE.Vector3(); | ||
|
||
function guid() { | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000) | ||
.toString(16) | ||
.substring(1); | ||
} | ||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + | ||
s4() + '-' + s4() + s4() + s4(); | ||
} | ||
|
||
const getBullet = () => { | ||
var bullet = new THREE.Mesh( | ||
new THREE.SphereGeometry(0.5, 8, 8), | ||
new THREE.MeshBasicMaterial()); | ||
|
||
const scene = getScene(); | ||
|
||
const raycaster = getRaycaster(); | ||
bullet.position.set( | ||
raycaster.ray.origin.x, | ||
raycaster.ray.origin.y, | ||
raycaster.ray.origin.z | ||
); | ||
|
||
const player = pointLockers(); | ||
|
||
bullet.velocity = new THREE.Vector3( | ||
-Math.sin(player.rotation._y), | ||
0, | ||
-Math.cos(player.rotation._y), | ||
); | ||
|
||
bullet.alive = true; | ||
bullet.randomid = guid(); | ||
|
||
|
||
setTimeout(function() { | ||
bullet.alive = false; | ||
scene.remove(bullet); | ||
}, 1000); | ||
|
||
return bullet; | ||
} | ||
|
||
module.exports = getBullet; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let _raycaster; | ||
|
||
module.exports = () => | ||
_raycaster; | ||
|
||
module.exports.init = (raycaster) => { | ||
_raycaster = raycaster; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let otherBullets = {}; | ||
|
||
const get = () => otherBullets; | ||
|
||
const addBullets = (randomid, bullet) => { | ||
otherBullets[randomid] = bullet; | ||
|
||
}; | ||
|
||
module.exports ={ | ||
get, | ||
addBullets | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.