[Orxonox-commit 7314] r11931 - in code/branches/3DPacman_FS18: data/levels data/levels/templates data/overlays src/modules/pacman

dreherm at orxonox.net dreherm at orxonox.net
Thu May 3 14:57:36 CEST 2018


Author: dreherm
Date: 2018-05-03 14:57:35 +0200 (Thu, 03 May 2018)
New Revision: 11931

Added:
   code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h
Modified:
   code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
   code/branches/3DPacman_FS18/data/levels/templates/PacmanGelb.oxt
   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/PacmanGhost.cc
   code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
Log:
HUD first commit

Modified: code/branches/3DPacman_FS18/data/levels/3DPacman.oxw
===================================================================
--- code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/data/levels/3DPacman.oxw	2018-05-03 12:57:35 UTC (rev 11931)
@@ -33,33 +33,32 @@
     <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,245" lookat="0,0,0" spawnclass=PacmanGelb pawndesign=PacmanGelb />
 
-
-<--! GHOSTS -->
-<PacmanGhost position="0,0,0">
+<!-- GHOSTS -->
+<PacmanGhost position="0,10,15" >
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostRed.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="0,0,0">
+<PacmanGhost position="0,10,15" >
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostBlue.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="0,0,0">
+<PacmanGhost position="0,10,15" >
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostOrange.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<PacmanGhost position="0,0,0">
+<PacmanGhost position="0,10,15" >
     <attached>
         <Model position="0,0,0" mesh="PacmanGhostPink.mesh" scale="5" />
     </attached>
 </PacmanGhost>
 
-<--! POINTS -->
+<!-- POINTS -->
 <PacmanPointSphere position="0,10,0">
     <attached>
         <Model position="0,0,0" mesh="PacmanPointSphere.mesh" scale="5" />
@@ -79,9 +78,7 @@
 </PacmanPointSphere>
 
 
-
-
-<--! Map -->
+<!-- Map -->
 <StaticEntity position="0,0,25" direction="0,0,0" collisionType=static mass=100000 friction=0.01 >
     <attached> 
         <Model position="0,0,0" mesh="PacmanMap.mesh" scale="50" /> 
@@ -88,22 +85,18 @@
     </attached> 
     <collisionShapes> 
 
-  <--! Edge -->
-	<BoxCollisionShape position="250,10,0" halfExtents="1,15,250" />
-	<BoxCollisionShape position="-250,10,0" halfExtents="1,15,250" />
+  <!-- Edge -->  
+  <BoxCollisionShape position="250,10,0" halfExtents="1,15,250" />
+  <BoxCollisionShape position="-250,10,0" halfExtents="1,15,250" />
   <BoxCollisionShape position="0,10,250" halfExtents="250,15,1" />
   <BoxCollisionShape position="0,10,-250" halfExtents="250,15,1" />
 
-  <--! Shapes in order -->
-  <BoxCollisionShape position="-35,10,-200" halfExtents="40,15,25" />
-  <BoxCollisionShape position="60,10,-200" halfExtents="40,15,25" />
-  <BoxCollisionShape position="-35,10,200" halfExtents="40,15,25" />
-  <BoxCollisionShape position="60,10,200" halfExtents="40,15,25" />
+   <!-- Shapes in order -->    
+  <BoxCollisionShape position="-200,10,-65" halfExtents="55,15,35" />
+  <BoxCollisionShape position="-200,10,30" halfExtents="55,15,35" />
+  <BoxCollisionShape position="200,10,-65" halfExtents="55,15,35" />
+  <BoxCollisionShape position="200,10,30" halfExtents="55,15,35" />
 
-  <BoxCollisionShape position="-175,10,-165" halfExtents="30,15,20" />
-
-
-
     </collisionShapes> 
 </StaticEntity>
 
@@ -111,6 +104,5 @@
 <PortalEndPoint position="240,10,0" id="2" distance="40" target="Pawn"/>
 <PortalLink fromID="1" toID="2" />
 <PortalLink fromID="2" toID="1" />
-
   </Scene>
 </Level>

