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

Fixed everything #217

Open
wants to merge 55 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
c7c7315
Added Turret
sabsbremer Jul 27, 2016
1b9f764
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 27, 2016
a9dbf43
Shooring Turret
sabsbremer Jul 27, 2016
9718602
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 27, 2016
b24a66a
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 28, 2016
ae6f159
2. movement prepared
sabsbremer Jul 28, 2016
5c01aea
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 28, 2016
d893309
FIxed Meshes
sabsbremer Jul 28, 2016
51acfae
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 28, 2016
3ab5a23
Fixed Console Errors
sabsbremer Jul 28, 2016
62e4c8f
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 28, 2016
b9b9013
Fixed Ratio
sabsbremer Jul 28, 2016
cd3902d
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 28, 2016
a2ca9a9
hanged Rocket Symbol
sabsbremer Jul 29, 2016
5e39d96
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 29, 2016
2fca093
Fixed TurretLaser
sabsbremer Jul 29, 2016
d577d58
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 29, 2016
dab12b1
Merge pull request #136 from cebremer/dev
Varaion Jul 29, 2016
c9c0160
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 1, 2016
da67261
Kein Plan
sabsbremer Aug 3, 2016
69aa654
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 3, 2016
d71ed98
Added Server structure
sabsbremer Aug 3, 2016
3ddd787
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 3, 2016
382ba3c
Changed the minorest bug...
sabsbremer Aug 3, 2016
97c36e7
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 3, 2016
8450149
Wenn du jetzt nochmal mergest bevor ich den Pull request raus habe ka…
sabsbremer Aug 3, 2016
c93c882
Merge pull request #186 from cebremer/dev
Varaion Aug 3, 2016
9fd4147
Merge branch 'dev' of https://github.com/OsnaCS/space-game into dev
Aug 3, 2016
5936ce3
Added Chat
sabsbremer Aug 4, 2016
a5273f6
Merge branch 'dev' of https://github.com/cebremer/space-game into dev
sabsbremer Aug 4, 2016
30d1868
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
8f1d9ef
MySQL Connection and REST Api under /api/1/highscore
Aug 4, 2016
79b0792
server config file added
Aug 4, 2016
45cb8d3
Fixed Chat
sabsbremer Aug 4, 2016
fc33a76
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
eb4f23a
Merge branch 'Multiplayer' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
e46534b
Changed Names
sabsbremer Aug 4, 2016
a8c9b50
Merge pull request #199 from jvogtherr/Multiplayer
Varaion Aug 4, 2016
c62323e
fixing conflicts
VaraionPrivate Aug 4, 2016
2232eb1
API hotfix
Aug 4, 2016
c8ac1c7
Merge branch 'Multiplayer' of github.com:OsnaCS/space-game into Multi…
Aug 4, 2016
99495e9
Merge pull request #205 from jvogtherr/Multiplayer
Varaion Aug 4, 2016
580c870
Changed Multiplayer for Servers
sabsbremer Aug 4, 2016
cf9860c
Merge branch 'Multiplayer' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
e432c95
You can actually use P in Chat
sabsbremer Aug 4, 2016
6fc616a
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
c17a34c
Removed Turret
sabsbremer Aug 4, 2016
f0bd049
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
9c93b1c
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
483276f
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
dea85a3
...
sabsbremer Aug 4, 2016
523cd36
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Aug 4, 2016
36aa4ce
Update serverconfig.json
sabsbremer Aug 4, 2016
24aecf0
Changed Cross Position
sabsbremer Aug 5, 2016
7f08b19
Merge branch 'dev' of https://github.com/cebremer/space-game into dev
sabsbremer Aug 5, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 14 additions & 0 deletions app/Chat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var socket = io();
var scroll = 0;

