Revision 2df35810
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objectlib/effects/EffectController.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
public interface EffectController extends EffectListener |
29 | 29 |
{ |
30 |
void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration);
|
|
30 |
void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, int duration);
|
|
31 | 31 |
TwistyObject getOldObject(); |
32 | 32 |
TwistyObject getObject(); |
33 | 33 |
int getNumScrambles(); |
src/main/java/org/distorted/objectlib/effects/scramble/ScrambleEffect.java | ||
---|---|---|
70 | 70 |
private EffectController mController; |
71 | 71 |
private int mEffectReturned; |
72 | 72 |
private int mNumScramblesLeft; |
73 |
private long mDurationPerDegree;
|
|
73 |
private int mDurationPerDegree;
|
|
74 | 74 |
private final Random mRnd; |
75 | 75 |
private int[] mBasicAngle; |
76 | 76 |
private boolean mRotReady, mPluginReady; |
... | ... | |
133 | 133 |
int row = mScrambles[mNumScrambles][1]; |
134 | 134 |
int angle= mScrambles[mNumScrambles][2]; |
135 | 135 |
|
136 |
int rowBitmap= (1<<row); |
|
137 |
int absAngle = (angle<0 ? -angle : angle); |
|
138 |
int basicDegrees = 360/mBasicAngle[axis]; |
|
139 |
long durationMillis = absAngle*basicDegrees*mDurationPerDegree; |
|
140 |
|
|
141 | 136 |
mNumScramblesLeft--; |
142 |
mController.addRotation(this, axis, rowBitmap, angle*basicDegrees, durationMillis);
|
|
137 |
mController.addRotation(this, axis, (1<<row), angle, mDurationPerDegree);
|
|
143 | 138 |
mNumScrambles++; |
144 | 139 |
} |
145 | 140 |
else |
src/main/java/org/distorted/objectlib/main/ObjectControl.java | ||
---|---|---|
249 | 249 |
private void finishRotation() |
250 | 250 |
{ |
251 | 251 |
computeCurrentSpeedInInchesPerSecond(); |
252 |
int angle = mPreRender.getObject().computeNearestAngle(mCurrentAxis,mCurrentAngle, mCurrRotSpeed); |
|
252 |
TwistyObject object = mPreRender.getObject(); |
|
253 |
int angle = object.computeNearestAngle(mCurrentAxis,mCurrentAngle, mCurrRotSpeed); |
|
253 | 254 |
mPreRender.finishRotation(angle); |
254 | 255 |
mPreRender.rememberMove(mCurrentAxis,mCurrentRow,angle); |
255 | 256 |
|
256 | 257 |
if( angle!=0 ) |
257 | 258 |
{ |
258 | 259 |
TwistyActivity act = mAct.get(); |
259 |
mActioner.onFinishRotation(act,mCurrentAxis,mCurrentRow,angle); |
|
260 |
|
|
261 |
int basicAngle= object.getBasicAngle()[mCurrentAxis]; |
|
262 |
int realAngle = (angle*basicAngle)/360; |
|
263 |
|
|
264 |
mActioner.onFinishRotation(act,mCurrentAxis,mCurrentRow,realAngle); |
|
260 | 265 |
} |
261 | 266 |
|
262 | 267 |
mContinuingRotation = false; |
... | ... | |
657 | 662 |
|
658 | 663 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
659 | 664 |
|
660 |
public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration)
|
|
665 |
public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, int duration)
|
|
661 | 666 |
{ |
662 | 667 |
mPreRender.addRotation(listener,axis,rowBitmap,angle,duration); |
663 | 668 |
} |
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java | ||
---|---|---|
485 | 485 |
|
486 | 486 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
487 | 487 |
|
488 |
public void addRotation(MovesFinished listener, int axis, int rowBitmap, int angle, long duration)
|
|
488 |
public void addRotation(MovesFinished listener, int axis, int rowBitmap, int bareAngle, int millPreDegree)
|
|
489 | 489 |
{ |
490 | 490 |
mAddRotation = true; |
491 | 491 |
|
492 |
int basicAngle= mNewObject.getBasicAngle()[axis]; |
|
493 |
int angle = bareAngle*(360/basicAngle); |
|
494 |
int duration = Math.abs(angle)*millPreDegree; |
|
495 |
|
|
492 | 496 |
mAddActionListener = listener; |
493 | 497 |
mAddRotationAxis = axis; |
494 | 498 |
mAddRotationRowBitmap = rowBitmap; |
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
1240 | 1240 |
return mQuat; |
1241 | 1241 |
} |
1242 | 1242 |
|
1243 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1244 |
|
|
1245 |
public void apply(Effect effect, int position) |
|
1246 |
{ |
|
1247 |
mEffects.apply(effect, position); |
|
1248 |
} |
|
1249 |
|
|
1250 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1251 |
|
|
1252 |
public void remove(long effectID) |
|
1253 |
{ |
|
1254 |
mEffects.abortById(effectID); |
|
1255 |
} |
|
1256 |
|
|
1243 | 1257 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1244 | 1258 |
// PUBLIC API |
1245 | 1259 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1261 | 1275 |
return mNumLayers; |
1262 | 1276 |
} |
1263 | 1277 |
|
1264 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1265 |
|
|
1266 |
public void apply(Effect effect, int position) |
|
1267 |
{ |
|
1268 |
mEffects.apply(effect, position); |
|
1269 |
} |
|
1270 |
|
|
1271 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1272 |
|
|
1273 |
public void remove(long effectID) |
|
1274 |
{ |
|
1275 |
mEffects.abortById(effectID); |
|
1276 |
} |
|
1277 |
|
|
1278 | 1278 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1279 | 1279 |
|
1280 | 1280 |
public synchronized void solve() |
Also available in: Unified diff
Simplifications