Changeset 348
- Timestamp:
- Feb 4, 2011, 12:42:16 AM (10 years ago)
- Location:
- trunk/monsterz
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/monsterz/board.cpp
r340 r348 317 317 /* The mash becomes the new owner of the disappearing piece */ 318 318 mash->AddPiece(data->pairs[i][j].piece); 319 data->thumbs->AddCount(data->pairs[i][j].id - 1, 1);319 data->thumbs->AddCount(data->pairs[i][j].id, 1); 320 320 321 321 #if 0 // Test for piece creation -
trunk/monsterz/fusion.cpp
r346 r348 36 36 private: 37 37 int2 dim; 38 int npieces, maxnpieces;38 int minnpieces, npieces, maxnpieces; 39 39 int board, tiles; 40 40 … … 65 65 */ 66 66 67 Fusion::Fusion(int2 dim, int npieces, int maxnpieces)67 Fusion::Fusion(int2 dim, int minnpieces, int maxnpieces) 68 68 : data(new FusionData()) 69 69 { 70 70 data->dim = dim; 71 data->npieces = npieces; 71 data->minnpieces = minnpieces; 72 data->npieces = minnpieces; 72 73 data->maxnpieces = maxnpieces; 73 74 data->board = Tiler::Register(PNG_BOARD, 384, 384, 1.0f); … … 77 78 Ticker::Ref(data->emitter); 78 79 79 data->thumbs = new Thumbs( npieces);80 data->thumbs = new Thumbs(minnpieces + 1); 80 81 Ticker::Ref(data->thumbs); 81 82 … … 84 85 data->pairs[i][j].id = 0; 85 86 86 data->current[0].id = 1 + rand() % data->npieces;87 data->current[1].id = 1 + rand() % data->npieces;87 data->current[0].id = GetRandomId(); 88 data->current[1].id = GetRandomId(); 88 89 data->current[0].piece = new Piece(data->emitter, int2(3, 8), 89 90 80 + 20 * data->current[0].id); … … 97 98 data->mashes = NULL; 98 99 99 data->next[0] = 1 + rand() % data->npieces;100 data->next[1] = 1 + rand() % data->npieces;100 data->next[0] = GetRandomId(); 101 data->next[1] = GetRandomId(); 101 102 data->rotation = 0; 102 103 … … 179 180 data->current[t].piece->Move(int2(i, j) * 48); 180 181 data->pairs[i][j] = data->current[t]; 182 data->thumbs->AddCount(data->current[t].id, 1); 181 183 break; 182 184 } … … 195 197 data->current[0].piece->Move(data->current[0].piece->GetCell() * 48); 196 198 data->current[1].piece->Move(data->current[1].piece->GetCell() * 48); 197 data->next[0] = 1 + rand() % data->npieces;198 data->next[1] = 1 + rand() % data->npieces;199 data->next[0] = GetRandomId(); 200 data->next[1] = GetRandomId(); 199 201 data->rotation = 0; 200 202 … … 215 217 Scene::GetDefault()->AddTile((data->board << 16) | 0, 216 218 position.x, position.y, 1, 0); 219 } 220 221 int Fusion::GetRandomId() const 222 { 223 int max = data->npieces; 224 225 if (max > data->minnpieces) 226 max--; 227 228 return 1 + rand() % max; 217 229 } 218 230 … … 292 304 Ticker::Ref(data->pairs[i][j].piece); 293 305 data->pairs[i][j].piece->SetPos(int2(i, j) * 48); 306 data->thumbs->AddCount(data->pairs[i][j].id, 1); 294 307 count[list[i][j]] = 0; 295 308 list[i][j] = -1; -
trunk/monsterz/fusion.h
r345 r348 24 24 { 25 25 public: 26 Fusion(int2 dim, int npieces, int maxnpieces);26 Fusion(int2 dim, int minnpieces, int maxnpieces); 27 27 virtual ~Fusion(); 28 28 … … 32 32 33 33 private: 34 int GetRandomId() const; 34 35 void Resolve(); 35 36 int TagNeighbours(int list[MAX_PIECES][MAX_PIECES], int i, int j); -
trunk/monsterz/interface.cpp
r345 r348 83 83 Ticker::Unref(data->title); 84 84 data->title = NULL; 85 data->fusion = new Fusion(int2(8, 7), 4, 12);85 data->fusion = new Fusion(int2(8, 7), 3, 12); 86 86 Ticker::Ref(data->fusion); 87 87 #if 0 -
trunk/monsterz/thumbs.cpp
r345 r348 95 95 void Thumbs::AddCount(int id, int count) 96 96 { 97 if (id >= 0 && id < data->npieces) 98 data->count[id] += count; 97 if (id > 0 && id <= data->npieces) 98 data->count[id - 1] += count; 99 } 100 101 int Thumbs::GetCount(int id) 102 { 103 if (id > 0 && id <= data->npieces) 104 return data->count[id - 1]; 105 else 106 return 0; 99 107 } 100 108 -
trunk/monsterz/thumbs.h
r345 r348 29 29 void SetMax(int npieces); 30 30 void AddCount(int id, int count); 31 int GetCount(int id); 31 32 32 33 protected:
Note: See TracChangeset
for help on using the changeset viewer.