[Orxonox-commit 5566] r10229 - code/branches/minigame4DHS14/src/modules/mini4dgame
landauf at orxonox.net
landauf at orxonox.net
Sun Feb 1 14:50:46 CET 2015
Author: landauf
Date: 2015-02-01 14:50:46 +0100 (Sun, 01 Feb 2015)
New Revision: 10229
Modified:
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4Dgame.cc
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.cc
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.h
Log:
fixed warnings & details
Modified: code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4Dgame.cc
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4Dgame.cc 2015-02-01 13:27:56 UTC (rev 10228)
+++ code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4Dgame.cc 2015-02-01 13:50:46 UTC (rev 10229)
@@ -189,7 +189,7 @@
//void Mini4Dgame::setStone(Vector4 move, const int playerColor, Mini4DgameBoard* board)
void Mini4Dgame::setStone(int x,int y,int z,int w)//Vector4 move, const int playerColor)
{
- Vector4 move = Vector4(x,y,z,w);
+ Mini4DgamePosition move = Mini4DgamePosition(x,y,z,w);
ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>::begin();
it->makeMove(move);
}
Modified: code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.cc
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.cc 2015-02-01 13:27:56 UTC (rev 10228)
+++ code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.cc 2015-02-01 13:50:46 UTC (rev 10229)
@@ -83,20 +83,20 @@
@brief checks if the move is valid
@param the position where to put the stone plus the player who makes the move
*/
- bool Mini4DgameBoard::isValidMove(const Vector4 move)
+ bool Mini4DgameBoard::isValidMove(const Mini4DgamePosition& move)
{
return (move.x<4 && move.y<4 && move.z<4 && move.w<4
&& move.x>=0 && move.y>=0 && move.z>=0 && move.w>=0
- && this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] == mini4DgamePlayerColor::none);
+ && this->board[move.x][move.y][move.z][move.w] == mini4DgamePlayerColor::none);
}
void Mini4DgameBoard::undoMove()
{
- Vector4 move = moves.back();
+ const Mini4DgamePosition& move = moves.back();
moves.pop_back();
- this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = mini4DgamePlayerColor::none;
- this->blinkingBillboards[(int)move.x][(int)move.y][(int)move.z][(int)move.w]->destroy();
- this->blinkingBillboards[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = 0;
+ this->board[move.x][move.y][move.z][move.w] = mini4DgamePlayerColor::none;
+ this->blinkingBillboards[move.x][move.y][move.z][move.w]->destroy();
+ this->blinkingBillboards[move.x][move.y][move.z][move.w] = 0;
if(player_toggle_){
this->player_toggle_ = false;
}else{
@@ -108,17 +108,17 @@
@brief makes a move on the logic playboard
@param the position where to put the stone plus the player who makes the move
*/
- void Mini4DgameBoard::makeMove(const Vector4 move)
+ void Mini4DgameBoard::makeMove(const Mini4DgamePosition& move)
{
if(this->isValidMove(move))
{
if(!moves.empty())
{
//stop blinking of last move
- Vector4 lastMove = moves.back();
- this->blinkingBillboards[(int)lastMove.x][(int)lastMove.y][(int)lastMove.z][(int)lastMove.w]
+ const Mini4DgamePosition& lastMove = moves.back();
+ this->blinkingBillboards[lastMove.x][lastMove.y][lastMove.z][lastMove.w]
->setActive(false);
- this->blinkingBillboards[(int)lastMove.x][(int)lastMove.y][(int)lastMove.z][(int)lastMove.w]
+ this->blinkingBillboards[lastMove.x][lastMove.y][lastMove.z][lastMove.w]
->setScale(0.1);
}
@@ -132,24 +132,24 @@
this->player_toggle_ = true;
}
- this->board[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = (mini4DgamePlayerColor::color) playerColor;
+ this->board[move.x][move.y][move.z][move.w] = (mini4DgamePlayerColor::color) playerColor;
BlinkingBillboard* bb = new BlinkingBillboard(this->getContext());
bb->setFrequency(0.3);
bb->setAmplitude(0.1);
- switch((int)move.w){
+ switch(move.w){
case 0: bb->setMaterial("Numbers/One");
- bb->setPosition(60*(int)move.x-95,60*(int)move.y-95,60*(int)move.z-95);
+ bb->setPosition(60.0f*move.x-95,60.0f*move.y-95,60.0f*move.z-95);
break;
case 1: bb->setMaterial("Numbers/Two");
- bb->setPosition(60*(int)move.x-85,60*(int)move.y-85,60*(int)move.z-95);
+ bb->setPosition(60.0f*move.x-85,60.0f*move.y-85,60.0f*move.z-95);
break;
case 2: bb->setMaterial("Numbers/Three");
- bb->setPosition(60*(int)move.x-85,60*(int)move.y-95,60*(int)move.z-85);
+ bb->setPosition(60.0f*move.x-85,60.0f*move.y-95,60.0f*move.z-85);
break;
case 3: bb->setMaterial("Numbers/Four");
- bb->setPosition(60*(int)move.x-85,60*(int)move.y-85,60*(int)move.z-85);
+ bb->setPosition(60.0f*move.x-85,60.0f*move.y-85,60.0f*move.z-85);
break;
}
@@ -164,7 +164,7 @@
}
this->attach(bb);
- this->blinkingBillboards[(int)move.x][(int)move.y][(int)move.z][(int)move.w] = bb;
+ this->blinkingBillboards[move.x][move.y][move.z][move.w] = bb;
Mini4DgameWinner winner = this->getWinner();
@@ -175,9 +175,9 @@
BlinkingBillboard* redFlare = new BlinkingBillboard(this->getContext());
redFlare->setFrequency(0.5);
redFlare->setAmplitude(3);
- redFlare->setPosition(60*(int)winner.winningRow[i]-90,
- 60*(int)winner.winningColumn[i]-90,
- 60*(int)winner.winningHeight[i]-90);
+ redFlare->setPosition(60.0f*(int)winner.winningRow[i]-90,
+ 60.0f*(int)winner.winningColumn[i]-90,
+ 60.0f*(int)winner.winningHeight[i]-90);
redFlare->setMaterial("Flares/lensflare");
redFlare->setColour(ColourValue(1,0,0));
this->attach(redFlare);
Modified: code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.h
===================================================================
--- code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.h 2015-02-01 13:27:56 UTC (rev 10228)
+++ code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.h 2015-02-01 13:50:46 UTC (rev 10229)
@@ -42,6 +42,15 @@
namespace orxonox
{
+ struct Mini4DgamePosition
+ {
+ Mini4DgamePosition(int x, int y, int z, int w) : x(x), y(y), z(z), w(w) {}
+ int x;
+ int y;
+ int z;
+ int w;
+ };
+
struct Mini4DgameWinner
{
int winningRow[4];
@@ -66,9 +75,9 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- bool isValidMove(const Vector4 move);
+ bool isValidMove(const Mini4DgamePosition& move);
void undoMove();
- void makeMove(const Vector4 move);
+ void makeMove(const Mini4DgamePosition& move);
Mini4DgameWinner getWinner();
void changedGametype();
@@ -76,7 +85,7 @@
private:
//void registerVariables();
- std::vector<Vector4> moves;
+ std::vector<Mini4DgamePosition> moves;
bool player_toggle_;
BlinkingBillboard* blinkingBillboards[4][4][4][4];
int board[4][4][4][4]; //!< The logical board where the game takes place. board[row][column][height][number]
More information about the Orxonox-commit
mailing list