Modified: code/branches/3DPacman_FS18/data/levels/templates/PacmanGelb.oxt
===================================================================
--- code/branches/3DPacman_FS18/data/levels/templates/PacmanGelb.oxt	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/data/levels/templates/PacmanGelb.oxt	2018-05-03 12:57:35 UTC (rev 11931)
@@ -49,10 +49,7 @@
 <Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
     </attached>
     <collisionShapes>
-      <BoxCollisionShape position="0    ,0 ,  3" halfExtents="10,   4,8" />
-      <BoxCollisionShape position="12.6 ,-2,  3" halfExtents="2.8,2.8,11"/>
-      <BoxCollisionShape position="-12.6,-2,  3" halfExtents="2.8,2.8,11"/>
-      <BoxCollisionShape position="0,     0,-12" halfExtents="4  , 4 ,7" />
+      <BoxCollisionShape position="0    ,0 ,  0" halfExtents="1,1,1" />
     </collisionShapes>
 
 <?lua
@@ -73,7 +70,7 @@
   <MultiStateEngine
    boostfactor    = 1.0
 
-   speedfront     = 50
+   speedfront     = 60
    speedback      = 20
    speedleftright =  1
    speedupdown    =  1

Added: code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo
===================================================================
--- code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo	                        (rev 0)
+++ code/branches/3DPacman_FS18/data/overlays/PacmanHUD.oxo	2018-05-03 12:57:35 UTC (rev 11931)
@@ -0,0 +1,69 @@
+<Template name="pacmanhud">
+  <OverlayGroup name = "pacmanhud" scale = "1, 1">
+  </OverlayGroup>
+</Template>
+<Template name="PacmanHUD">
+  <OverlayGroup name="PacmanHUD" scale = "1, 1">
+   
+    <PacmanHUDinfo
+     position  = "0.02, 0.01"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "left"
+
+     showpoints     = true
+    />
+
+    <PacmanHUDinfo
+     position  = "0.5, 0.5"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 0.0, 0.0, 1.0"
+     align     = "center"
+
+     showmessage     = true
+     messageID = 0
+
+    />
+
+    <PacmanHUDinfo
+         position  = "0.5, 0.6"
+         pickpoint = "0.0, 0.0"
+         font      = "ShareTechMono"
+         textsize  = 0.04
+         colour    = "1.0, 1.0, 1.0, 1.0"
+         align     = "center"
+
+         showmessage     = true
+         messageID = 1
+    />
+    <PacmanHUDinfo
+     position  = "0.5, 0.65"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "center"
+
+     showmessage     = true
+     messageID = 2
+    />
+    <PacmanHUDinfo
+     position  = "0.5, 0.7"
+     pickpoint = "0.0, 0.0"
+     font      = "ShareTechMono"
+     textsize  = 0.04
+     colour    = "1.0, 1.0, 1.0, 1.0"
+     align     = "center"
+
+     showmessage     = true
+     messageID = 3
+
+    />
+
+    
+  </OverlayGroup>
+</Template>
\ No newline at end of file

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.cc	2018-05-03 12:57:35 UTC (rev 11931)
@@ -43,10 +43,13 @@
     {
         RegisterObject(Pacman);
 
+       // firstGame = true;                   //needed for the HUD
         lives = 10;
         point = 0;
         level = 1;
 
+       // setHUDTemplate("PacmanOrxHUD");
+       // scoreboardTemplate_ = "";
     }
 
     void Pacman::levelUp()
@@ -96,7 +99,7 @@
 
 
     bool Pacman::collis(Vector3 one, Vector3 other){
-        if((abs(one.x-other.x)<7) && (abs(one.y-other.y)<7) && (abs(one.z-other.z)<7))
+        if((abs(one.x-other.x)<10) && (abs(one.y-other.y)<10) && (abs(one.z-other.z)<10))
             return true;
         return false;
     }
