Changeset 266 for trunk/monsterz/mash.cpp
- Timestamp:
- Jan 23, 2011, 5:47:21 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/monsterz/mash.cpp
r265 r266 33 33 Piece *pieces[8 * 8]; 34 34 Int2 cells[8 * 8]; 35 int npieces, finished; 35 int npieces; 36 37 enum 38 { 39 WAIT, 40 POP, 41 DEAD, 42 } 43 state; 36 44 }; 37 45 … … 47 55 Ticker::Ref(game); 48 56 data->npieces = 0; 49 data-> finished = 0;57 data->state = MashData::WAIT; 50 58 } 51 59 … … 57 65 } 58 66 59 int Mash::Is Finished() const67 int Mash::IsDead() const 60 68 { 61 return data-> finished;69 return data->state == MashData::DEAD; 62 70 } 63 71 … … 66 74 Entity::TickGame(deltams); 67 75 68 if (data->finished) 69 return; 76 switch (data->state) 77 { 78 case MashData::WAIT: 79 { 80 int inplace = 1; 81 for (int n = 0; n < data->npieces && inplace; n++) 82 { 83 Int2 dest = data->pieces[n]->GetCell() * 48; 84 Int2 cur = data->pieces[n]->GetPos(); 70 85 71 int inplace = 1; 72 for (int n = 0; n < data->npieces && inplace; n++) 86 /* If piece is still too high, don't start the animation */ 87 if (cur.y - dest.y > 2) 88 inplace = 0; 89 } 90 91 if (inplace) 92 { 93 for (int n = 0; n < data->npieces; n++) 94 data->pieces[n]->Pop(); 95 data->state = MashData::POP; 96 } 97 break; 98 } 99 case MashData::POP: 73 100 { 74 Int2 dest = data->pieces[n]->GetCell() * 48; 75 Int2 cur = data->pieces[n]->GetPos(); 76 77 /* If piece is still too high, don't start the animation */ 78 if (cur.y - dest.y > 12) 79 inplace = 0; 101 int alldead = 1; 102 for (int n = 0; n < data->npieces && alldead; n++) 103 if (!data->pieces[n]->IsDead()) 104 alldead = 0; 105 if (alldead) 106 { 107 for (int n = 0; n < data->npieces; n++) 108 Ticker::Unref(data->pieces[n]); 109 data->npieces = 0; 110 data->state = MashData::DEAD; 111 } 112 break; 80 113 } 81 82 if (inplace) 83 { 84 for (int n = 0; n < data->npieces; n++) 85 Ticker::Unref(data->pieces[n]); 86 data->finished = 1; 114 case MashData::DEAD: 115 break; 87 116 } 88 117 } … … 95 124 Mash::~Mash() 96 125 { 126 for (int n = 0; n < data->npieces; n++) 127 Ticker::Unref(data->pieces[n]); 97 128 Ticker::Unref(data->game); 98 129 delete data;
Note: See TracChangeset
for help on using the changeset viewer.