Changeset 10229 for code/branches/minigame4DHS14
- Timestamp:
- Feb 1, 2015, 2:50:46 PM (10 years ago)
- Location:
- code/branches/minigame4DHS14/src/modules/mini4dgame
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4Dgame.cc
r10225 r10229 190 190 void Mini4Dgame::setStone(int x,int y,int z,int w)//Vector4 move, const int playerColor) 191 191 { 192 Vector4 move = Vector4(x,y,z,w);192 Mini4DgamePosition move = Mini4DgamePosition(x,y,z,w); 193 193 ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>::begin(); 194 194 it->makeMove(move); -
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.cc
r10225 r10229 84 84 @param the position where to put the stone plus the player who makes the move 85 85 */ 86 bool Mini4DgameBoard::isValidMove(const Vector4move)86 bool Mini4DgameBoard::isValidMove(const Mini4DgamePosition& move) 87 87 { 88 88 return (move.x<4 && move.y<4 && move.z<4 && move.w<4 89 89 && move.x>=0 && move.y>=0 && move.z>=0 && move.w>=0 90 && this->board[ (int)move.x][(int)move.y][(int)move.z][(int)move.w] == mini4DgamePlayerColor::none);90 && this->board[move.x][move.y][move.z][move.w] == mini4DgamePlayerColor::none); 91 91 } 92 92 93 93 void Mini4DgameBoard::undoMove() 94 94 { 95 Vector4move = moves.back();95 const Mini4DgamePosition& move = moves.back(); 96 96 moves.pop_back(); 97 this->board[ (int)move.x][(int)move.y][(int)move.z][(int)move.w] = mini4DgamePlayerColor::none;98 this->blinkingBillboards[ (int)move.x][(int)move.y][(int)move.z][(int)move.w]->destroy();99 this->blinkingBillboards[ (int)move.x][(int)move.y][(int)move.z][(int)move.w] = 0;97 this->board[move.x][move.y][move.z][move.w] = mini4DgamePlayerColor::none; 98 this->blinkingBillboards[move.x][move.y][move.z][move.w]->destroy(); 99 this->blinkingBillboards[move.x][move.y][move.z][move.w] = 0; 100 100 if(player_toggle_){ 101 101 this->player_toggle_ = false; … … 109 109 @param the position where to put the stone plus the player who makes the move 110 110 */ 111 void Mini4DgameBoard::makeMove(const Vector4move)111 void Mini4DgameBoard::makeMove(const Mini4DgamePosition& move) 112 112 { 113 113 if(this->isValidMove(move)) … … 116 116 { 117 117 //stop blinking of last move 118 Vector4lastMove = moves.back();119 this->blinkingBillboards[ (int)lastMove.x][(int)lastMove.y][(int)lastMove.z][(int)lastMove.w]118 const Mini4DgamePosition& lastMove = moves.back(); 119 this->blinkingBillboards[lastMove.x][lastMove.y][lastMove.z][lastMove.w] 120 120 ->setActive(false); 121 this->blinkingBillboards[ (int)lastMove.x][(int)lastMove.y][(int)lastMove.z][(int)lastMove.w]121 this->blinkingBillboards[lastMove.x][lastMove.y][lastMove.z][lastMove.w] 122 122 ->setScale(0.1); 123 123 } … … 133 133 } 134 134 135 this->board[ (int)move.x][(int)move.y][(int)move.z][(int)move.w] = (mini4DgamePlayerColor::color) playerColor;135 this->board[move.x][move.y][move.z][move.w] = (mini4DgamePlayerColor::color) playerColor; 136 136 137 137 BlinkingBillboard* bb = new BlinkingBillboard(this->getContext()); … … 139 139 bb->setAmplitude(0.1); 140 140 141 switch( (int)move.w){141 switch(move.w){ 142 142 case 0: bb->setMaterial("Numbers/One"); 143 bb->setPosition(60 *(int)move.x-95,60*(int)move.y-95,60*(int)move.z-95);143 bb->setPosition(60.0f*move.x-95,60.0f*move.y-95,60.0f*move.z-95); 144 144 break; 145 145 case 1: bb->setMaterial("Numbers/Two"); 146 bb->setPosition(60 *(int)move.x-85,60*(int)move.y-85,60*(int)move.z-95);146 bb->setPosition(60.0f*move.x-85,60.0f*move.y-85,60.0f*move.z-95); 147 147 break; 148 148 case 2: bb->setMaterial("Numbers/Three"); 149 bb->setPosition(60 *(int)move.x-85,60*(int)move.y-95,60*(int)move.z-85);149 bb->setPosition(60.0f*move.x-85,60.0f*move.y-95,60.0f*move.z-85); 150 150 break; 151 151 case 3: bb->setMaterial("Numbers/Four"); 152 bb->setPosition(60 *(int)move.x-85,60*(int)move.y-85,60*(int)move.z-85);152 bb->setPosition(60.0f*move.x-85,60.0f*move.y-85,60.0f*move.z-85); 153 153 break; 154 154 } … … 165 165 166 166 this->attach(bb); 167 this->blinkingBillboards[ (int)move.x][(int)move.y][(int)move.z][(int)move.w] = bb;167 this->blinkingBillboards[move.x][move.y][move.z][move.w] = bb; 168 168 169 169 … … 176 176 redFlare->setFrequency(0.5); 177 177 redFlare->setAmplitude(3); 178 redFlare->setPosition(60 *(int)winner.winningRow[i]-90,179 60 *(int)winner.winningColumn[i]-90,180 60 *(int)winner.winningHeight[i]-90);178 redFlare->setPosition(60.0f*(int)winner.winningRow[i]-90, 179 60.0f*(int)winner.winningColumn[i]-90, 180 60.0f*(int)winner.winningHeight[i]-90); 181 181 redFlare->setMaterial("Flares/lensflare"); 182 182 redFlare->setColour(ColourValue(1,0,0)); -
code/branches/minigame4DHS14/src/modules/mini4dgame/Mini4DgameBoard.h
r10227 r10229 43 43 { 44 44 45 struct Mini4DgamePosition 46 { 47 Mini4DgamePosition(int x, int y, int z, int w) : x(x), y(y), z(z), w(w) {} 48 int x; 49 int y; 50 int z; 51 int w; 52 }; 53 45 54 struct Mini4DgameWinner 46 55 { … … 67 76 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 68 77 69 bool isValidMove(const Vector4move);78 bool isValidMove(const Mini4DgamePosition& move); 70 79 void undoMove(); 71 void makeMove(const Vector4move);80 void makeMove(const Mini4DgamePosition& move); 72 81 Mini4DgameWinner getWinner(); 73 82 … … 77 86 private: 78 87 //void registerVariables(); 79 std::vector< Vector4> moves;88 std::vector<Mini4DgamePosition> moves; 80 89 bool player_toggle_; 81 90 BlinkingBillboard* blinkingBillboards[4][4][4][4];
Note: See TracChangeset
for help on using the changeset viewer.