@@ -145,11 +148,29 @@
 
     void Pacman::end()
     {
+        /*
+        firstGame = false;
+        
+        //Set randomized deathmessages
+        if(point<7)         sDeathMessage = DeathMessage7[rand()%(DeathMessage7.size())];
+        else if(point<20)   sDeathMessage = DeathMessage20[rand()%(DeathMessage20.size())];
+        else if(point<30)   sDeathMessage = DeathMessage30[rand()%(DeathMessage30.size())];
+        else                sDeathMessage = DeathMessageover30[rand()%(DeathMessageover30.size())];
+        
+        //Update Highscore
         if (Highscore::exists())
         {
+            int score = this->getPoints();
+            Highscore::getInstance().storeScore("Pacman", score, this->getPlayer()->getPlayer());
+        }
+
+
+        if (Highscore::exists())
+        {
             //int score = this->getPoints();
             //Highscore::getInstance().storeScore("3DPacman", score, this->playerInfo_);
         }
+        */
         GSLevel::startMainMenu();
     }
 }

Modified: code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/src/modules/pacman/Pacman.h	2018-05-03 12:57:35 UTC (rev 11931)
@@ -93,6 +93,7 @@
             bool bcolli = false;
             Vector3 startposplayer = Vector3(0,10,245);
             int totallevelpoint = 3;
+            //bool firstGame;
             
        private:
 
@@ -106,30 +107,31 @@
             Timer comboTimer;
             Timer showLevelTimer;
 
-
-         /*
-
-            //void spawnEnemy();
-
-
-
-
-
-
-
-
-
-
-
-
-        private:
-
-
-
-
-            //Context* context;
-            */
+/*
+std::string sDeathMessage;
+const std::vector<std::string> DeathMessage7 = {
+                "You should really try that again",
+                "You can do better, can you?",
+                "Hey, maybe you get a participation award, that's good isn't it?",
+                "Congratulations, you get a medal, a wooden one",
+                "That was flappin bad!",
+                "Well, that was a waste of time",
+                "You suck!",
+                "Maybe try SuperOrxoBros. That game is not as hard.",
+                "Here's a tip: Try not to fly into these grey thingies.",
+                "We won't comment on that."};
+            const std::vector<std::string> DeathMessage20 = {
+                "Getting better!",
+                "Training has paid off, huh?",
+                "Good average!",
+                "That was somehow enjoyable to watch",
+                "Flappin average",
+                "Getting closer to something",
+                "That wasn't crap, not bad",
+                "Surprisingly not bad."};
+  */      
+        
     };
 }
 
-#endif /* _DodgeRace_H__ */
\ No newline at end of file
+#endif /* _Pacman_H__ */
\ No newline at end of file

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.cc	2018-05-03 12:57:35 UTC (rev 11931)
@@ -48,8 +48,6 @@
         this->velocity = Vector3(0, 0, 0);
 
         this->setCollisionType(CollisionType::Dynamic);
-
-        this->resetposition = this->getPosition(); //Set Default start position
         
         this->actuelposition = this->getPosition();
         
@@ -324,6 +322,9 @@
             else if(findpos(actuelposition,possibleposition[65])){
                 setnewTarget(56,64);
             }
+            else if(findpos(actuelposition,possibleposition[66])){
+                setnewTarget(47,48);
+            }
 
             else{
                 this->resetGhost(); //Shouldn't happen...

Modified: code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-03 12:47:26 UTC (rev 11930)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanGhost.h	2018-05-03 12:57:35 UTC (rev 11931)
@@ -66,7 +66,7 @@
             int target_z = 0; 
             Vector3 actuelposition;
             Vector3 velocity;
-            Vector3 resetposition;
+            Vector3 resetposition = Vector3(0,10,15);
     };
 
 }