$('#form').submit(function(){
console.log("Hallo");
socket.emit('chat message', localStorage.getItem('player') + ': ' + $('#m').val());
$('#m').val('');
return false;
});
socket.on('chat message', function(msg) {
var message = $('#messages');
var list = document.getElementById("messages");
message.append($('<li>').text(msg));
});
106 changes: 59 additions & 47 deletions app/Collision.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
var Collision = function () {


var x,y,z;
var globalXs = [];
var globalYs = [];
var globalZs = [];
var globalMXs = [];
var globalMYs = [];
var globalMZs = [];

/************************* MIN AND MAX FUNCTIONS *************************/

Expand All @@ -10,7 +16,7 @@ var Collision = function () {
function minX(box) {

// array for x values
var globalXs = [];
globalXs = [];
// get the position of each vertex
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
// get the local position of the vertex
Expand All @@ -27,19 +33,19 @@ var Collision = function () {
// Calculates the max X value of the vertices of a box
function maxX(box) {

var globalXs = [];
globalMXs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
var localVertex = box.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4(box.matrix);
globalXs.push(globalVertex.x);
globalMXs.push(globalVertex.x);
}
return Math.max.apply(Math, globalXs);
return Math.max.apply(Math, globalMXs);
}

// Calculates the min Y value of the vertices of a box
function minY(box) {

var globalYs = [];
globalYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
var localVertex = box.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4(box.matrix);
Expand All @@ -51,19 +57,19 @@ var Collision = function () {
// Calculates the max Y value of the vertices of a box
function maxY(box) {

var globalYs = [];
globalMYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
var localVertex = box.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4(box.matrix);
globalYs.push(globalVertex.y);
globalMYs.push(globalVertex.y);
}
return Math.max.apply(Math, globalYs);
return Math.max.apply(Math, globalMYs);
}

// Calculates the min Z value of the vertices of a box
function minZ(box) {

var globalZs = [];
globalZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
var localVertex = box.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4(box.matrix);
Expand All @@ -75,20 +81,20 @@ var Collision = function () {
// Calculates the max Z value of the vertices of a box
function maxZ(box) {

var globalZs = [];
globalMZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
var localVertex = box.geometry.vertices[vertexIndex].clone();
var globalVertex = localVertex.applyMatrix4(box.matrix);
globalZs.push(globalVertex.z);
globalMZs.push(globalVertex.z);
}
return Math.max.apply(Math, globalZs);
return Math.max.apply(Math, globalMZs);
}

// Calculates the min x value of the vertices of a box
function minXship(box) {

// array for x values
var globalXs = [];
globalXs = [];
// get the position of each vertex
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalXs.push(box.geometry.vertices[vertexIndex].x + ship.position.x);
Expand All @@ -100,17 +106,17 @@ var Collision = function () {
// Calculates the max X value of the vertices of a box
function maxXship(box) {

var globalXs = [];
globalMXs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalXs.push(box.geometry.vertices[vertexIndex].x + ship.position.x);
globalMXs.push(box.geometry.vertices[vertexIndex].x + ship.position.x);
}
return Math.max.apply(Math, globalXs);
return Math.max.apply(Math, globalMXs);
}

// Calculates the min Y value of the vertices of a box
function minYship(box) {

var globalYs = [];
globalYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalYs.push(box.geometry.vertices[vertexIndex].y + ship.position.y);
}
Expand All @@ -120,17 +126,17 @@ var Collision = function () {
// Calculates the max Y value of the vertices of a box
function maxYship(box) {

var globalYs = [];
globalMYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalYs.push(box.geometry.vertices[vertexIndex].y + ship.position.y);
globalMYs.push(box.geometry.vertices[vertexIndex].y + ship.position.y);
}
return Math.max.apply(Math, globalYs);
return Math.max.apply(Math, globalMYs);
}

// Calculates the min Z value of the vertices of a box
function minZship(box) {

var globalZs = [];
globalZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalZs.push(box.geometry.vertices[vertexIndex].z + ship.position.z);
}
Expand All @@ -140,19 +146,19 @@ var Collision = function () {
// Calculates the max Z value of the vertices of a box
function maxZship(box) {

var globalZs = [];
globalMZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalZs.push(box.geometry.vertices[vertexIndex].z + ship.position.z);
globalMZs.push(box.geometry.vertices[vertexIndex].z + ship.position.z);
}
return Math.max.apply(Math, globalZs);
return Math.max.apply(Math, globalMZs);
}


// Calculates the min x value of the vertices of a box
function minXenemy(box, i) {

// array for x values
var globalXs = [];
globalXs = [];
// get the position of each vertex
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalXs.push(box.geometry.vertices[vertexIndex].x + enemies[i].position.x);
Expand All @@ -164,37 +170,37 @@ var Collision = function () {
// Calculates the max X value of the vertices of a box
function maxXenemy(box, i) {

var globalXs = [];
globalMXs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalXs.push(box.geometry.vertices[vertexIndex].x + enemies[i].position.x);
globalMXs.push(box.geometry.vertices[vertexIndex].x + enemies[i].position.x);
}
return Math.max.apply(Math, globalXs);
return Math.max.apply(Math, globalMXs);
}

// Calculates the min Y value of the vertices of a box
function minYenemy(box, i) {

var globalYs = [];
globalYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalYs.push(box.geometry.vertices[vertexIndex].y + enemies[i].position.y);
}
return Math.min.apply(Math, globalYs);
return Math.min.apply(Math, globalMYs);
}

// Calculates the max Y value of the vertices of a box
function maxYenemy(box, i) {

var globalYs = [];
globalYs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalYs.push(box.geometry.vertices[vertexIndex].y + enemies[i].position.y);
globalMYs.push(box.geometry.vertices[vertexIndex].y + enemies[i].position.y);
}
return Math.max.apply(Math, globalYs);
return Math.max.apply(Math, globalMYs);
}

// Calculates the min Z value of the vertices of a box
function minZenemy(box, i) {

var globalZs = [];
globalZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalZs.push(box.geometry.vertices[vertexIndex].z + enemies[i].position.z);
}
Expand All @@ -204,11 +210,11 @@ var Collision = function () {
// Calculates the max Z value of the vertices of a box
function maxZenemy(box, i) {

var globalZs = [];
globalMZs = [];
for (var vertexIndex = 0; vertexIndex < box.geometry.vertices.length; vertexIndex++) {
globalZs.push(box.geometry.vertices[vertexIndex].z + enemies[i].position.z);
globalMZs.push(box.geometry.vertices[vertexIndex].z + enemies[i].position.z);
}
return Math.max.apply(Math, globalZs);
return Math.max.apply(Math, globalMZs);
}

/************************* INTERSECTION FUNCTIONS *************************/
Expand Down Expand Up @@ -239,9 +245,9 @@ var Collision = function () {
// Checks if there is an intersection between a sphere and a box
function intersectSphereBox(sphere, box) {
// get box closest point to sphere center by clamping
var x = Math.max(minX(box), Math.min(sphere.position.x, maxX(box)));
var y = Math.max(minY(box), Math.min(sphere.position.y, maxY(box)));
var z = Math.max(minZ(box), Math.min(sphere.position.z, maxZ(box)));
x = Math.max(minX(box), Math.min(sphere.position.x, maxX(box)));
y = Math.max(minY(box), Math.min(sphere.position.y, maxY(box)));
z = Math.max(minZ(box), Math.min(sphere.position.z, maxZ(box)));

// distance between the sphere and the closest box-point to the spehere
var distance = Math.sqrt((x - sphere.position.x) * (x - sphere.position.x) +
Expand Down Expand Up @@ -285,9 +291,9 @@ var Collision = function () {
function cylinderAsBox(cylinder) {

// parameters for the box
var x = cylinder.geometry.parameters.radiusTop * 2;
var y = cylinder.geometry.parameters.height;
var z = cylinder.geometry.parameters.radiusTop * 2;
x = cylinder.geometry.parameters.radiusTop * 2;
y = cylinder.geometry.parameters.height;
z = cylinder.geometry.parameters.radiusTop * 2;

// initialize box
var boxGeometry = new THREE.BoxGeometry(x, y, z);
Expand Down Expand Up @@ -322,10 +328,16 @@ var Collision = function () {

// Checks if there is an intersection between a ShipHitbox and another box
function intersectShipHitBoxBox(a, b) {
var x1Pruef = minXship(a) <= maxX(b);
var x2Pruef = maxXship(a) >= minX(b);
var y1Pruef = minYship(a) <= maxY(b);
var y2Pruef = maxYship(a) >= minY(b);
var z1Pruef = minZship(a) <= maxZ(b);
var z2Pruef = maxZship(a) >= minZ(b);
// if there is an intersection in every dimension the two boxes intersect
return (minXship(a) <= maxX(b) && maxXship(a) >= minX(b) &&
(minYship(a) <= maxY(b) && maxYship(a) >= minY(b)) &&
(minZship(a) <= maxZ(b) && maxZship(a) >= minZ(b)));
return (x1Pruef && x2Pruef &&
(y1Pruef && y2Pruef) &&
(z1Pruef && z2Pruef));
}

// Checks if there is an intersection between a point and box
Expand Down
Loading