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

Added Turret #136

Merged
merged 32 commits into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
d0ed7c2
asteroidHitBoxFix
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
370edde
small fixes
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
46c2818
small changes
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
9a5b41b
small changes
Jul 28, 2016
065dc61
no merge conflicts
Jul 28, 2016
6042e88
running version without laserSuccess
Jul 28, 2016
c0b117b
bugfixes
Jul 29, 2016
985dcf1
name undefined
Jul 29, 2016
a2ca9a9
hanged Rocket Symbol
sabsbremer Jul 29, 2016
6d68889
Rocket and Minigun interface symbols
Jan-HenrikLackner Jul 29, 2016
5e39d96
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 29, 2016
c321115
removes diffuseWrap
VaraionPrivate Jul 29, 2016
f8a80c4
512*512
Jan-HenrikLackner Jul 29, 2016
991d99c
Merge pull request #132 from Jan-HenrikLackner/dev
Varaion Jul 29, 2016
0e20cfe
collision weapon bug fix
Jul 29, 2016
ce533f9
no merge conflicts
Jul 29, 2016
2fca093
Fixed TurretLaser
sabsbremer Jul 29, 2016
4eb417c
Merge pull request #134 from GunnarNiebaum/dev
Varaion Jul 29, 2016
d577d58
Merge branch 'dev' of github.com:OsnaCS/space-game into dev
sabsbremer Jul 29, 2016
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
16 changes: 6 additions & 10 deletions app/Collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,12 @@ var Collision = function() {
(sphere.position.z - other.position.z) * (sphere.position.z - other.position.z));
// if the distance between the centers is smaller the the sum of the
// radii the spheres intersect

//console.log(sphere.parameters.radius);
// console.log(sphere.geometry.parameters.radius);
return distance < (sphere.geometry.parameters.radius + other.geometry.parameters.radius);
}

// 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)));
Expand All @@ -206,7 +204,7 @@ var Collision = function() {
return distance < sphere.geometry.parameters.radius;
}