Added: code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc	                        (rev 0)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.cc	2018-05-03 12:57:35 UTC (rev 11931)
@@ -0,0 +1,132 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Leo Merholz
+ *      Pascal Schärli
+ *
+ *      Co-authors:
+ *      ...
+ */
+
+#include "PacmanHUDinfo.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    RegisterClass(PacmanHUDinfo);
+
+    PacmanHUDinfo::PacmanHUDinfo(Context* context) : OverlayText(context)
+    {
+        RegisterObject(PacmanHUDinfo);
+
+        this->PacmanGame = nullptr;
+        this->bShowPoints_ = false;
+        this->bShowMessage_ = false;
+        this->messageID = 0;
+    }
+
+    void PacmanHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(PacmanHUDinfo, XMLPort, xmlelement, mode);
+
+        XMLPortParam(PacmanHUDinfo, "showpoints",    setShowPoints,    getShowPoints,    xmlelement, mode).defaultValues(false);
+        XMLPortParam(PacmanHUDinfo, "showmessage",   setShowMessage,   getShowMessage,   xmlelement, mode).defaultValues(false);
+        XMLPortParam(PacmanHUDinfo, "messageID",     setMessageID,     getMessageID,     xmlelement, mode).defaultValues(0);
+       
+    
+    }
+
+    void PacmanHUDinfo::tick(float dt)
+    {
+        SUPER(PacmanHUDinfo, tick, dt);
+
+        if (this->PacmanGame)
+        {
+            if(not this->PacmanGame->isDead()){
+                if(this->bShowPoints_){
+                    const std::string& points = "Score: "+multi_cast<std::string>(this->PacmanGame->getPoints());
+                    setTextSize(0.04);
+                    this->setCaption(points);
+                }
+                else if(this->bShowMessage_){
+                    setTextSize(0);
+                }
+            }
+            else{
+                if(this->bShowPoints_){
+                    setTextSize(0);
+                }
+                else if(this->bShowMessage_){
+                    if(this->PacmanGame->firstGame){
+                        if(messageID==3){
+                            setTextSize(0.05);
+                            this->setCaption("First click, then press space to start");
+                        }
+                    }
+                    else{
+                        std::string message;
+                        setTextSize(0.05);
+                        switch(messageID){
+                            case 0:
+                                message = "Game Over";
+                                setTextSize(0.1);
+                                this->setCaption(message);
+                            break;
+                            case 1:
+                                message = this->PacmanGame->sDeathMessage;
+                            break;
+                            case 2:
+                                message = "Your Score: "+multi_cast<std::string>(this->PacmanGame->getPoints())+
+                                                        "  Local High Score: "+multi_cast<std::string>(Highscore::getInstance().getHighestScoreOfGame("Flappy Orx"));
+                            break;
+                            case 3:
+                                time_t time = this->PacmanGame->getPlayer()->timeUntilRespawn();
+                                if(time<=0)
+                                    message = "Press space to restart.";
+                                else
+                                    message = "Please wait "+multi_cast<std::string>(time)+" seconds.";
+                            break;
+                        }
+                        this->setCaption(message);
+                    }
+                }
+            }   
+        }
+    }
+
+    void PacmanHUDinfo::changedOwner()
+    {
+        SUPER(PacmanHUDinfo, changedOwner);
+
+        if (this->getOwner() && this->getOwner()->getGametype())
+        {
+            this->PacmanGame = orxonox_cast<Pacman*>(this->getOwner()->getGametype());
+        }
+        else
+        {
+            this->PacmanGame = nullptr;
+        }
+    }
+}
\ No newline at end of file

Added: code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h
===================================================================
--- code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h	                        (rev 0)
+++ code/branches/3DPacman_FS18/src/modules/pacman/PacmanHUDinfo.h	2018-05-03 12:57:35 UTC (rev 11931)
@@ -0,0 +1,72 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Florian Zinggeler
+ *
+ */
+
+#ifndef _PacmanHUDinfo_H__
+#define _PacmanHUDinfo_H__
+
+#include "PacmanPrereqs.h"
+#include "Pacman.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "overlays/OverlayText.h"
+#include <cstring>
+
+namespace orxonox
+{
+    class _PacmanExport PacmanHUDinfo : public OverlayText, public Tickable
+    {
+        public:
+            PacmanHUDinfo(Context* context);
+
+            virtual void tick(float dt) override;
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+            virtual void changedOwner() override;
+
+            inline void setShowPoints(bool value)
+                { this->bShowPoints_ = value; }
+            inline bool getShowPoints() const
+                { return this->bShowPoints_; }
+
+            inline void setShowMessage(bool value){
+                bShowMessage_ = value;
+            }
+            inline bool getShowMessage() const
+                { return this->bShowMessage_; }
+
+            inline void setMessageID(int value){
+                messageID = value;
+            }
+            inline int getMessageID() const
+                { return messageID; }
+
+        private:
+            Pacman* PacmanGame;
+            bool bShowPoints_;
+            bool bShowMessage_;
+            int messageID;
+    };
+}
+#endif /* _PacmanHUDinfo_H__ */
\ No newline at end of file



More information about the Orxonox-commit mailing list