in the description, you should mention to press space bar, to see the other
awesome shapes. Great sketch!
int P=24;
String code ="ZRPL";
// All shapes ruthlessley stolen from the glsnake screensaver ...
// (c) Jamie Wilkinson, Andrew Bennetts and Peter Aylett
String[][] shapes = {
{ "straight", "ZZZZZZZZZZZZZZZZZZZZZZZZ" },
/* the models in the Rubik's snake manual */
{ "ball", "RRLLRLRRLRLLRRLLRLRRLRLZ" },
{ "snow", "RRRRLLLLRRRRLLLLRRRRLLLZ" },
{ "propellor", "ZZZRLRZLZZZRLRZLZZZRLRZL" },
{ "flamingo", "ZPZZZZZPRRPRLPLRPRRZZZPZ" },
{ "cat", "ZPPZPPZRZPPZPPZPPZZZZZZZ" },
{ "rooster", "ZZPPZLZLRPRZPPZRPRLZLZPZ" },
/* These models were taken from Andrew and Peter's original snake.c
* as well as some newer ones made up by JamieAndrew and Peter. */
{ "half balls", "LLRLRRLRLLLLLLRLRRLRLLLZ" },
{ "zigzag1", "RRRLLLRRRLLLRRRLLLRRRLLZ" },
{ "zigzag2", "PZPZPZPZPZPZPZPZPZPZPZPZ" },
{ "zigzag3", "PLPLPLPLPLPLPLPLPLPLPLPZ" },
{ "caterpillar", "RRPLLPRRPLLPRRPLLPRRPLLZ" },
{ "bow", "RLRRRLLLRLRRRLLLRLRRRLLZ" },
{ "turtle", "ZRLZZRLPRRLRLLPLLLRLRRRZ" },
{ "basket", "RPZZPLZLLZLPZZPRPLPZZPLZ" },
{ "thing", "PRLRRLPLRLLRPRLRRLPLRLLZ" },
{ "hexagon", "ZZZZLZZRZZZZLZZRZZZZLZZR" },
{ "tri1", "ZZLRZLZRZZLRZLZRZZLRZLZR" },
{ "triangle", "ZZZZZZLRZZZZZZLRZZZZZZLR" },
{ "flower", "ZLPRRPZLPRRPZLPRRPZLPRRP" },
{ "crucifix", "ZPPZPZPPZPZPPZPZZZPPZZZP" },
{ "kayak", "PRLPLPZZRPLZZZZZZRPLZZPR" },
{ "bird", "ZZZZRRZLPRZRZRZRPLZRLZPZ" },
{ "seal", "RLLPRLZPPZLZLPRZLLLPRRLZ" },
{ "dog", "ZZZZPPZPZZPZPPZZZPZPPZPZ" },
{ "frog", "RRLLRPRPLPRZLZLPRZLLRLLZ" },
{ "quavers", "LLRLRRZZZRZZLRZZZLLRLRRZ" },
{ "fly", "LLRLRRZPZZLPRZZPZLLRLRRZ" },
{ "puppy", "ZPZPPZPPZZZRRPRLPLRPRLZZ" },
{ "stars", "LRPRLPLRPRZZZRPRLPLRPRLZ" },
{ "mountains", "RPRPRPLPLPLPRPRPRPLPLPLP" },
{ "quad1", "RPRRRPLLLPLPRPRRRPLLLPLP" },
{ "quad2", "ZPRRRPLLLPZPZPRRRPLLLPZP" },
{ "glasses", "ZPZRRPLLZPZPZPZRRPLLZPZP" },
{ "em", "ZPZZRPLZZPZPZPZZRPLZZPZP" },
{ "quad3", "ZRZZRPLZZLZPZRZZRPLZZLZP" },
{ "vee", "ZZZZRPLZZZZPZZZZRPLZZZZP" },
{ "square", "ZZZRRPLLZZZPZZZRRPLLZZZP" },
{ "eagle", "RZZRRPLLZZLPRZZRRPLLZZLP" },
{ "volcano", "RZLRRPLLRZLPRZLRRPLLRZLP" },
{ "saddle", "RZLZRPLZRZLPRZLZRPLZRZLP" },
{ "c3d", "ZZRZZPZZLZZPZZRZZPZZLZZP" },
{ "block", "ZZPPZRPLPRPRPLPRZZPZZLPR" },
{ "duck", "LPLPZPPZPZLPRZPZPPZZLPLZ" },
{ "prayer", "RRRLRLLZZZRPLZZZRRLRLLLP" },
{ "giraffe", "ZZZRPLZZZRRRPLRZPZLRPLLL" },
{ "tie fighter", "PLRLLPRZRLZPLLRRRPLZLRZZ" },
{ "Strong Arms", "PPZZPZZRZRRPRRZRZZPZZPPZ" },
/* the following modesl were created during the slug/compsoc codefest
* febrray 2003 */
{ "cool looking gegl", "PPZZRZZPPZLZZPZPPZLRPZZZ" },
{ "knuckledusters", "ZZZZPRZPPZPPZRRZPPZPPZRZ" },
{ "k's turd", "RRPRLRPRLRPRLRPRLRPRLRPZ" },
{ "lightsabre", "ZZZZZPPZZZZZZZZZZZZZZZZZ" },
{ "not a stairway", "LZRLRZLRLZRLRZLRLZRLRZLZ" },
{ "not very good (but accurate) gegl", "ZPPZZZPPZLZPPZRLZPZPPZPZ" },
{ "box", "ZZZZPZZZZZZPZZZZPZZZZZZZ" },
{ "kissy box", "PZZZPZZZZZZPZZZZPZZZZZPZ" },
{ "erect penis", /* thanks benno */ "PZPPZZPZZZPPZZZRZZZZZZZZ" },
{ "flaccid penis", "PZPPZZPZZZPPZZZRPZZZZZZZ" },
{ "vagina", "RZZZRZZPZZLZZZLZLPLPRPRZ" },
{ "mask", "ZRLPRRPZZPZZPZPZPZZPZZZZ" },
{ "poles or columns or something", "LRLZZZPPZZZLRLZZZPPZZZLZ" },
{ "crooked v", "ZLZZZZPPZZZLZLZZZPPZZZZZ" },
{ "dog leg", "ZLZZZZPPZZZLZRZZZZPPZZZZ" },
{ "scrubby", "ZZZZZLZZZZLRZZZZLRZZLPZZ" },
{ "voltron's eyes", "ZZPRZLZZRZLPZZPZLZRLZRZZ" },
{ "flying toaster", "PZZPPZRZPPZRZPPZRZPPZZPZ" },
{ "dubbya", "PZZPPZRZPPZZZPPZRZPPZZPZ" },
{ "tap handle", "PZZPPZRZPPZLZPPZRZPPZZPZ" },
{ "wingnut", "PZZPPZRZPPZPZPPZRZPPZZPZ" },
{ "tight twist", "RZZLZLRZRLRPRLRZRLZLZZRZ" },
{ "double helix", "RZRZRZRZRZRZRLRPZRZRZRZZ" },
/* These models come from the website at
* http://www.geocities.com/stigeide/snake */
{ "Abstract", "RLRZPZLRLPZZPLRLZPZRLRZZ" },
{ "toadstool", "LRZRLZZRLPRRLRLLRRRPRLPZ" },
{ "AlanH2", "LRZRLZZRLPRRLRLLRRLLRLRZ" },
{ "AlanH3", "LRZRLZZRLPRRLRLLRRLPLRPZ" },
{ "AlanH4", "ZZPLRLZRLRZPZLRLZRLRPZZZ" },
{ "Alien", "RLRPZZPRLRZPPZLLRRLLZPPZ" },
{ "Angel", "ZRLPRRRLLRLRRLLLPRLZZRLZ" },
{ "AnotherFigure", "LPRZZPRLLPRLZPZRLPRRLPZZ" },
{ "Ball", "LRLRRLRLLRLRRLRLLRLRRLRZ" },
{ "Basket", "ZRRZRRZRLZLLPRLZLRPLLZLZ" },
{ "Beetle", "PLRZLLRLRRLRLLRLRRZLRPRZ" },
{ "bone", "PPLZPPZLZZZZZZZRZPPZRPPZ" },
{ "Bow", "LLLRLRRRLLLRLRRRLLLRLRRZ" },
{ "bra", "RRLLRLRRLLLRRRLLRLRRLLLZ" },
{ "bronchosaurus", "ZPZPPZPZZPZPPZZZZZZZZZPZ" },
{ "Cactus", "PLZPPZRPLZZPRPLZZRPLPZZZ" },
{ "Camel", "RZPRPRZRPRLPLRPRZRPRZZLZ" },
{ "Candlestick", "LPLZRPLZRPRPLPLZRPLZRPRZ" },
{ "Cat", "ZPPZPPZRZPPZPPZPPZZZZZZZ" },
{ "Cave", "RZZPLZPPZRLPRRLLPRRLPZZZ" },
{ "Chains", "PZZPLLPRRPZZPZZPLLPRRPZZ" },
{ "Chair", "RLRRRLRZZPPZPPZPPZZLRLLZ" },
{ "Chick", "RRRPLPLPRRRPLLLPRPRPLLLZ" },
{ "Clockwise", "RRRRRRRRRRRRRRRRRRRRRRRZ" },
{ "cobra", "ZRLLRLRRLRLLLLZLRZZPZZRZ" },
{ "Cobra2", "LZPZPLZPZLLPRRZPZRPZPZRZ" },
{ "Cobra3", "ZLZPPZPPZRZPZZLZZZPZZZLZ" },
{ "Compact1", "ZZPZZLPRPLPLPRPLZPPZZLPZ" },
{ "Compact2", "LPRZZPPZRPLZZRPRPLPRZZZZ" },
{ "Compact3", "ZPZPPZLPRZPPZPZPPZLPRZPZ" },
{ "Compact4", "PRZZPZZPPZPRPLPZPPZZPZZZ" },
{ "Compact5", "LZLPRPLPLPRPRPLPRZRPRPLZ" },
{ "Contact", "PZZPLLPLRRPLLRPRRPZZPRPZ" },
{ "Contact2", "RPZLLPRRZPLPRPZLLPRRZPLZ" },
{ "Cook", "ZZPPZRZRLPLZPPZLPLRZRZPZ" },
{ "Counterclockwise", "LLLLLLLLLLLLLLLLLLLLLLLZ" },
{ "Cradle", "LLZPLRLLRLRRLRPZRRLLZZRZ" },
{ "Crankshaft", "ZPPZPPZPLLPRLZPLPRZZZPRZ" },
{ "Cross", "ZPZPPZPZZZPPZZZPZPPZPZPZ" },
{ "Cross2", "ZZPPZLZZPPZRZZPPZLZZPPZZ" },
{ "Cross3", "ZZPPZLZZPPZRZZPPZLZZPPZZ" },
{ "CrossVersion1", "PZRPLPRPRPLPRZPRPRLPLRPZ" },
{ "CrossVersion2", "RLPLLZRLPRRPLLPRLZLLPLRZ" },
{ "Crown", "LZPZRZZLZPZRLZPZRZZLZPZZ" },
{ "DNAStrand", "RPRPRPRPRPRPRPRPRPRPRPRZ" },
{ "Diamond", "ZRZZLZZRPLLRLRRPLZZRZZLZ" },
{ "Dog", "RRLRLLLRRLRLLRRRLRLLZLRZ" },
{ "DogFace", "ZZPPZLLRPZPPZPLRRZPPZZPZ" },
{ "DoublePeak", "ZZPZZRLPLRPRLLZPZRRLPLRZ" },
{ "DoubleRoof", "ZLLRRLRLLRLRRLLZLRPLLPRZ" },
{ "txoboggan", "ZZZRPLZZZPPZZZZLPRZZZZPZ" },
{ "Doubled", "LPLRPRLPLRLZLPLPLRPRLPLZ" },
{ "Doubled1", "LPLRPRLPLZRZRZLPLRPRLPLZ" },
{ "Doubled2", "LPLRPRLPLLRZRLLPLRPRLPLZ" },
{ "DumblingSpoon", "PPZZZZZLZZLRZZLRZZRZZZZZ" },
{ "Embrace", "PZZPRPLPZRPRPLPLZPRPLPZZ" },
{ "EndlessBelt", "ZRLZZZLRZPRLZLRLPLRLZLRZ" },
{ "Entrance", "LLRRRLLRLRRRLLLRLRRLLLRZ" },
{ "Esthetic", "LLPRRZLPRPLPLPRPLZRLPRRZ" },
{ "Explosion", "RRRRLRLLRRRLRLLLRRLRLLLZ" },
{ "F-ZeroXCar", "RRLRLLPRLZZRLZZLRPRLPLRZ" },
{ "Face", "ZRPRLPLLPRRPRLPLPLPLRPRZ" },
{ "Fantasy", "LLRPZRZLPLPRPRZLZPLRRRPZ" },
{ "Fantasy1", "PZZPPZPRLRRPLLRLPZPPZZPZ" },
{ "FaserGun", "ZZLRPRZRPRLPLRPRZRPRRZPZ" },
{ "FelixW", "ZRZPLZLRZZRPLZZLRZRPZLZZ" },
{ "Flamingo", "ZPZZZZZPLLPLRPRLPLLZZZPZ" },
{ "FlatOnTheTop", "ZPPZPRZRLPRRPLRZRZZPZZPZ" },
{ "Fly", "ZLPRZPLPLRPRPRPLPLPLRPRZ" },
{ "Fountain", "LRLRRPLPLRRPLLRRPLLRPRPZ" },
{ "Frog", "LLRRLPLPRPLZRZRPLZRRLRRZ" },
{ "Frog2", "LZLRRPLRZZRPLZZLRPLLRZRZ" },
{ "Furby", "PZLPRZPPZPPZZPZRPLZPZZPZ" },
{ "Gate", "ZZPZZRZPPZLPLLPRRPRZPPZZ" },
{ "Ghost", "LLLRRLRLLRRRPLRZZLRZZLRZ" },
{ "Globus", "RLZPLLRRLRLLRLRRLRPZRLZZ" },
{ "Grotto", "PPZLRLZPRPLZZZZRPLPZRLRZ" },
{ "H", "PZPPZZZZPPZPLZPPZZZZPPZZ" },
{ "HeadOfDevil", "PZRZRPLZRPRLPLLPRRPRLZZZ" },
{ "Heart", "RZZZPLPLRRZPZLLRPRPZZZLZ" },
{ "Heart2", "ZPZZLZLZZZZPZZZZRZRZZPZZ" },
{ "Hexagon", "ZZZZLZZRZZZZLZZRZZZZLZZZ" },
{ "HoleInTheMiddle1", "ZLRPLLPRLZLRZRLPRRPLRZRZ" },
{ "HoleInTheMiddle2", "ZLRZRRPLRZRLZLRZRRPLRZRZ" },
{ "HouseBoat", "RRPLLLPRRRPLRZLPRPLPLRPZ" },
{ "HouseByHouse", "LPLPLPRPRPRPLPLPLPRPRPRZ" },
{ "Infinity", "LLLRRLLRRLLLLLLRRLLRRLLZ" },
{ "Integral", "RRRRRLLRLRRLLLLLLRRLRLLZ" },
{ "Iron", "ZZZZPRZRZZLPRZZRPLZZRZRZ" },
{ "just squares", "RRLPLPRPRLLPRRLPLPRPRLLZ" },
{ "Kink", "ZPPZPZPPZZRPLZZPPZPZPPZZ" },
{ "Knot", "LLPLZLRLPLLRRPRLRZRPRRLZ" },
{ "Leaf", "ZPPZZLZLZZPZZRZRPLZRPLZZ" },
{ "LeftAsRight", "RPLRLZRLPRRPLLPRLZRLRPLZ" },
{ "Long-necked", "PZLPLPRPRZPZLPLPRPLZPPZZ" },
{ "lunar module", "PLLRLRRLRLLRLRRPLRZRLZLZ" },
{ "magnifying glass", "ZZPZLZPPZZRPLZZPPZRZPZZZ" },
{ "Mask", "ZZZRZRLZLPZPZZPZPRZRLZLZ" },
{ "Microscope", "PPZZPZRPZZRPLZZPLZPPZPPZ" },
{ "Mirror", "PRLZPPZZLRZZPZZLRPRZPPZZ" },
{ "MissPiggy", "ZLLPRZRRPLLRRPLLZLPRRZRZ" },
{ "Mole", "ZRZRLRPZLPRZPLRLZLZRRPLZ" },
{ "Monk", "LZPPZLZPPZRZPPZRLRRLRLLZ" },
{ "Mountain", "ZRLPRRPLRZLPLZRLPRRPLRZZ" },
{ "mountains", "ZPZLPLRPRPRPLPLPLRPRZPZZ" },
{ "MouseWithoutTail", "ZPPZLZPPZZRPLZZPPZRZPPZZ" },
{ "mushroom", "PLLRLRRPLRZZLPZRZPPZLZPZ" },
{ "necklace", "ZZLZZZLZZZZPZZZZRZZZRZZZ" },
{ "NestledAgainst", "LZPLLRRPZRPLZRLPRRLRLLLZ" },
{ "NoClue", "ZRPLLLZLPRRPLLPRZRRRPLZZ" },
{ "Noname", "LPRPRZPZZPPZPPZRPLPRPRLZ" },
{ "Obelisk", "PZZZPRPLPLPLRPRPRPLPZZZZ" },
{ "Ostrich", "ZZPPZLZPPZPPZRZPPZZZZZPZ" },
{ "Ostrich2", "PPZPLLLRLRRLRLLRPZPZZPZZ" },
{ "pair of glasses", "ZPZZPZZPZLZPZRZPZZPZZPZZ" },
{ "Parrot", "ZZZZRRZLPRZRZRZRPLZRLZPZ" },
{ "Penis", "PPRZPPZPZZRPLZZPZPPZLPPZ" },
{ "PictureCommingSoon", "LLZRLPRRPRLPLRPRRPRLZRRZ" },
{ "Pitti", "LPZZPZZPZZRPLZZPZZPZZPRZ" },
{ "Plait", "LLLLLLLLLLRLRRRRRRRRRRLZ" },
{ "Platform", "RPZZZZPZZPPZPLZRLPRRPLRZ" },
{ "PodRacer", "ZPZPRPZRPLLPRLZPPZZLZPLZ" },
{ "Pokemon", "LLRLRRLLLRLRRLLRRLLRLRRZ" },
{ "Prawn", "RPZPRZPPZZLPRZZPPZLPZPLZ" },
{ "Propeller", "ZZZRZLRLZZZRZLRLZZZRZLRZ" },
{ "Pyramid", "ZLPRZLPRZLPRZPRLLLPRRRLZ" },
{ "QuarterbackTiltedAndReadyToHut", "PZRRLRPRLRZPZLRLPLRLLZPZ" },
{ "Ra", "PLLLRLRRLRLLZLLRLRRLRLLZ" },
{ "Rattlesnake", "LZLZLZLLZLZLZLRZPRRRRRRZ" },
{ "Revelation", "ZZZPZZPRLLLRRLLRRRLPZZPZ" },
{ "Revolution1", "LLPRZPZLPRRPLLPRZPZLPRRZ" },
{ "Ribbon", "RRLRLLPZPPZPZPPZPRRLRLLZ" },
{ "Rocket", "RZLPRZRZLZRPLZRZLZLPRZLZ" },
{ "Roofed", "ZLPRZPLZPZRPZLPRZPLZPZRZ" },
{ "Roofs", "PPRZLPRPLPLPRPRPLPRZLPPZ" },
{ "RowHouses", "RPLPRPRPLPLPRPRPLPLPRPLZ" },
{ "Sculpture", "RLPZZZLRLPZZPLRLZZZPLRLZ" },
{ "Seal", "LLLPRRRZLPRZLLLPRLZPPZLZ" },
{ "Seal2", "RPZLLLRLRRRPRRPLRZZLRZZZ" },
{ "Sheep", "RLLRRLLRLRRRRRLRLLLLLRLZ" },
{ "Shelter", "LRLRRLRLLRZZZZPZZPZZZZRZ" },
{ "Ship", "PRLLLLPRRRRLZLZRPLZLZPPZ" },
{ "Shpongle", "LRZRLRZRLRZRLRZRLRZRLRZZ" },
{ "Slide", "LRLRZLRLPZZPZZPRLZZRLRLZ" },
{ "SmallShip", "ZLRZRLZLRZLRZLRZRLZLRZLZ" },
{ "SnakeReadyToStrike", "LZLZLZLRZRZRZLZZZPZZZZLZ" },
{ "Snakes14", "RRPZRLRZZZRPLPZPLPRZZLRZ" },
{ "Snakes15", "ZPPZPPZPLLPRLZPLPRZZZPRZ" },
{ "Snakes18", "PPLPLPRZRPRZRPLPRZPPZZPZ" },
{ "Snowflake", "LLLRRRRLLLLRRRRLLLLRRRRZ" },
{ "Snowman", "ZPPZPPZZZPPZPPZZZPPZPPZZ" },
{ "Source", "PRZPZLPRPLLRLRRPLLRLRRPZ" },
{ "Spaceship", "PPRRPRLPLPRPRLPLRPRPRPPZ" },
{ "Spaceship2", "PPLPLPRZPPZLPRZPZLPLLPPZ" },
{ "Speedboat", "LZZLPRZZLZZPZZRZZLPRZZRZ" },
{ "Speedboat2", "PRLLRRRZLPRZLLLRRLPZRPLZ" },
{ "Spider", "RRZZLRLPZLZPPZRZPRLRZZLZ" },
{ "Spitzbergen", "PLZRRLPZLPRRPLLPRZPRLLZZ" },
{ "Square", "ZZLLPRRZZLLPRRZZLLPRRZZZ" },
{ "SquareHole", "PZPZZPPZPZZPZZPZPPZZPZPZ" },
{ "Stage", "RZLPLRPRLRPRLPLRLPLRPRZZ" },
{ "Stairs", "ZPZPZPZPZPZPZPZPZPZPZPZZ" },
{ "Stairs2", "ZPZPZPPZZPZPZPZPZPPZZPZZ" },
{ "Straight", "ZZZZZZZZZZZZZZZZZZZZZZZZ" },
{ "Swan", "ZPZPLLPLPRPRLPLRPRPLPLRZ" },
{ "Swan2", "PZPRRRLRLLRLRRRPZZZZZPPZ" },
{ "Swan3", "PPZZZRZRZZLPRZZRPLZZRZRZ" },
{ "Symbol", "RRPZPPZPLLRLRRPZPPZPLLRZ" },
{ "Symmetry", "RZLRLZLRLZRPLZRLRZRLRZLZ" },
{ "Symmetry2", "ZPLLPZZLPRPLLPRRPLLPRPLZ" },
{ "TableFireworks", "ZRLPRRRPLRZRLPRRRPRLZRPZ" },
{ "Tapering", "ZZRLPLZPPZLPRZPPZRPRLZZZ" },
{ "TaperingTurned", "ZZRLPLZPPZLZRZPPZRPRLZZZ" },
{ "TeaLightStick", "RZPPZLRPLLRRPLLRRPLLRRPZ" },
{ "thighmaster", "RZZRLZZRLZZLRZZRLZZRLZZZ" },
{ "Terraces", "RLZRLPLLPLRRRLLLRPRRPRLZ" },
{ "Terrier", "PZPPZPZZZPPZPZZPZPPZZZZZ" },
{ "Three-Legged", "RZLRZLPRZRZPZLZLPRZLRZLZ" },
{ "ThreePeaks", "RZZRPLPRPRRPLLPLPRPLZZLZ" },
{ "ToTheFront", "ZPRLLLPRLZPPZLLPZLRZPZLZ" },
{ "Top", "PLLPLZZRLPRRLRLLPRPRRPZZ" },
{ "Transport", "PZZPPZPPZPPZPPZPPZZPZZZZ" },
{ "Triangle", "ZZZZZZRLZZZZZZRLZZZZZZRZ" },
{ "Tripple", "PZPLPRPRPZPLPRPZPLPLPRPZ" },
{ "Turtle", "RRRLRLLLPLLRLRRPLRZZLRZZ" },
{ "Twins", "ZPZLPLRPRPZZPLPLRPRZPZZZ" },
{ "TwoSlants", "ZPZZPPZPZRPRLPLPRPLZZRPZ" },
{ "TwoWings", "PLZRZPPZPPZPPZLZRPLZRLZZ" },
{ "UFO", "LLRLRRLRLLLPLLLRLRRLRLLZ" },
{ "USS Enterprise", "LPRPRLZPPZRLZPPZRLPLPRZZ" },
{ "UpAndDown", "ZPZPZPLPRPZPZPZPZPLPRPZZ" },
{ "Upright", "ZRRLRLLPZZLPRZZPRRLRLLZZ" },
{ "Upside-down", "PZZZPPZRRLLPRRLLZPPZZZPZ" },
{ "Valley", "ZRPLPRPRLRZPZLRLPLPRPLZZ" },
{ "Viaduct", "PRPLPZZPRZRRZRPZZPLPRPZZ" },
{ "View", "ZRPLPRZZRPLLRRPLZZLPRPLZ" },
{ "Waterfall", "LZRPLZRPLZRPLZRPLZRPLZRZ" },
{ "windwheel", "PRRPZLPRRPZLPRRPZLPRRPZZ" },
{ "Window", "PZPPZZPZPZPZZPZPZPPZZZZZ" },
{ "WindowToTheWorld", "PLZPZZPZZPZRPLZPZZPZZPZZ" },
{ "Windshield", "PPZRPLLPRZPZLPRRPLZPPZPZ" },
{ "WingNut", "ZZZZPRRRPRLPLRPRRRPZZZZZ" },
{ "Wings2", "RZPZLPRPRLRRLLRLPLPRZPZZ" },
{ "WithoutName", "PRPRRPLLPZPRPLPZPRRPLLPZ" },
{ "Wolf", "ZZPPZPZZPZPPZPZZZPPZZZPZ" },
{ "X", "LZZPLRRPLRZPPZLRPLLRPZZZ" }
};
/////////////////////////////////////
// //
// /////// Rubik's Snake //
// // //
// /////////////////////////////////
//
/////////// (c) Martin Schneider 2009
// http://www.k2g2.org/blog:bit.craft
// This is a simple 3D simulation of Rubik's Snake
int psel, sel;
float W, zoom, rotX, rotY, tween;
float cx, cy, cz;
boolean translucent, edges;
void setup() {
size(500, 500, P3D);
W = width / 2;
textFont(createFont("", max(12, W / 15)));
textMode(SCREEN);
zoom = W / 10;
tween = 1;
}
void draw() {
background(255);
// interpolate between shapes
tween = min(tween + .01, 1);
// calculate the center of the snake
snake(false);
// move the camera to the center
beginCamera();
camera();
translate(cx, cy, cz);
endCamera();
lights();
// draw the snake
snake(true);
// draw the label
fill(0, abs(.5 - tween) * 255);
text(shapes[tween < .5 ? psel : sel][0], 10, 30);
}
void snake(boolean drawIt) {
cx = cz = cy = 0;
translate(W, W, W);
rotateX(rotX);
rotateY(rotY);
scale(zoom);
for(int i = 0; i < P; i++) {
translate(-.5, 0,-.5);
if(drawIt) {
prism(i);
} else {
cx += (modelX(0, 0, 0) - W) / P;
cy += (modelY(0, 0, 0) - W) / P;
cz += (modelZ(0, 0, 0) - W) / P;
}
translate(0, .5, .5);
rotateZ(HALF_PI);
float a0 = code.indexOf(shapes[psel][1].charAt(i));
float a1 = code.indexOf(shapes[sel][1].charAt(i));
rotateY(PI + lerp(a0, a1, tween) * HALF_PI);
}
}
void prism(int n) {
color[] c= { #ff9999, #9999ff };
int[][] v = {
{0, 0, 0}, {1, 0, 0}, {0, 1, 0},
{0, 0, 1}, {1, 0, 1}, {0, 1, 1}
};
int[][][] f = {
{v[0], v[1], v[2]},
{v[3], v[4], v[5]},
{v[0], v[1], v[4], v[3]},
{v[0], v[2], v[5], v[3]},
{v[1], v[2], v[5], v[4]}
};
fill(c[n%2], translucent ? 50 : 255);
strokeWeight(edges ? zoom *.1 : 0);
for(int i=0; i<f.length; i++) {
beginShape();
for(int j=0; j<f[i].length; j++)
vertex(f[i][j][0], f[i][j][1], f[i][j][2]);
endShape();
}
}
void switchShape(int n) {
if (tween < 1) return;
psel = sel;
sel = (sel + n + shapes.length ) % shapes.length;
tween=0;
}
void mouseDragged() {
if (mouseButton == LEFT) {
rotY += TWO_PI * (mouseX - pmouseX) / width;
rotX -= TWO_PI * (mouseY - pmouseY) / height;
} else {
zoom = constrain(zoom - .1 * (mouseY - pmouseY), 1, W / 7.5);
}
}
void keyPressed() {
switch(key) {
case 'e': edges = !edges; break;
case 't': translucent = !translucent; break;
case ' ': switchShape(1 + (int) random(shapes.length - 1)); break;
}
switch(keyCode) {
case RIGHT: switchShape(+1); break;
case LEFT: switchShape(-1); break;
}
}
OpenProcessing is an online community platform devoted to sharing and discussing Processing sketches in a collaborative, open-source environment.
Download Processing
Terms of Service
To contact, send an email to:

See the feedback forum and vote!
Follow OpenProcessing on Twitter.
All sketches are licensed under Creative Commons Attribution-Share Alike 3.0.
Syntax highlighting and Processing brush under LGPL 3.
All the source code is licensed under Creative Commons GNU GPL.
Comments engine by Scriptsmill Comments Script.


