[Orxonox-commit 7361] r11978 - in code/branches/3DPacman_FS18: data/overlays src/modules/pacman
dreherm at orxonox.net
dreherm at orxonox.net
Fri May 18 12:38:38 CEST 2018
Author: dreherm
Date: 2018-05-18 12:38:37 +0200 (Fri, 18 May 2018)
New Revision: 11978
Modified:
code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc
code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h
code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
Log:
HUd and Ghost rotations
Modified: code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
===================================================================
--- code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo 2018-05-18 10:38:37 UTC (rev 11978)
@@ -13,36 +13,49 @@
<OverlayGroup name = "spaceshiphud" scale = "1, 1">
<PacmanHUDinfo
- position = "0.4, 0.01"
+ position = "0.05, 0.05"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
- align = "right"
+ align = "left"
showpoints = true
/>
<PacmanHUDinfo
- position = "1.4, 2.5"
- pickpoint = "0.0, 0.0"
+ position = "0.45, 0.5"
+ pickpoint = "0.5, 0.5"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
- align = "right"
+ align = "middle"
+ showgameover = true
+
/>
<PacmanHUDinfo
- position = "0.4, 0.1"
+ position = "0.05, 0.8"
pickpoint = "0.0, 0.0"
font = "ShareTechMono"
textsize = 0.04
colour = "1.0, 1.0, 1.0, 1.0"
- align = "right"
+ align = "left"
showghoststatus = true
/>
+ <PacmanHUDinfo
+ position = "0.05, 0.9"
+ pickpoint = "0.0, 0.0"
+ font = "ShareTechMono"
+ textsize = 0.04
+ colour = "1.0, 1.0, 1.0, 1.0"
+ align = "left"
+
+ showlive = true
+ />
+
</OverlayGroup>
</Template>
Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc 2018-05-18 10:38:37 UTC (rev 11978)
@@ -43,13 +43,10 @@
{
RegisterObject(Pacman);
- // firstGame = true; //needed for the HUD
- lives = 0;
+ lives = 3;
point = 0;
level = 1;
- // setHUDTemplate("PacmanOrxHUD");
- // scoreboardTemplate_ = "";
}
void Pacman::levelUp()
@@ -187,6 +184,14 @@
afraid = false;
}
+ bool Pacman::getAfraid(){
+ return afraid;
+ }
+
+ int Pacman::getTimer(){
+ return timer;
+ }
+
void Pacman::posreset(){
for(int i = 0; i<4; ++i){
ghosts[i]->resetGhost();
@@ -216,7 +221,11 @@
return point;
}
+ int Pacman::getLives(){
+ return lives;
+ }
+
void Pacman::start()
{
Deathmatch::start();
Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h 2018-05-18 10:38:37 UTC (rev 11978)
@@ -83,6 +83,9 @@
void setNormal();
bool isdead();
void dead(float dt);
+ bool getAfraid();
+ int getTimer();
+ int getLives();
bool bEndGame;
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.cc 2018-05-18 10:38:37 UTC (rev 11978)
@@ -50,6 +50,9 @@
actuelposition = this->getPosition();
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-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGelb.h 2018-05-18 10:38:37 UTC (rev 11978)
@@ -41,6 +41,7 @@
#include "worldentities/pawns/SpaceShip.h"
#include "graphics/Camera.h"
+
namespace orxonox
{
class _PacmanExport PacmanGelb : public SpaceShip
@@ -51,7 +52,15 @@
virtual void tick(float dt);
//no rotation
- //virtual void rotateYaw(const Vector2& value) override{};
+ 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)));
+ };
virtual void rotatePitch(const Vector2& value) override{};
private:
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc 2018-05-18 10:38:37 UTC (rev 11978)
@@ -440,19 +440,22 @@
void PacmanGhost::move(float dt, Vector3 actuelposition, Vector3 velocity){
if(!dontmove){
this->setPosition(Vector3(actuelposition.x+20*velocity.x*dt,10,actuelposition.z+20*velocity.z*dt));
-
-
- if(abs(velocity.x) == 2){
- this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));
+ if((abs(abs(velocity.x)-2)<0.1) && (abs(velocity.z-0)<0.1))
+ if(velocity.x<0){
+ this->setOrientation(Quaternion(Radian(-1.57), Vector3(0, 1, 0)));
}
- else if(velocity.z == 2){
- this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));
+ else{
+ this->setOrientation(Quaternion(Radian(1.57), Vector3(0, 1, 0)));
}
- else if(velocity.z == -2){
- this->setOrientation(Quaternion(Radian(180), Vector3(0, 1, 0)));
+ if((abs(abs(velocity.z)-2)<0.1) && (abs(velocity.x-0)<0.1))
+ if(velocity.z<0){
+ this->setOrientation(Quaternion(Radian(3.14), Vector3(0, 1, 0)));
}
- else{}
-
+ else{
+ this->setOrientation(Quaternion(Radian(0), Vector3(0, 1, 0)));
+ }
+ this->getOrientation();
+
}
}
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h 2018-05-18 10:38:37 UTC (rev 11978)
@@ -67,6 +67,7 @@
int target_x = 0;
int target_z = 0;
Vector3 velocity;
+ Vector3 oldvelocity = Vector3(2,0,0);
private:
int decision = 0; //Gives the random which way information to the ghost.
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc 2018-05-18 10:38:37 UTC (rev 11978)
@@ -57,6 +57,8 @@
XMLPortParam(PacmanHUDinfo, "showmessage", setShowMessage, getShowMessage, xmlelement, mode).defaultValues(false);
XMLPortParam(PacmanHUDinfo, "showghoststatus", setGhoststatus, getGhoststatus, xmlelement, mode).defaultValues(false);
XMLPortParam(PacmanHUDinfo, "messageID", setMessageID, getMessageID, xmlelement, mode).defaultValues(0);
+ XMLPortParam(PacmanHUDinfo, "showgameover", setGameover, getGameover, xmlelement, mode).defaultValues(false);
+ XMLPortParam(PacmanHUDinfo, "showlive", setlive, getlive, xmlelement, mode).defaultValues(false);
}
@@ -68,26 +70,41 @@
if (this->PacmanGame)
{
bool death = this->PacmanGame->isdead();
- if(death){
- bShowPoints_ = false;
- bShowGhoststatus_ = false;
+ if(death && showgameover){
const std::string& deathmessage = "Game Over";
- setTextSize(0.4);
+ setTextSize(0.08);
this->setCaption(deathmessage);
}
- if(this->bShowPoints_ && !death) {
+ if(this->bShowPoints_) {
const std::string& points = "Collected points: "+multi_cast<std::string>(this->PacmanGame->getPoints()) + " of " + multi_cast<std::string>(this->PacmanGame->totallevelpoint);
- setTextSize(0.04);
+ setTextSize(0.03);
this->setCaption(points);
}
- if(this->bShowGhoststatus_ && !death){
- const std::string& ghoststatus = "Do not get caught!";
- if(this->PacmanGame->afraid) const std::string& ghoststatus = "Catch the ghosts!";
- setTextSize(0.04);
- this->setCaption(ghoststatus);
+ if(this->bShowGhoststatus_){
+ if(this->PacmanGame->getAfraid()) {
+ const std::string& ghoststatus = "Catch the ghosts! \n " + multi_cast<std::string>(this->PacmanGame->getTimer()) + " seconds left";
+ setTextSize(0.03);
+ this->setCaption(ghoststatus);
+ }
+ else{
+ const std::string& ghoststatus = "Do not get caught!";
+ setTextSize(0.03);
+ this->setCaption(ghoststatus);
+ }
}
+
+ if(this->showlive){
+ const std::string& live = "Remaining lives: "+multi_cast<std::string>(this->PacmanGame->getLives());
+ setTextSize(0.03);
+ this->setCaption(live);
+ }
+
+ if(death && !(this->showgameover)){
+ setTextSize(0.0);
+ }
+
}
}
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h 2018-05-18 10:38:37 UTC (rev 11978)
@@ -68,11 +68,26 @@
inline int getGhoststatus() const
{ return this->bShowGhoststatus_; }
+ inline void setGameover(bool value){
+ this->showgameover = value;
+ }
+ inline int getGameover() const
+ { return this->showgameover; }
+
+ inline void setlive(bool value){
+ this->showlive = value;
+ }
+ inline int getlive() const
+ { return this->showlive; }
+
+
private:
Pacman* PacmanGame;
bool bShowPoints_;
bool bShowMessage_;
bool bShowGhoststatus_;
+ bool showgameover;
+ bool showlive;
int messageID;
};
}
Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc 2018-05-17 14:24:48 UTC (rev 11977)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanPointAfraid.cc 2018-05-18 10:38:37 UTC (rev 11978)
@@ -74,7 +74,7 @@
bool PacmanPointAfraid::taken(Vector3 playerpos)
{
resetposition = this->getPosition();
- if((abs(resetposition.x - playerpos.x)<5) && (abs(resetposition.z - playerpos.z)<5)){
+ if((abs(resetposition.x - playerpos.x)<5) && (abs(resetposition.y - playerpos.y)<5) && (abs(resetposition.z - playerpos.z)<5)){
this->setPosition(Vector3(resetposition.x, -50, resetposition.z));
return true;
}
More information about the Orxonox-commit
mailing list