Revision 486b3417
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.ObjectShape; |
25 | 25 |
import org.distorted.helpers.ObjectSticker; |
26 |
import org.distorted.helpers.ScrambleStateGraph; |
|
26 | 27 |
import org.distorted.library.main.DistortedEffects; |
27 | 28 |
import org.distorted.library.main.DistortedTexture; |
28 | 29 |
import org.distorted.library.mesh.MeshSquare; |
... | ... | |
135 | 136 |
mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke); |
136 | 137 |
} |
137 | 138 |
|
139 |
private int mCurrState; |
|
140 |
private int mIndexExcluded; |
|
141 |
private final ScrambleStateGraph[] mStates; |
|
142 |
|
|
138 | 143 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
139 | 144 |
|
140 | 145 |
TwistyDiamond(int size, Static4D quat, DistortedTexture texture, |
141 | 146 |
MeshSquare mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth) |
142 | 147 |
{ |
143 | 148 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.DIAM, res, scrWidth); |
149 |
|
|
150 |
int[] tmp = new int[3*2*size]; |
|
151 |
|
|
152 |
for(int i=0; i<2*size; i++) |
|
153 |
{ |
|
154 |
tmp[3*i ] = (i<size) ? i:i-size; |
|
155 |
tmp[3*i+1] = (i%2==0) ? -1:1; |
|
156 |
tmp[3*i+2] = 0; |
|
157 |
} |
|
158 |
|
|
159 |
mStates = new ScrambleStateGraph[] |
|
160 |
{ |
|
161 |
new ScrambleStateGraph( new int[][] {tmp,tmp,tmp,tmp} ) |
|
162 |
}; |
|
144 | 163 |
} |
145 | 164 |
|
146 | 165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
515 | 534 |
|
516 | 535 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
517 | 536 |
|
518 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int total) |
|
537 |
public void randomizeNewScramble(int[][] scramble, Random rnd, int curr, int totalScrambles)
|
|
519 | 538 |
{ |
520 | 539 |
if( curr==0 ) |
521 | 540 |
{ |
522 |
scramble[curr][0] = rnd.nextInt(NUM_AXIS); |
|
523 |
} |
|
524 |
else |
|
525 |
{ |
|
526 |
int newVector = rnd.nextInt(NUM_AXIS -1); |
|
527 |
scramble[curr][0] = (newVector>=scramble[curr-1][0] ? newVector+1 : newVector); |
|
541 |
mCurrState = 0; |
|
542 |
mIndexExcluded =-1; |
|
528 | 543 |
} |
529 | 544 |
|
530 |
float rowFloat = rnd.nextFloat(); |
|
531 |
int numLayers = getNumLayers(); |
|
545 |
int total = mStates[mCurrState].getTotal(mIndexExcluded); |
|
546 |
int random= rnd.nextInt(total); |
|
547 |
int[] info= mStates[mCurrState].getInfo(random,mIndexExcluded); |
|
532 | 548 |
|
533 |
for(int row=0; row<numLayers; row++) |
|
534 |
{ |
|
535 |
if( rowFloat*numLayers <= row+1 ) |
|
536 |
{ |
|
537 |
scramble[curr][1] = row; |
|
538 |
break; |
|
539 |
} |
|
540 |
} |
|
549 |
scramble[curr][0] = info[0]; |
|
550 |
scramble[curr][1] = info[1]; |
|
551 |
scramble[curr][2] = info[2]; |
|
541 | 552 |
|
542 |
switch( rnd.nextInt(2) ) |
|
543 |
{ |
|
544 |
case 0: scramble[curr][2] = -1; break; |
|
545 |
case 1: scramble[curr][2] = 1; break; |
|
546 |
} |
|
553 |
mCurrState = info[3]; |
|
554 |
mIndexExcluded = info[0]; |
|
547 | 555 |
} |
548 | 556 |
|
549 | 557 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert the Diamonds & the Helicopter to the new, unified scrambling method.