[Orxonox-commit 7368] r11984 - in code/branches/3DPacman_FS18: data/levels data/overlays src/modules/pacman
dreherm at orxonox.net
dreherm at orxonox.net
Thu May 24 14:25:15 CEST 2018
Author: dreherm
Date: 2018-05-24 14:25:15 +0200 (Thu, 24 May 2018)
New Revision: 11984
Modified:
code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h
Log:
Added level info
Modified: code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
===================================================================
--- code/branches/3DPacman_FS18/data/levels/3DPacman.oxw 2018-05-24 11:57:50 UTC (rev 11983)
+++ code/branches/3DPacman_FS18/data/levels/3DPacman.oxw 2018-05-24 12:25:15 UTC (rev 11984)
@@ -1,8 +1,8 @@
<LevelInfo
name = "3DPacman"
description = "A 3DVersion of Pacman."
- tags = "test"
- screenshot = "emptylevel.png"
+ tags = "minigame"
+ screenshot = "Pacman.png"
/>
<?lua
@@ -15,8 +15,6 @@
include("templates/PacmanGelb.oxt")
?>
-<!-- include("templates/spaceshipEscort.oxt") -->
-
<Level
plugins = pacman
gametype = Pacman
@@ -35,8 +33,6 @@
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
<SpawnPoint team=0 position="0,10,150" lookat="0,0,0" spawnclass=PacmanGelb pawndesign=PacmanGelb />
- <!-- <SpawnPoint team=0 position="0,10,150" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort /> -->
-
<!-- GHOSTS -->
<PacmanGhost position="0,10,15" >
<attached>
@@ -1804,7 +1800,7 @@
<BoxCollisionShape position="175,10,100" halfExtents="30,30,10" />
<BoxCollisionShape position="155,10,130" halfExtents="10,30,25" />
<BoxCollisionShape position="-220,10,150" halfExtents="20,30,10" />
- <BoxCollisionShape position="-220,10,150" halfExtents="20,30,10" /> <!-- 30 -->
+ <BoxCollisionShape position="220,10,150" halfExtents="20,30,10" /> <!-- 30 -->
<BoxCollisionShape position="0,10,150" halfExtents="60,30,10" />
<BoxCollisionShape position="0,10,180" halfExtents="10,30,25" />
<BoxCollisionShape position="-100,10,170" halfExtents="10,30,25" />
@@ -1816,8 +1812,17 @@
</collisionShapes>
</StaticEntity>
-<PortalEndPoint position="-240,10,0" id="1" distance="40" target="Pawn"/>
-<PortalEndPoint position="240,10,0" id="2" distance="40" target="Pawn"/>
+
+<Template name=Portal>
+ <PortalEndPoint>
+ <attached>
+ <Model mesh="Spacegate.mesh" yaw="90"/>
+ </attached>
+ </PortalEndPoint>
+</Template>
+
+<PortalEndPoint position="-240,15,5" id="1" distance="40" target="Pawn" design="Portal"/>
+<PortalEndPoint position="240,15,5" id="2" distance="40" target="Pawn" design="Portal"/>
<PortalLink fromID="1" toID="2" />
<PortalLink fromID="2" toID="1" />
</Scene>
Modified: code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
===================================================================
--- code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo 2018-05-24 11:57:50 UTC (rev 11983)
+++ code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo 2018-05-24 12:25:15 UTC (rev 11984)
@@ -58,7 +58,7 @@
/>
<PacmanHUDinfo
- position = "0.5, 0.5"
+ position = "0.85, 0.9"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc 2018-05-24 11:57:50 UTC (rev 11983)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc 2018-05-24 12:25:15 UTC (rev 11984)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Marc Dreher
* Co-authors:
* ...
*
@@ -33,7 +33,6 @@
#include "Pacman.h"
#include "core/CoreIncludes.h"
-//Test
namespace orxonox
{
@@ -51,6 +50,7 @@
void Pacman::levelUp()
{
+ //Reset each object
for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){
nextsphere->resetPacmanPointSphere();
}
@@ -59,11 +59,14 @@
next->resetPacmanPointAfraid();
}
+ //Level up ghosts
for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
nextghost->levelupvelo();
}
+ //Reset ghosts and player
this->posreset();
+ //Increase maximum of points and level
totallevelpoint = ObjectList<PacmanPointSphere>().size() + totallevelpoint;
level++;
}
@@ -76,61 +79,63 @@
{
SUPER(Pacman, tick, dt);
+ //Needed for gameover
if(deathtime != 0){
dead(dt);
}
+ //ingame loop
else{
- if(afraid){
- timer = timer - dt;
- if(timer<=0){
- setNormal();
+ //Register ghosts
+ int i = 0;
+ for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
+ ghosts[i] = nextghost;
+ i++;
}
- }
+ //Switch ghost to not-catchable, if timer is zero
+ if(afraid){
+ timer = timer - dt;
+ if(timer<=0){
+ setNormal();
+ }
+ }
- int i = 0;
- for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
- ghosts[i] = nextghost;
- i++;
- }
+ //Get position of player
+ player = this->getPlayer();
+ if (player != nullptr)
+ {
+ currentPosition = player->getWorldPosition();
+ }
- player = this->getPlayer();
- if (player != nullptr)
- {
- currentPosition = player->getWorldPosition();
- }
+ //Check for collision with ghosts
+ bcolli = false;
+ for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){
+ bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
+ }
+ if(bcolli){
+ this->catched(dt);
+ }
- bcolli = false;
- for(int nrghost = 0; (nrghost<8) && (!bcolli); ++nrghost){
- bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
- //orxout() << "GHOST" << nrghost << ghosts[nrghost]->getPosition() << endl;
- }
-
- if(bcolli){
- this->catched(dt);
- }
-
- i = 0;
- for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){
- if(collis(nextsphere->getPosition(), currentPosition)){
- takePoint(nextsphere);
+ //Check for collision with PointSpheres and PacmanPointAfraid
+ i = 0;
+ for(PacmanPointSphere* nextsphere : ObjectList<PacmanPointSphere>()){
+ if(collis(nextsphere->getPosition(), currentPosition))
+ takePoint(nextsphere);
}
- }
- for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){
- if(next->taken(currentPosition)){
- setAfraid();
+ for(PacmanPointAfraid* next : ObjectList<PacmanPointAfraid>()){
+ if(next->taken(currentPosition))
+ setAfraid();
}
- }
}
}
-
+ //Check for collisions between to objects (compare float numbers)
bool Pacman::collis(Vector3 one, Vector3 other){
if((abs(one.x-other.x)<10) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<10))
return true;
@@ -137,10 +142,11 @@
return false;
}
+ //Decrease live or resetghost
void Pacman::catched(float dt){
- if(!afraid) {
- if(!lives){
+ if(!this->afraid) {
+ if(!this->lives){
deathtime = 5;
this->dead(dt);
}
@@ -149,13 +155,14 @@
}
else{
for(int nrghost = 0; nrghost<8; ++nrghost){
- bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
- if(bcolli) ghosts[nrghost]->resetGhost();
- bcolli = false;
+ bcolli = collis(ghosts[nrghost]->getPosition(), currentPosition);
+ if(bcolli) ghosts[nrghost]->resetGhost();
+ bcolli = false;
}
}
}
+ //Change ghost design (to afraid)
void Pacman::setAfraid(){
timer = 10; //Set timer to 10 seconds
@@ -171,6 +178,7 @@
afraid = true;
}
+ //Change ghost design (to not afraid)
void Pacman::setNormal(){
timer = 0;
@@ -184,18 +192,7 @@
afraid = false;
}
- bool Pacman::getAfraid(){
- return afraid;
- }
-
- int Pacman::getTimer(){
- return timer;
- }
-
- int Pacman::getLevel(){
- return level;
- }
-
+ //Reset ghosts and plazer
void Pacman::posreset(){
for(int i = 0; i<4; ++i){
ghosts[i]->resetGhost();
@@ -203,6 +200,7 @@
player->setPosition(startposplayer);
}
+ //Collision with PointSphere
void Pacman::takePoint(PacmanPointSphere* taken){
++point;
if(point == totallevelpoint){
@@ -209,6 +207,7 @@
this->levelUp();
return;
}
+ //Set PointSphere under map
Vector3 postaken = taken->getPosition();
postaken.y = -50;
taken->setPosition(postaken);
@@ -224,13 +223,30 @@
return nullptr;
}
+ //Getter
+ bool Pacman::getAfraid(){
+ return afraid;
+ }
+ //Getter
+ int Pacman::getTimer(){
+ return timer;
+ }
+ //Getter
+ int Pacman::getLevel(){
+ return level;
+ }
+ //Getter
int Pacman::getPoints(){
return point;
}
-
+ //Getter
int Pacman::getLives(){
return lives;
}
+ //Getter
+ bool Pacman::isdead(){
+ return death;
+ }
void Pacman::start()
@@ -237,6 +253,7 @@
{
Deathmatch::start();
+ //Hide afraided ghosts under map
int i = 0;
for(PacmanGhost* nextghost : ObjectList<PacmanGhost>()){
if(3<i){
@@ -246,17 +263,17 @@
i++;
}
+ //Set maximum of points of first level
totallevelpoint = ObjectList<PacmanPointSphere>().size();
}
- bool Pacman::isdead(){
- return death;
- }
-
void Pacman::dead(float dt){
death = true;
+ //if (Highscore::exists())
+ // Highscore::getInstance().storeScore("3DPacman", this->getPoints(), this->playerInfo_);
+
deathtime = deathtime-dt;
if(deathtime<0)
@@ -265,14 +282,6 @@
void Pacman::end()
{
-
- /*
- if (Highscore::exists())
- {
- //int score = this->getPoints();
- //Highscore::getInstance().storeScore("3DPacman", score, this->playerInfo_);
- }
- */
GSLevel::startMainMenu();
}
}
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc 2018-05-24 11:57:50 UTC (rev 11983)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc 2018-05-24 12:25:15 UTC (rev 11984)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Marc Dreher
* Co-authors:
* ...
*
@@ -46,13 +46,9 @@
void PacmanGelb::tick(float dt)
{
SUPER(PacmanGelb, tick, dt);
- //bring player back to ground
- actuelposition = this->getPosition();
+ actuelposition = this->getPosition(); //bring player back to ground
actuelposition.y = 10;
this->setPosition(actuelposition);
- this->rotatePitch(Vector2(0, 0));
-
-
}
}
\ No newline at end of file
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h 2018-05-24 11:57:50 UTC (rev 11983)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h 2018-05-24 12:25:15 UTC (rev 11984)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Florian Zinggeler
+ * Marc Dreher
* Co-authors:
* ...
*
@@ -51,21 +51,17 @@
virtual void tick(float dt);
- //no rotation
+ //allow rotation in horizontal manner
virtual void rotateYaw(const Vector2& value) override{
this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
-
Pawn::rotateYaw(value);
-
- // This function call adds a lift to the ship when it is rotating to make it's movement more "realistic" and enhance the feeling.
- //if (this->getLocalVelocity().z < 0 && std::abs(this->getLocalVelocity().z) < stallSpeed_)
- //this->moveRightLeft(-lift_ / 5.0f * value * sqrt(std::abs(this->getLocalVelocity().y)));
};
+
+ //forbid rotation in the vertical (doesn't work totally proper, see documentation)
virtual void rotatePitch(const Vector2& value) override{};
private:
Vector3 actuelposition;
- Quaternion actuelorient;
};
}
More information about the Orxonox-commit
mailing list