Changeset 248
- Timestamp:
- Jan 20, 2011, 2:59:43 PM (12 years ago)
- Location:
- trunk/monsterz
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/monsterz/board.cpp
r245 r248 121 121 if (cur_cell.i < 0 || cur_cell.i >= 8 122 122 || cur_cell.j < 0 || cur_cell.j >= 8 123 || (cur_pos - cur_cell * 48).sqlen() > 24 * 24) 123 || (cur_pos - cur_cell * 48).sqlen() > 24 * 24 124 || (cur_cell - data->src_cell).sqlen() != 1) 124 125 cur_cell = Int2(-1); 125 /* If target cell changed, change destinations. */126 /* If potential target changed, update our cache. */ 126 127 if (cur_cell != data->dst_cell) 127 128 { … … 129 130 data->pieces[data->dst_cell.i] 130 131 [data->dst_cell.j]->Goto(data->dst_cell * 48); 131 if (cur_cell != Int2(-1) 132 && (cur_cell - data->src_cell).sqlen() == 1) 132 if (cur_cell != Int2(-1)) 133 133 data->pieces[cur_cell.i] 134 134 [cur_cell.j]->Goto(data->src_cell * 48); … … 136 136 } 137 137 } 138 if (!buttons[0] || mouse.x < 0 || mouse.y < 0) 138 if (!buttons[0] || mouse.x < 0 || mouse.y < 0 139 || (data->src_cell * 48 140 - data->grabbed->GetPos()).sqlen() > 100 * 100) 139 141 { 142 if (data->dst_cell != Int2(-1)) 143 { 144 Piece *src = data->pieces[data->src_cell.i][data->src_cell.j]; 145 Piece *dst = data->pieces[data->dst_cell.i][data->dst_cell.j]; 146 data->pieces[data->src_cell.i][data->src_cell.j] = dst; 147 data->pieces[data->dst_cell.i][data->dst_cell.j] = src; 148 src->SetCell(data->dst_cell); 149 src->Goto(data->dst_cell * 48); 150 dst->SetCell(data->src_cell); 151 dst->Goto(data->src_cell * 48); 152 } 140 153 data->grabbed->Ungrab(); 141 if (data->dst_cell != Int2(-1))142 data->pieces[data->dst_cell.i]143 [data->dst_cell.j]->Goto(data->dst_cell * 48);144 154 data->state = BoardData::IDLE; 145 155 } -
trunk/monsterz/piece.cpp
r245 r248 62 62 } 63 63 64 void Piece::SetCell(Int2 cell) 65 { 66 data->cell = cell; 67 } 68 64 69 Int2 Piece::GetPos() const 65 70 { -
trunk/monsterz/piece.h
r245 r248 23 23 virtual ~Piece(); 24 24 25 void SetCell(Int2 cell); 25 26 Int2 GetPos() const; 26 27
Note: See TracChangeset
for help on using the changeset viewer.