// CHecks if there is an intersection between a sphere and a cylinder.
// Checks if there is an intersection between a sphere and a cylinder.
// Appoximates the cylinder as a box
function intersectSphereCylinder(sphere, cylinder) {

Expand All @@ -221,7 +219,7 @@ var Collision = function() {

}

// CHecks if there is an intersection between a box and a cylinder.
// Checks if there is an intersection between a box and a cylinder.
// Appoximates the cylinder as a box
function intersectBoxCylinder(box, cylinder) {

Expand All @@ -246,9 +244,11 @@ var Collision = function() {

// initialize box
var boxGeometry = new THREE.BoxGeometry(x,y,z);
var boxMaterial = new THREE.MeshBasicMaterial({ color:0x00FF00 });
var boxMaterial = new THREE.MeshBasicMaterial({ color:0xFFFF00 });
var hitBox = new THREE.Mesh(boxGeometry, boxMaterial);

hitBox.visible = false;

// transform box to the position of the cylinder
hitBox.applyMatrix(cylinder.matrix);

Expand All @@ -267,10 +267,6 @@ var Collision = function() {
(y - sphere.position.y) * (y - sphere.position.y) +
(z - sphere.position.z) * (z - sphere.position.z));

// console.log(distance);
// console.log(sphere.geometry.parameters.radius);


// if the distance is smaller than the radius of the sphere there is an intersection
return distance < sphere.geometry.parameters.radius;
}
Expand Down
106 changes: 86 additions & 20 deletions app/CollisionHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ function handleAsteroids() {
}
// Kollision mit Player
for (var j = 0; j <= playerHitBoxes.length - 1; j++) {

// playerHitBoxes[j].applyMatrix(ship.matrix);

if (collision.intersectSphereShipHitBox(asteroidHitBoxes[i],
playerHitBoxes[j])) {
destroyAsteroid(i);
Expand All @@ -22,7 +19,7 @@ function handleAsteroids() {
}
}


/** NICHT LÖSCHEN **/
// Kollision mit Gegner
// for (var j = 0; j < enemies.length - 1; j++) {
// var enemyHitboxes = getEnemyHitboxes(enemies[j]);
Expand All @@ -40,49 +37,115 @@ function handleAsteroids() {


function handleProjectiles() {

// for every projectile
for (var i = 0; i <= projectiles.length - 1; i++) {

// Asteroidentreffer

for (var j = 0; j <= asteroidHitBoxes.length - 1; j++) {
var projectileSucceded = false;

if (projectiles[i].name === "LaserHitBox") {
// Asteroidentreffer
if (projectiles[i].name === "LaserHitBox") {
for (var j = 0; j <= asteroidHitBoxes.length - 1; j++) {
if (collision.intersectSphereCylinder(asteroidHitBoxes[j],
projectiles[i])) {
// successLaser(projectiles[i]);
successLaser(i);
hitAsteroid(j, "Laser");
projectileSucceded = true;
break;
}
}
}

else if (projectiles[i].name === "RocketHitBox") {

else if (projectiles[i].name === "RocketHitBox") {
for (var j = 0; j <= asteroidHitBoxes.length - 1; j++) {
if (collision.intersectSphereCylinder(asteroidHitBoxes[j],
projectiles[i])) {
successRocket(i);
console.log("hit");
successRocket(i);
hitAsteroid(j, "Rocket");
projectileSucceded = true;
break;
}
}
}

else if (projectiles[i].name === "Explosion") {

else if (projectiles[i].name === "Explosion") {
for (var j = 0; j <= asteroidHitBoxes.length - 1; j++) {
if (collision.intersectSphereOther(asteroidHitBoxes[j],
projectiles[i])) {
hitAsteroid(j, "Explosion");
}
}
}

else if (projectiles[i].name === "MachineGun") {

else if (projectiles[i].name === "MachineGun") {
for (var j = 0; j <= asteroidHitBoxes.length - 1; j++) {
if (collision.intersectSphereOther(asteroidHitBoxes[j],
projectiles[i])) {
// successMachineGunBullet(projectiles[i]);
/** NICHT LÖSCHEN **/
// successMachineGunBullet(i);
destroyAsteroid(j);
// projectileSucceded = true;
// break;
}
}

}

// // Collect items via projectiles
// for (var j = 0; j <= itemHitBoxes.length - 1; j++) {

/** NICHT LÖSCHEN **/
// Collect items via projectiles
if (projectileSucceded === false) {

if (projectiles[i].name === "LaserHitBox") {
for (var j = 0; j <= itemHitBoxes.length - 1; j++) {
if (collision.intersectBoxCylinder(itemHitBoxes[j],
projectiles[i])) {
successLaser(i);
collected(j);
break;
}
}
}



else if (projectiles[i].name === "RocketHitBox") {
for (var j = 0; j <= itemHitBoxes.length - 1; j++) {
if (collision.intersectBoxCylinder(itemHitBoxes[j],
projectiles[i])) {
successRocket(i);
collected(j);
break;
}
}
}


else if (projectiles[i].name === "Explosion") {
for (var j = 0; j <= itemHitBoxes.length - 1; j++) {
if (collision.intersectSphereBox(itemHitBoxes[j],
projectiles[i])) {
collected(j);
}
}
}


else if (projectiles[i].name === "MachineGun") {
for (var j = 0; j <= itemHitBoxes.length - 1; j++) {
if (collision.intersectSphereBox(itemHitBoxes[j],
projectiles[i])) {
/** NICHT LÖSCHEN **/
// successMachineGunBullet(i);
collected(j);
}
}
}

/** NICHT LÖSCHEN **/
// if (projectiles[i].name === "LaserHitBox") {
// if (collision.intersectBoxCylinder(itemHitBoxes[j],
// projectiles[i])) {
Expand Down Expand Up @@ -118,9 +181,11 @@ function handleProjectiles() {
// }
// }


// }


/** NICHT LÖSCHEN **/
// Gegner wird getroffen
// for (var j = 0; j < enemies.length - 1; j++) {

Expand Down Expand Up @@ -187,11 +252,12 @@ function handleProjectiles() {

// }

}

}
}


/** NICHT LÖSCHEN **/
function handlePlayerEnemyCollision() {
// var playerHitboxes = getPlayerHitboxes();
// for (var i = 0; i <= playerHitboxes.length - 1; i++) {
Expand All @@ -207,7 +273,7 @@ function handlePlayerEnemyCollision() {
// }
}


/** NICHT LÖSCHEN **/
function handleEnemyEnemyCollision() {
// for (var i = 0; i <= enemies.length - 2; i++) {
// var enemyHitboxes1 = getEnemyHitboxes(enemies[i]); {
Expand All @@ -232,7 +298,6 @@ function handlePlayerPopupCollision() {
for (var j = 0; j < itemHitBoxes.length; j++) {
if (collision.intersectShipHitBoxBox(playerHitBoxes[i],
itemHitBoxes[j])) {
//console.log("Collision detected");
collected(j);
}
}
Expand All @@ -244,6 +309,7 @@ function handleCollision() {
handlePlayerPopupCollision();
handleAsteroids();
handleProjectiles();
/** NICHT LÖSCHEN **/
//handlePlayerEnemyCollision();
//handleEnemyEnemyCollision();

Expand Down
17 changes: 15 additions & 2 deletions app/Crosshairs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var cross1,cross2,cross3,cross4,cross5,cross6,cross7,cross8,cross9,cross10,cross11,cross12,cross13,cross14,cross15;
var cross1,cross2,cross3,cross4,cross5,cross6,cross7,cross8,cross9,cross10,cross11,cross12,cross13,cross14,cross15,cross16;
var crosses = [];
var pos = 0;
var old = 0;
Expand Down Expand Up @@ -158,14 +158,27 @@ function Crosshairs() {
cross15.visible = false;
crosses.push(cross15);


mapA = fileLoader.get("Crosshair16");

materialA = new THREE.SpriteMaterial({map: mapA});

cross16 = new THREE.Sprite(materialA);
cross16.position.set(0, 10, -40);
cross16.scale.set(6.0, 6.0, 1.0);
cross16.visible = false;
crosses.push(cross16);

cross1.visible = true;
ship.add(cross1);

},

switch:function(){
switch:function(){

if(pos == crosses.length-1){
old = crosses.length-1;

pos = 0;
}
else{
Expand Down
2 changes: 2 additions & 0 deletions app/FileLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ var FileLoader = function() {
"../res/textures/Crosshair13.png",
"../res/textures/Crosshair14.png",
"../res/textures/Crosshair15.png",
"../res/textures/Crosshair16.png",

"../res/textures/TextureHero.png",
"../res/textures/particle.png",
"../res/textures/particle_grey.png",
Expand Down
40 changes: 19 additions & 21 deletions app/Items.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var powerUps = [];
var types = [];
var itemHitBoxes = [];
var shieldActive = false;
var shieldActive = false;

function spawnPowerUp(x, y, z, type) {

Expand Down Expand Up @@ -112,8 +112,6 @@ function updatePowerUps (){

function collected(itemNumber){


//console.log("itemCollected");
changeScore(scoreValues["itemCollected"]);

var tmpItem = types[itemNumber];
Expand All @@ -129,38 +127,38 @@ function collected(itemNumber){
break;
case "SINGLEROCKET":

rocketAmmo +=1;
break;
rocketAmmo +=1;

break;

case "DOUBLEROCKET":
case "DOUBLEROCKET":

rocketAmmo +=2;
break;
rocketAmmo +=2;

break;
case "QUATROROCKET":

rocketAmmo += 4;
rocketAmmo += 4;


break;

case "SHIELD":
case "SHIELD":

shieldActive = true;
player.activateShield();
break;
shieldActive = true;
player.activateShield();
break;

case "MONEY" :
case "MONEY" :

changeMoney(20);
particleHandler.addExplosion(itemHitBoxes[itemNumber].position, 5, 0x00FF00);
break;
changeMoney(20);
particleHandler.addExplosion(itemHitBoxes[itemNumber].position, 5, 0x00FF00);
break;

case "FACEPALM":


break;
break;

default:
particleHandler.addExplosion(itemHitBoxes[itemNumber].position, 5, 0x6495ED);
Expand Down
1 change: 1 addition & 0 deletions app/Movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ function Movement() {
targetPosition.y = position.y + 100 * Math.cos(phi);
targetPosition.z = position.z + 100 * Math.sin(phi) * Math.sin(theta);
ship.lookAt(targetPosition);
turret.move();
},

unlockPointer:function(){
Expand Down
Loading