diff --git a/_TODO b/_TODO index 7dd33a8..da528a1 100644 --- a/_TODO +++ b/_TODO @@ -1,32 +1,11 @@ -- Boosts funcionais (implementado o boost central) - Pode trazer alguns porblemas por causa do movimento atual da personagem - + - Melhorar o movimento da personagem. Provavelmente algo com um contador onde é simulada aceleração -- BulletPool - Reutilizar as balas em vez de estar sempre a criar e a destruir - -- EnemyPool - Same - Octree Raycasting Ver se melhora o desempenho do Raycasting -- Dividir o mapa em 3 - Uma parte de chao para ser usado com o raycast para baixo - Outra parte de paredes para usar com raycast lateral - Outra parte só estética (tecto) para não empatar - -- Adicionar um trail à bala - Provavelmente ver as particulas se fica mais rapido / dá para fazer - Se não, acrescentar um mesh atras da bala - -- Escolher e implementar o modo de jogo - Survival, onde inimigos aparecem sempre, cada vez mais, e tens um highscore de quantos mataste - TimeAttack, onde tens X segundos para matar os inimigos, e é por rondas (meh) - ... - - Movimentos e ações dos inimigos Previsão da nossa posição para disparar contra nos Espécie de Pathfinding @@ -40,5 +19,3 @@ - THREE.BufferGeometry para mapa supostamente mais rapido para objetos que nao se mexem - -- Recoil da arma \ No newline at end of file diff --git a/_TopicosRelatorio b/_TopicosRelatorio index a0c3ef1..d2b611a 100644 --- a/_TopicosRelatorio +++ b/_TopicosRelatorio @@ -17,7 +17,12 @@ Foi feita uma ilusao de sombra usando dois materias diferentes - O mapa criado tinha 3 mil faces e depois de uma otimização passou para 1,5 mil + Posteriormente foi dividido em 3 para melhorar o desempenho - MD2Character não dava para copiar para varios inimigos. As animações não eram grande coisa Passou-se a usar MD2CharacterComplex +- Bullet & Enemy Pool + O porque de se usar, falar do garbage collector e criação de modelos + +- firefox vs chrome diff --git a/boost.js b/boost.js index 98a1b1f..cdbf69d 100644 --- a/boost.js +++ b/boost.js @@ -7,7 +7,6 @@ function Boost(postion,actionFunction) { var self = this; this.update = function(posObject){ - //console.log("threshold " + this.thresholdDistance); if (posObject.distanceTo(postion)0){ - console.log("Colisão bala"); this.destroy(objectIndex); return; } @@ -61,7 +59,6 @@ function Bullet(damage) { intersections = this.raycaster.intersectObject(game.enemies[i].mesh,true); if (intersections.length>0){ game.enemies[i].damage(this.damage,i); - console.log("Enemy hit"); this.destroy(objectIndex); return; } @@ -70,7 +67,6 @@ function Bullet(damage) { if (!this.shotByPlayer && game.player.playerBB.containsPoint(this.mesh.position)){ game.player.takeDamage(this.damage); - console.log("Player hit"); this.destroy(objectIndex); return; } diff --git a/enemy.js b/enemy.js index b083241..fe47f67 100644 --- a/enemy.js +++ b/enemy.js @@ -78,7 +78,6 @@ function Enemy() { direction.y=0; var bullet = bPool.allocate(); - console.log("shoot"); bullet.activate(this.enemyDamage, pointBulletVec, direction, this.bulletSpeed, false); }; @@ -137,7 +136,6 @@ function Enemy() { this.boosts[i].update(new THREE.Vector3().subVectors(this.mesh.position,new THREE.Vector3(0,this.enemyHeight,0)))//ver se é preciso passar o delta } - // console.log(this.mesh.position) //update fisica this.updatePhysics(delta); @@ -175,7 +173,6 @@ function Enemy() { });//quando terminar de olhar para o player resta timeLook para 5 } - //console.log("move " , this.timeLook) //this.mesh.rotateY(0.3*delta * superHotConstant); //this.mesh.translateZ(-this.speed*delta * superHotConstant); @@ -195,11 +192,14 @@ function Enemy() { if (this.health <= 0){ this.destroy(index); + game.score += 1; + scoreDiv.innerHTML = game.score; } }; this.activate = function (position) { this.active = true; + this.health = 100; game.enemies.push(this); this.setPosition(position); diff --git a/game.js b/game.js index 2dbb081..45188d7 100644 --- a/game.js +++ b/game.js @@ -19,32 +19,26 @@ function Game() { this.prevTime; this.stats1; - this.stats2; //gestao das fisicas this.gravity = 2; - this.enemySpawnTimer = 5; + this.enemySpawnTimer = 2; this.enemySpawnTimerCurrent = 1; + this.score = 0; this.init = function() { - // SCENE - this.scene = new THREE.Scene(); // CAMERA - this.camera = new THREE.PerspectiveCamera( 60, window.innerWidth/window.innerHeight, 0.1, 1000 ); // Mover a camara com o rato (FirstPerson) this.controls = new THREE.PointerLockControls( this.camera ); this.scene.add( this.controls.getObject() ); // adiciona camera - // LIGHTS - - //this.camera.add(new THREE.PointLight(0xffffff, 1, 30, 2)) this.scene.add( new THREE.AmbientLight( 0x202020 ) ); var mesh = new THREE.Mesh( @@ -55,10 +49,7 @@ function Game() { mesh.position.set(0, 29, 0); this.scene.add(mesh); - - // RENDERER - this.renderer = new THREE.WebGLRenderer({antialias: true}); // TODO ver o antialias //this.renderer.shadowMapEnabled = true; //this.renderer.shadowMapType = THREE.PCFSoftShadowMap; @@ -68,10 +59,7 @@ function Game() { this.renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( this.renderer.domElement ); - - // GAME MAP - this.scene.add(loader.map); this.scene.add(loader.floors); this.floors = loader.floors; @@ -81,7 +69,6 @@ function Game() { this.walls.name="walls"; //RAYCAST DEBUG - var gem = new THREE.BoxGeometry(0.1,0.5,0.1); var lineMaterial = new THREE.MeshBasicMaterial({ color: 0xff0000 }); this.rayInter = new THREE.Mesh(gem, lineMaterial); @@ -101,78 +88,33 @@ function Game() { } , false); // POINTERLOCK - - var havePointerLock = 'pointerLockElement' in document - || 'mozPointerLockElement' in document - || 'webkitPointerLockElement' in document; - - //verificar se o browser suporta pointerLock - if ( havePointerLock ) { - var element = document.body; - - function pointerlockchange( event ) { - if ( document.pointerLockElement === element - || document.mozPointerLockElement === element - || document.webkitPointerLockElement === element ) { - game.controlsEnabled = true; - game.controls.enabled = true; - blocker.style.display = 'none'; - } else { - game.controlsEnabled = false; - game.controls.enabled = false; - blocker.style.display = 'block'; - instructions.style.display = ''; - } - }; - - // Hook pointer lock state change events - document.addEventListener( 'pointerlockchange', pointerlockchange, false ); - document.addEventListener( 'mozpointerlockchange', pointerlockchange, false ); - document.addEventListener( 'webkitpointerlockchange', pointerlockchange, false ); - - instructions.addEventListener( 'click', function ( event ) { - instructions.style.display = "none" ; - - // Ask the browser to lock the pointer - element.requestPointerLock = element.requestPointerLock || element.mozRequestPointerLock || element.webkitRequestPointerLock; - element.requestPointerLock(); - }, false ); - } else { - container.innerHTML = 'Your browser doesn\'t seem to support Pointer Lock API'; - } - - //CRIAR OBJETOS + this.verifyPointerLock(); + //CRIAR OBJETOS this.player = new Player(); this.player.addWeapon(new Pistol(loader.gun1, Bullet, 20, 1, new THREE.Vector3(0, 0.15, -1))); this.player.addWeapon(new Automatic(loader.gun2, Bullet, 30, 10, new THREE.Vector3(0, 0.1, -0.4))); - - // STATS this.stats1 = new Stats(); this.stats1.showPanel(0); // Panel 0 = fps this.stats1.domElement.style.cssText = 'position:absolute;top:0px;left:0px;'; document.body.appendChild(this.stats1.domElement); - - this.stats2 = new Stats(); - this.stats2.showPanel(1); // Panel 1 = ms - this.stats2.domElement.style.cssText = 'position:absolute;top:0px;left:80px;'; - document.body.appendChild(this.stats2.domElement); } this.animate = function() { - var delta = clock.getDelta(); - - resetPlayer(); + if (game.gameOver) return; - if ( game.controlsEnabled ) { + var delta = clock.getDelta(); + if (game.controlsEnabled) { + resetPlayer(); + // Update das balas for (var i = 0 ; i < game.bullets.length ; i++){ game.bullets[i].update(delta,i); } - + // Update do player game.player.update(delta); @@ -182,21 +124,21 @@ function Game() { var enemy = enemyPool.allocate(); enemy.activate(getRandomEnemySpawn()); game.enemySpawnTimerCurrent = game.enemySpawnTimer; + game.enemySpawnTimer *= 1 - 0.5 * delta * game.currentTimeSpeed; } - + // Update dos inimigos for (var i=0; i
+
+ +
@@ -48,8 +51,18 @@
+
+
+ YOUR FINAL SCORE +
+ 80 +
+ +
+
+ - + @@ -62,6 +75,7 @@ + @@ -70,8 +84,6 @@ - -