Changeset 746
- Timestamp:
- Mar 28, 2011, 1:31:29 AM (10 years ago)
- Location:
- trunk/monsterz
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/monsterz/board.cpp
r740 r746 237 237 } 238 238 } 239 240 /* Move initiated: if valid, perform immediately. */ 241 if (data->dst_cell != vec2i(-1)) 242 { 243 vec2i cell_a = data->src_cell; 244 vec2i cell_b = data->dst_cell; 245 246 if (Switch(cell_a, cell_b)) 247 data->state = BoardData::HUNT_IDLE; 248 } 249 250 /* Mouse released, or exited window, or dragged too far. */ 239 251 if (!buttons[0] || mousepos.x == -1 240 252 || (data->src_cell * data->size - data->grabbed.piece->GetPos() 241 253 - data->grabbed.piece->GetOffset()).sqlen() > 100 * 100) 242 254 { 243 /* Mouse released, or exited window, or dragged too far. */ 244 data->grabbed.piece->Ungrab(data->grabbed.piece->GetCell() * data->size); 255 vec2i cell_a = data->src_cell; 256 BoardData::Pair a = data->pairs[cell_a.i][cell_a.j]; 257 a.piece->Ungrab(cell_a * data->size); 258 245 259 if (data->dst_cell != vec2i(-1)) 246 Switch(data->src_cell, data->dst_cell); 260 { 261 vec2i cell_b = data->dst_cell; 262 BoardData::Pair b = data->pairs[cell_b.i][cell_b.j]; 263 b.piece->Ungrab(cell_b * data->size); 264 } 265 247 266 data->state = BoardData::HUNT_IDLE; 248 267 } … … 392 411 } 393 412 394 voidBoard::Switch(vec2i cell_a, vec2i cell_b)413 bool Board::Switch(vec2i cell_a, vec2i cell_b) 395 414 { 396 415 BoardData::Pair a = data->pairs[cell_a.i][cell_a.j]; … … 407 426 data->pairs[cell_a.i][cell_a.j] = a; 408 427 data->pairs[cell_b.i][cell_b.j] = b; 409 a.piece->Ungrab(cell_a * data->size); 410 b.piece->Ungrab(cell_b * data->size); 411 return; 428 return false; 412 429 } 413 430 … … 541 558 data->pairs[i][0].piece->SetBelow(below[i]); 542 559 } 560 561 return true; 543 562 } 544 563 -
trunk/monsterz/board.h
r664 r746 42 42 /* Hunt mode */ 43 43 void Fill(); 44 voidSwitch(vec2i cell_a, vec2i cell_b);44 bool Switch(vec2i cell_a, vec2i cell_b); 45 45 int ListMashes(int list[MAX_WIDTH][MAX_HEIGHT]); 46 46 int ListMoves(int list[MAX_WIDTH][MAX_HEIGHT]); -
trunk/monsterz/mash.cpp
r735 r746 88 88 for (int n = 0; n < data->npieces && allready; n++) 89 89 { 90 /* If piece is still too high, don't start the animation */90 /* If piece is still too far, don't start the animation */ 91 91 vec2i shift = data->pieces[n]->GetShift(); 92 if ( shift.y > 2 || abs(shift.x) > 2)92 if (abs(shift.y) + abs(shift.x) > 0) 93 93 allready = 0; 94 94 }
Note: See TracChangeset
for help on using the changeset viewer.