Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aryeh merge with master #73

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
200fce3
Refactored mainPlayer reducer, turn functions, and when the game star…
harryttd Feb 12, 2017
5ad8a21
Still working on it.
harryttd Feb 12, 2017
d0699f3
Refactored uneeded code like making too many dispatch calls to the st…
harryttd Feb 13, 2017
582f2cf
Cleaned up some code. Got rid of extra dispatch calls to the store. N…
harryttd Feb 13, 2017
bd517e6
Cleaned up some code. When one player crashes does not crash other pl…
harryttd Feb 15, 2017
21fce66
Merge branch 'master' into collision-bug
harryttd Feb 15, 2017
7bebac2
updated readme
harryttd Feb 15, 2017
a61b9e9
Updated tests
harryttd Feb 15, 2017
a642510
Update README.md
harryttd Feb 15, 2017
8d94ab4
Updated stylesheet
harryttd Feb 17, 2017
2cdb822
Merge branch 'collision-bug' of https://github.com/harryttd/3D_Tron i…
harryttd Feb 21, 2017
49d247b
Updated Readme
harryttd Feb 21, 2017
4e196de
Merge pull request #2 from harryttd/collision-bug
harryttd Feb 21, 2017
bcab7c0
Going through code trying to clean up and fix bugs. Refactor
harryttd Feb 26, 2017
3e17ff5
Seems I got automatic dying fixed...
harryttd Feb 26, 2017
cab8140
Moved collision event listener to socket file and put it where we set…
harryttd Feb 26, 2017
fe84bf5
Moved collision listener back to componentDidMount in Game Component
harryttd Feb 26, 2017
45c96a9
Merge pull request #3 from harryttd/collision-bug
harryttd Feb 26, 2017
f7638f2
Delete extra packages from package.json
harryttd Feb 26, 2017
bf393e6
Merge pull request #4 from harryttd/package.json
harryttd Feb 26, 2017
3d08a3d
Cleaned up react components. Fixed server users reducer test.
harryttd Feb 26, 2017
fd2b86e
Passed down props directly to DeadWithWinner component.
harryttd Feb 26, 2017
107b68e
Merge pull request #5 from harryttd/dumb-components
harryttd Feb 26, 2017
04d1b4c
Delete import connect from InGame file
harryttd Feb 26, 2017
cd4de9d
.DS_Store banished!
harryttd Feb 26, 2017
2313d01
Move redux-devtools-extension to regular depen.
harryttd Mar 1, 2017
c1374d0
Move nodemon to dev dep.
harryttd Mar 1, 2017
c62055f
Made game reload when game only had one player.
harryttd Mar 1, 2017
c61f959
Got rid of redux dev tools as they were creating an issue.
harryttd Mar 1, 2017
1292fa2
Add use strict to files
harryttd Mar 2, 2017
426e5f1
Made LobbyRoom component "dumb".
harryttd Mar 2, 2017
0c4f61c
update readme
harryttd Mar 2, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Seems I got automatic dying fixed...
harryttd committed Feb 26, 2017
commit 3e17ff5d318b73a4abac611f5311f52dabfcb7a5
60 changes: 28 additions & 32 deletions browser/components/Game.js
Original file line number Diff line number Diff line change
@@ -9,50 +9,46 @@ import { DeadNoWinner, Winner, DeadWithWinner} from './InGame';

console.log("SOCKET ID LOCAL STORAGE (IN THE FRONT END)", localStorage.getItem('mySocketId'));

