Changeset 345
 Timestamp:
 Feb 3, 2011, 5:13:52 PM (10 years ago)
 Location:
 trunk/monsterz
 Files:

 5 edited
Legend:
 Unmodified
 Added
 Removed

trunk/monsterz/fusion.cpp
r344 r345 36 36 private: 37 37 int2 dim; 38 int npieces ;38 int npieces, maxnpieces; 39 39 int board, tiles; 40 40 … … 65 65 */ 66 66 67 Fusion::Fusion(int2 dim, int npieces )67 Fusion::Fusion(int2 dim, int npieces, int maxnpieces) 68 68 : data(new FusionData()) 69 69 { 70 70 data>dim = dim; 71 71 data>npieces = npieces; 72 data>maxnpieces = maxnpieces; 72 73 data>board = Tiler::Register(PNG_BOARD, 384, 384, 1.0f); 73 74 data>tiles = Tiler::Register(PNG_TILES, 48, 48, 1.0f); … … 230 231 int seq = 0, effect = 0; 231 232 232 printf("\npairs:\n");233 for (int j = data>dim.j; j;)234 {235 for (int i = 0; i < data>dim.i; i++)236 printf("% 2i ", data>pairs[i][j].id);237 printf("\n");238 }239 240 233 /* Count connected tiles */ 241 for (int j = 0; j < data>dim.j; j++) 242 for (int i = 0; i < data>dim.i; i++) 243 { 244 if (!data>pairs[i][j].id) 245 continue; 246 247 if (list[i][j] != 1) 248 continue; 249 250 list[i][j] = seq; 251 count[seq] = TagNeighbours(list, i, j); 252 if (count[seq] >= 3) 253 effect = 1; 254 seq++; 255 } 256 257 printf("hits:\n"); 258 for (int j = data>dim.j; j;) 259 { 260 for (int i = 0; i < data>dim.i; i++) 261 printf("% 2i ", list[i][j]); 262 printf("\n"); 234 for (int j = 0; j < data>dim.j; j++) for (int i = 0; i < data>dim.i; i++) 235 { 236 if (!data>pairs[i][j].id) 237 continue; 238 239 if (data>pairs[i][j].id >= data>maxnpieces) 240 continue; 241 242 if (list[i][j] != 1) 243 continue; 244 245 list[i][j] = seq; 246 count[seq] = TagNeighbours(list, i, j); 247 if (count[seq] >= 3) 248 effect = 1; 249 seq++; 263 250 } 264 251 … … 271 258 Ticker::Ref(mash); 272 259 273 for (int j = 0; j < data>dim.j; j++) 274 for (int i = 0; i < data>dim.i; i++) 275 { 276 if (list[i][j] == 1) 277 continue; 278 if (count[list[i][j]] < 3) 279 continue; 280 281 mash>AddPiece(data>pairs[i][j].piece); 282 data>pairs[i][j].piece = NULL; 283 } 260 for (int j = 0; j < data>dim.j; j++) for (int i = 0; i < data>dim.i; i++) 261 { 262 if (list[i][j] == 1) 263 continue; 264 if (count[list[i][j]] < 3) 265 continue; 266 267 mash>AddPiece(data>pairs[i][j].piece); 268 data>pairs[i][j].piece = NULL; 269 } 284 270 285 271 mash>nextmash = data>mashes; … … 287 273 288 274 /* Create new pieces where necessary */ 289 for (int j = 0; j < data>dim.j; j++) 290 for (int i = 0; i < data>dim.i; i++) 291 { 292 if (list[i][j] == 1) 293 continue; 294 if (count[list[i][j]] < 3) 295 { 296 if (!data>pairs[i][j].piece) 297 data>pairs[i][j].id = 0; 298 continue; 299 } 300 301 data>pairs[i][j].id++; 302 data>pairs[i][j].piece = new Piece(data>emitter, int2(i, j), 80 + 20 * data>pairs[i][j].id); 303 Ticker::Ref(data>pairs[i][j].piece); 304 data>pairs[i][j].piece>SetPos(int2(i, j) * 48); 305 count[list[i][j]] = 0; 306 list[i][j] = 1; 307 } 308 309 printf("hits 2:\n"); 310 for (int j = data>dim.j; j;) 311 { 312 for (int i = 0; i < data>dim.i; i++) 313 printf("% 2i ", list[i][j]); 314 printf("\n"); 275 for (int j = 0; j < data>dim.j; j++) for (int i = 0; i < data>dim.i; i++) 276 { 277 if (list[i][j] == 1) 278 continue; 279 if (count[list[i][j]] < 3) 280 { 281 if (!data>pairs[i][j].piece) 282 data>pairs[i][j].id = 0; 283 continue; 284 } 285 286 data>pairs[i][j].id++; 287 if (data>pairs[i][j].id > data>npieces 288 && data>pairs[i][j].id <= data>maxnpieces) 289 { 290 data>npieces++; 291 data>thumbs>SetMax(data>npieces); 292 } 293 data>pairs[i][j].piece = new Piece(data>emitter, int2(i, j), 80 + 20 * data>pairs[i][j].id); 294 Ticker::Ref(data>pairs[i][j].piece); 295 data>pairs[i][j].piece>SetPos(int2(i, j) * 48); 296 count[list[i][j]] = 0; 297 list[i][j] = 1; 315 298 } 316 299 
trunk/monsterz/fusion.h
r344 r345 24 24 { 25 25 public: 26 Fusion(int2 dim, int npieces );26 Fusion(int2 dim, int npieces, int maxnpieces); 27 27 virtual ~Fusion(); 28 28 
trunk/monsterz/interface.cpp
r339 r345 83 83 Ticker::Unref(data>title); 84 84 data>title = NULL; 85 data>fusion = new Fusion(int2( 6, 8), 8);85 data>fusion = new Fusion(int2(8, 7), 4, 12); 86 86 Ticker::Ref(data>fusion); 87 87 #if 0 
trunk/monsterz/thumbs.cpp
r340 r345 45 45 : data(new ThumbsData()) 46 46 { 47 data>npieces = npieces;48 47 data>icons = Tiler::Register(PNG_ICONS, 24, 24, 1.0f); 49 48 50 for (int n = 0; n < data>npieces; n++) 51 { 52 data>count[n] = 0; 53 data>text[n] = new Text(NULL, "monsterz/gfx/font1.png"); 54 Ticker::Ref(data>text[n]); 55 int3 p = int3(476, 383  28 * n, 1); 56 data>text[n]>SetPos(p); 57 } 49 data>npieces = 0; 50 SetMax(npieces); 58 51 59 52 #if 0 … … 83 76 } 84 77 78 void Thumbs::SetMax(int npieces) 79 { 80 for (int n = npieces; n < data>npieces; n++) 81 Ticker::Unref(data>text[n]); 82 83 for (int n = data>npieces; n < npieces; n++) 84 { 85 data>count[n] = 0; 86 data>text[n] = new Text(NULL, "monsterz/gfx/font1.png"); 87 Ticker::Ref(data>text[n]); 88 int3 p = int3(476, 383  28 * n, 1); 89 data>text[n]>SetPos(p); 90 } 91 92 data>npieces = npieces; 93 } 94 85 95 void Thumbs::AddCount(int id, int count) 86 96 { 
trunk/monsterz/thumbs.h
r340 r345 27 27 virtual ~Thumbs(); 28 28 29 void SetMax(int npieces); 29 30 void AddCount(int id, int count); 30 31
Note: See TracChangeset
for help on using the changeset viewer.