Project

General

Profile

« Previous | Next » 

Revision 3f372405

Added by Leszek Koltunski over 3 years ago

Backing moves: constant angle speed.

View differences:

src/main/java/org/distorted/main/RubikPreRender.java
97 97
    mSolveObject          = false;
98 98
    mScrambleObject       = false;
99 99

  
100
    mCanRotate = true;
101
    mCanPlay   = true;
100
    unblockEverything();
102 101

  
103 102
    mOldObject = null;
104 103
    mNewObject = null;
......
146 145

  
147 146
  private void doEffectNow(BaseEffect.Type type)
148 147
    {
149
    int index = type.ordinal();
150

  
151 148
    try
152 149
      {
150
      int index = type.ordinal();
153 151
      mEffectID[index] = type.startEffect(mView.getRenderer().getScreen(),this);
154 152
      }
155 153
    catch( Exception ex )
156 154
      {
157 155
      android.util.Log.e("renderer", "exception starting effect: "+ex.getMessage());
158

  
159
      mCanPlay   = true;
160
      mCanRotate = true;
156
      unblockEverything();
161 157
      }
162 158
    }
163 159

  
......
188 184
          }
189 185
        }
190 186

  
191
      mCanRotate = true;
192
      mCanPlay   = true;
187
      unblockEverything();
193 188
      doEffectNow( BaseEffect.Type.WIN );
194 189
      }
195 190
    else
196 191
      {
197
      mCanRotate = true;
198
      mCanPlay   = true;
192
      unblockEverything();
199 193
      }
200 194

  
201 195
    mIsSolved = solved;
......
234 228

  
235 229
    if( mAddRotationID==0 ) // failed to add effect - should never happen
236 230
      {
237
      mCanRotate = true;
238
      mCanPlay   = true;
231
      unblockEverything();
239 232
      }
240 233
    }
241 234

  
......
244 237
  private void finishRotationNow()
245 238
    {
246 239
    mFinishRotation = false;
247
    mCanRotate      = false;
248
    mCanPlay        = false;
240
    blockEverything();
249 241
    mRotationFinishedID = mNewObject.finishRotationNow(this, mNearestAngle);
250 242

  
251 243
    if( mRotationFinishedID==0 ) // failed to add effect - should never happen
252 244
      {
253
      mCanRotate = true;
254
      mCanPlay   = true;
245
      unblockEverything();
255 246
      }
256 247
    }
257 248

  
......
263 254

  
264 255
    if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
265 256
      {
266
      mCanRotate= false;
267
      mCanPlay  = false;
257
      blockEverything();
268 258
      createObjectNow(mNextObject, mNextSize, null);
269 259
      doEffectNow( BaseEffect.Type.SIZECHANGE );
270 260
      }
......
278 268

  
279 269
    if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize)
280 270
      {
281
      mCanRotate= false;
282
      mCanPlay  = false;
271
      blockEverything();
283 272
      createObjectNow(mNextObject, mNextSize, mNextMoves);
284 273
      doEffectNow( BaseEffect.Type.SIZECHANGE );
285 274
      }
......
294 283
  private void scrambleObjectNow()
295 284
    {
296 285
    mScrambleObject = false;
297
    mCanRotate      = false;
298
    mCanPlay        = false;
299 286
    mIsSolved       = false;
287
    blockEverything();
300 288
    RubikScores.getInstance().incrementNumPlays();
301 289
    doEffectNow( BaseEffect.Type.SCRAMBLE );
302 290
    }
......
306 294
  private void solveObjectNow()
307 295
    {
308 296
    mSolveObject = false;
309
    mCanRotate   = false;
310
    mCanPlay     = false;
297
    blockEverything();
311 298
    doEffectNow( BaseEffect.Type.SOLVE );
312 299
    }
313 300

  
......
697 684
        {
698 685
        if( effectID == mEffectID[i] )
699 686
          {
700
          mCanRotate = true;
701
          mCanPlay   = true;
687
          unblockEverything();
702 688

  
703 689
          if( i==BaseEffect.Type.SCRAMBLE.ordinal() )
704 690
            {
src/main/java/org/distorted/screens/RubikScreenBase.java
34 34

  
35 35
abstract class RubikScreenBase extends RubikScreenAbstract implements RubikPreRender.ActionFinishedListener
36 36
  {
37
  private static final int DURATION_MILLIS = 750;
37
  private static final int REVOLUTION_MILLIS = 2000;
38 38

  
39 39
  private ImageButton mPrevButton, mLockButton;
40

  
41 40
  private boolean mCanPrevMove;
42 41

  
43 42
  private static class Move
......
65 64
      if( numMoves>0 )
66 65
        {
67 66
        RubikScreenBase.Move move = mMoves.remove(numMoves-1);
68
        TwistyObject object = pre.getObject();
69

  
70 67
        int axis  = move.mAxis;
71 68
        int row   = (1<<move.mRow);
72 69
        int angle = move.mAngle;
73
        int basic = object.getBasicAngle()[axis];
74
        int numRot= Math.abs(angle*basic/360);
70
        int duration= (int)(Math.abs(angle/360.0f)*REVOLUTION_MILLIS);
75 71

  
76 72
        if( angle!=0 )
77 73
          {
78 74
          mCanPrevMove = false;
79
          pre.addRotation(this, axis, row, -angle, numRot*DURATION_MILLIS);
75
          pre.addRotation(this, axis, row, -angle, duration);
80 76
          }
81 77
        else
82 78
          {

Also available in: Unified diff