class Game extends Component {
constructor(props) {
super(props);
document.addEventListener('keydown', (event) => {
const TURN_AUDIO = document.createElement('audio');
TURN_AUDIO.src = 'mp3/shortBikeTurn.m4a';
TURN_AUDIO.load();
const validKeys = [37, 39, 38, 40, 87, 65, 83, 68];
const player = store.getState().mainPlayer;
if (validKeys.includes(event.keyCode)) {
turnPlayer(event.keyCode, player);
TURN_AUDIO.play();
}
});

class Game extends Component {

componentDidMount() {
const players = this.props.players;
const myPlayer = this.props.mainPlayer;
world.start();
cameraSetOnStart(myPlayer);
players.forEach(player => {
player.si = setInterval(player.tail, 10);
});
myPlayer.ball.add(world.camera);
}

render() {
const TURN_AUDIO = document.createElement('audio');
TURN_AUDIO.src = 'mp3/shortBikeTurn.m4a';
TURN_AUDIO.load();

const player = this.props.mainPlayer;
const validKeys = [37, 39, 38, 40, 87, 65, 83, 68];
player.ball.add(world.camera);

document.addEventListener('keydown', (event) => {
if (validKeys.includes(event.keyCode)) {
turnPlayer(event.keyCode, this.props.mainPlayer);
TURN_AUDIO.play();
}
});

// {
// this.props.mainPlayer.status === 'dead' && this.props.players.filter(player => player.winner === true).length === 0 ? <DeadNoWinner /> : null
// }
// {
// this.props.mainPlayer.status === 'dead' && !this.props.mainPlayer.winner && this.props.players.filter(player => player.winner === true).length === 1 ? <DeadWithWinner /> : null
// }
// return (
//
//
// this.props.mainPlayer.winner ? <div><Winner /></div> : null
//
//
// );
return null;
return (
<div>
{
this.props.mainPlayer.status === 'dead' && this.props.players.filter(player => player.winner === true).length === 0 ? <DeadNoWinner /> : null
}
{
this.props.mainPlayer.status === 'dead' && !this.props.mainPlayer.winner && this.props.players.filter(player => player.winner === true).length === 1 ? <DeadWithWinner /> : null
}

{
this.props.mainPlayer.winner ? <Winner /> : null
}
</div>
);
}
}

4 changes: 2 additions & 2 deletions browser/game/gamePlayFunctions.js
Original file line number Diff line number Diff line change
@@ -112,13 +112,13 @@ export const collisionHandler = player => {
world.scene.remove(player.ball.native);
world.scene.remove(player.bike.native);
if (player.id === me.id) {
player.ball.remove(world.camera);
me.ball.remove(world.camera);
world.setControls(new WHS.OrbitControls());
store.dispatch(onDeathMainPlayer(me));
}

// WHEN THIS IS USED WE GET OUR PROBLEM
// store.dispatch(onDeath(player));
store.dispatch(onDeath(player));
if (player.walls.length !== 0) {
player.walls.forEach(wall => world.scene.remove(wall.native));
}
3 changes: 1 addition & 2 deletions browser/socket.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ export const initializeSocket = () => {
// console.log("collidedWith", collidedWith);
socket.emit('ball-collision', {signature: myBike.signature, id: myBike.id});
});
cameraSetOnStart(myBike);
});

socket.on('addPlayerName', (socketId, playerName) => {
@@ -97,7 +96,7 @@ export const initializeSocket = () => {
console.log("lastStanding", lastStanding);
store.dispatch(declareWinner(lastStanding));
console.log("END GAME", store.getState().players);
// setTimeout(() => window.location.reload(true), 10000);
setTimeout(() => window.location.reload(true), 10000);
});
};

12 changes: 6 additions & 6 deletions server/reducers/users.js
Original file line number Diff line number Diff line change
@@ -58,12 +58,12 @@ const removeUserAndEmit = socket => {
// };
/* --------------- REDUCER --------------- */
const initialState = [
{id: ''},
{id: ''},
{id: ''},
{id: ''},
{id: ''},
{id: ''}
{id: '', active: false, readyToPlay: false},
{id: '', active: false, readyToPlay: false},
{id: '', active: false, readyToPlay: false},
{id: '', active: false, readyToPlay: false},
{id: '', active: false, readyToPlay: false},
{id: '', active: false, readyToPlay: false}
];

function userReducer (state = initialState, action) {