visual fixes
This commit is contained in:
parent
230124e9af
commit
f308fb1a40
@ -9,7 +9,7 @@ color = 0
|
||||
vertical = 0
|
||||
playersInGame = []
|
||||
# Testing 1 Player for now
|
||||
maxPlayers = 1
|
||||
maxPlayers = 2
|
||||
timeLeft = 11.0
|
||||
|
||||
# Renders client
|
||||
|
||||
@ -4,7 +4,6 @@ var username;
|
||||
var playerTeam;
|
||||
var timer;
|
||||
var type;
|
||||
var username;
|
||||
var playerColor;
|
||||
var claimColor;
|
||||
var turn = 0;
|
||||
@ -12,6 +11,7 @@ var spectatorChoose = 1;
|
||||
var spectatedUser;
|
||||
var numberOfPlayers;
|
||||
var canMove = false;
|
||||
|
||||
// Colors
|
||||
var playerColors = {
|
||||
"red": "#E62E2E",
|
||||
@ -20,7 +20,7 @@ var playerColors = {
|
||||
var claimedColors = {
|
||||
"red": "#FF9999",
|
||||
"blue": "#9999FF"
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementsByClassName('play')[0].onclick = function startGame() {
|
||||
uuid4 = function() {
|
||||
@ -45,8 +45,7 @@ document.getElementsByClassName('play')[0].onclick = function startGame() {
|
||||
// Update score before creating player so scoreboard starts at 0
|
||||
updateScore();
|
||||
waitForPlayers(username);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function getInitial() {
|
||||
$.ajax({
|
||||
@ -56,8 +55,8 @@ function getInitial() {
|
||||
// data: '',
|
||||
success: function(data) {
|
||||
//called when successful
|
||||
playerCoordinate = data["coordinate"];
|
||||
playerTeam = data["team"];
|
||||
playerCoordinate = data.coordinate;
|
||||
playerTeam = data.team;
|
||||
},
|
||||
error: function(e) {
|
||||
//called when there is an error
|
||||
@ -86,13 +85,13 @@ function serverTransfer(coordinate,team,turn,username) {
|
||||
.then(
|
||||
function success(data) {
|
||||
for (var user in data) {
|
||||
if (data.hasOwnProperty(user)
|
||||
&& (user != username)
|
||||
&& (data[user].length > turn)
|
||||
&& (data[user][turn][2] != "spectator")
|
||||
if (data.hasOwnProperty(user) &&
|
||||
(user != username) &&
|
||||
(data[user].length > turn) &&
|
||||
(data[user][turn][2] != "spectator")
|
||||
) {
|
||||
if ((data[user].length > data[spectatedUser].length)
|
||||
&& data[spectatedUser][turn][2] === "spectator") {
|
||||
if ((data[user].length > data[spectatedUser].length) &&
|
||||
data[spectatedUser][turn][2] === "spectator") {
|
||||
spectatedUser = user;
|
||||
}
|
||||
var theMove = data[user][turn];
|
||||
@ -120,11 +119,11 @@ function waitForPlayers(uuid4) {
|
||||
data: JSON.stringify(uuid4, null, '\t'),
|
||||
async: false,
|
||||
dataType: "json",
|
||||
contentType: 'application/json;charset=UTF-8',
|
||||
contentType: 'application/json;charset=UTF-8'
|
||||
})
|
||||
.then(
|
||||
function success(data) {
|
||||
numberOfPlayers = data["playersInGame"];
|
||||
numberOfPlayers = data.playersInGame;
|
||||
if (numberOfPlayers == 1) {
|
||||
countdown();
|
||||
// try catch delete table for visuals later.
|
||||
@ -148,10 +147,10 @@ function countdown() {
|
||||
type: 'GET',
|
||||
async: false,
|
||||
success: function(data) {
|
||||
timeLeft = data["timeLeft"];
|
||||
console.log(data)
|
||||
timeLeft = data.timeLeft;
|
||||
console.log(data);
|
||||
//MAKE VISUAL STUFF HERE
|
||||
if(timeLeft == 0) {
|
||||
if(timeLeft === 0) {
|
||||
canMove = true;
|
||||
createPlayer();
|
||||
autoScroll('start');
|
||||
@ -164,7 +163,7 @@ function countdown() {
|
||||
//called when there is an error
|
||||
//(e.message);
|
||||
}
|
||||
})
|
||||
});
|
||||
}, 750); //Prevent too many requests
|
||||
}
|
||||
|
||||
@ -173,7 +172,7 @@ function countdown() {
|
||||
// Creation of Table
|
||||
|
||||
function createTable() {
|
||||
var body = document.body
|
||||
var body = document.body;
|
||||
var tbl = document.createElement('table');
|
||||
tbl.style.border = "1px solid black";
|
||||
for(var i = 0; i < 20; i++) {
|
||||
@ -228,7 +227,7 @@ function updateOldTable(coordinate, team) {
|
||||
otherPlayer = table.rows[coordinate[0]].cells[coordinate[1]];
|
||||
otherPlayer.style.backgroundColor = claimedColors[team];
|
||||
otherPlayer.className = otherPlayer.className.replace("player ", "");
|
||||
otherPlayer.id = ""
|
||||
otherPlayer.id = "";
|
||||
}
|
||||
|
||||
function updateScore() {
|
||||
@ -256,10 +255,10 @@ function movement(x,y) {
|
||||
timer =
|
||||
setTimeout(function() {
|
||||
try {
|
||||
if (nextSquare == undefined
|
||||
|| nextSquare.className.includes('player')
|
||||
|| playerTeam === "spectator"
|
||||
|| nextSquare.className.includes(playerTeam)) {
|
||||
if (nextSquare === undefined ||
|
||||
nextSquare.className.includes('player') ||
|
||||
playerTeam === "spectator" ||
|
||||
nextSquare.className.includes(playerTeam)) {
|
||||
killPlayer(playerCoordinate, playerTeam);
|
||||
}
|
||||
else {
|
||||
@ -301,11 +300,11 @@ function movePlayer(e) {
|
||||
clearTimeout(timer);
|
||||
movement(0,1);
|
||||
} else if (e.keyCode === 37 && type != "left") {
|
||||
type = "left"
|
||||
type = "left";
|
||||
clearTimeout(timer);
|
||||
movement(-1,0);
|
||||
} else if (e.keyCode === 39 && type != "right") {
|
||||
type = "right"
|
||||
type = "right";
|
||||
clearTimeout(timer);
|
||||
movement(1,0);
|
||||
}
|
||||
@ -340,7 +339,7 @@ function spectatorMode() {
|
||||
spectatorType = 'spectatorFull';
|
||||
spectatorFull();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function spectatorFull() {
|
||||
@ -360,7 +359,7 @@ function autoScroll(type) {
|
||||
} else if (type == "spectator") {
|
||||
$('body').scrollTo(document.getElementById(spectatedUser), 100, {offset: {top: center[0] , left: center[1]} });
|
||||
} else {
|
||||
alert("Broken?")
|
||||
alert("Broken?");
|
||||
// $('body').scrollTo(document.getElementById(username), 100, {offset: {top: center[0] , left: center[1]} });
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user