// This Java file was automatically generated by ToonTalk for Feb 21h import ap.toontalk.*; // Robot30_6570006: Score Keeper class Robot30_6570006 extends TTRobot { Robot30_6570006(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; // pick up what's in the first hole inside his box hand = given.pickUp(0); // drop it on the second hole inside his box given.holeGets(1, hand); return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot25_2285445166: Bounce class Robot25_2285445166 extends TTRobot { Robot25_2285445166(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; TTObject temp1; // move to the stack of numbers temp1 = new TTNumber(1); // pick up a number hand = temp1; // push '-' to change what he is holding hand.keyboard('-', true, false); // push 'x' to change what he is holding hand.keyboard('x', true, false); hand.stoppedTyping(); // drop it on the second hole inside his box given.holeGets(1, hand); // push '+' while pointing to the first hole inside his box given.hole(0).keyboard('+', false, false); given.hole(0).stoppedTyping(); return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot27_10113136: Sound when collide class Robot27_10113136 extends TTRobot { Robot27_10113136(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; // pick up what's in the second hole inside his box hand = given.pickUp(1); // use it what he is holding hand.use(); // drop it on the second hole inside his box given.holeGets(1, hand); return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot28_811171888: Serve class Robot28_811171888 extends TTRobot { Robot28_811171888(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; TTObject temp1; TTObject temp2; // pick up what's in the fifth hole inside his box hand = given.pickUp(4); // use it what he is holding hand.use(); // drop it on the fifth hole inside his box given.holeGets(4, hand); // move to the stack of numbers temp1 = new TTNumber(1); // pick up a number hand = temp1; // push '-' to change what he is holding hand.keyboard('-', true, false); hand.stoppedTyping(); // give it to the bird in the fourth hole inside his box given.hole(3).gets(hand); // move to the stack of numbers temp2 = new TTNumber(1); // pick up a number hand = temp2; // push '9' to change what he is holding hand.keyboard('9', true, false); // push '0' to change what he is holding hand.keyboard('0', false, false); // push '0' to change what he is holding hand.keyboard('0', false, false); // push '=' to change what he is holding hand.keyboard('=', false, false); hand.stoppedTyping(); // drop it on the first hole inside his box given.holeGets(0, hand); return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } // Robot1850_124686375: Move with Arrow Keys class Robot1850_124686375 extends TTRobot { Robot1850_124686375(TTNotebook n) { notebook = n; } public TTObject gets(TTObject given) throws TTException { if (!wants.matches(given)) return null; // If given a box that matches the box in his thought bubble (called "wants"), // this robot will do the following: TTObject hand; TTObject temp1; // grab a magic wand TTCopier copier = new TTCopier(); hand = copier; // use the magic wand on the third hole inside his box hand = copier.applyTo(given.hole(2), this); // drop what he just copied on the first hole inside his box given.holeGets(0, hand); // release the magic wand return this; // This robot has finished and will see if the box still matches his thoughts and try again. } } public class PongDemo extends TTApplet { public static void main(String args[]) { new TTFrame().begin(new PongDemo()); } public void initialize() { intializeToonTalkImages(); intializeNests(); TTNotebook notebook = TT.NOTEBOOK; TTRobot next_robot; TTPicture picture2 = new TTRectangle(500, 500, 1000, 1000, 0, 0, 0, 128, 0, true, true, false); setPicture(picture2); picture2.addPicture(PongDemo.PicturePart1(notebook, picture2)); picture2.addPicture(PongDemo.PicturePart1(notebook, picture2).resetGeometry(449, -916, 1992, 2011, 0, 0)); picture2.addPicture(PongDemo.PicturePart1(notebook, picture2).resetGeometry(1973, 502, 1992, 2011, 0, 0)); picture2.addPicture(PongDemo.PicturePart2(notebook, picture2)); picture2.addPicture(PongDemo.PicturePart3(notebook, picture2)); picture2.addPicture(PongDemo.PicturePart4(notebook, picture2)); TTObject temp0 = new TTText("Pong Demo"); picture2.addOnBack(temp0); TTObject temp1 = new TTText("Press up arrow to move up.\rPress down arrow to move down.\rAnd any other key to stop."); picture2.addOnBack(temp1); picture2.start(); } public static TTPicture PicturePart1(TTNotebook notebook, TTPicture container) { TTPicture picture3 = new TTRectangle(521, 1895, 1992, 2011, 0, 0, 128, 0, 0, true, true, false); return picture3; } public static TTPicture PicturePart2(TTNotebook notebook, TTPicture container) { TTPicture picture4 = new TTIndirectPicture(new TTNumber(9, TT.NO_NUMBER_OPERATION, 255, 255, 255), 953, 968, 81, 145, 0, 0, false, true, false); TTBox box5 = new TTBox(2); TTPicture picture6 = new TTRemoteLooks(picture4, 500, 500, 1000, 1000, 0, 0, false, true, false); box5.setHole(0, nest0); box5.setHole(1, picture6); // We just made a box with 2 holes. The first hole contains an empty nest. // The hole labeled with "Looks" contains a remote control for another's // looks - the integer 9. The first thing on the back is something. And the // second thing on the back is a robot who wants a box with 2 holes. The // first hole contains any number. The hole labeled with "Looks" contains any // number. If given a box like that he will pick up what's in the first hole // inside his box. And drop it on the second hole inside his box. TTRobot robot7 = new Robot30_6570006(notebook); TTBox box8 = new TTBox(2); TTBox wants1 = box8; // This robot will only accept a box with 2 holes. The first hole contains // any number. The hole labeled with "Looks" contains any number. wants1.setHole(0, TT.BLANK_NUMBER); wants1.setHole(1, TT.BLANK_NUMBER); robot7.setWants(wants1); TTTeam team7 = new TTTeam(box5, robot7); picture4.addTeam(team7); return picture4; } public static TTPicture PicturePart3(TTNotebook notebook, TTPicture container) { TTPicture picture9 = new TTGIFPicture("klmgjpnlbohccclhlngpfnjgabhgpcka.gif", false, 627, 344, 39, 52, 455, 344, false, true, false); picture9.addOnBack(PongDemo.PicturePart5(notebook, picture9)); picture9.addOnBack(PongDemo.PicturePart6(notebook, picture9)); picture9.addOnBack(PongDemo.PicturePart7(notebook, picture9)); return picture9; } public static TTPicture PicturePart4(TTNotebook notebook, TTPicture container) { TTPicture picture10 = new TTGIFPicture("elmcpoccmnboleljnleiackkcmmmkocc.gif", false, 47, 453, 56, 257, 0, 0, false, true, false); TTBox box11 = new TTBox(3); box11.setHole(0, new TTRemoteInteger(83, null, TT.NO_NUMBER_OPERATION, TT.Y_REMOTE, picture10, TT.BRITISH_ENGLISH)); box11.setHole(1, new TTRemotePicture(-2147483648, null, TT.NO_NUMBER_OPERATION, TT.LAST_KEYSTROKE_REMOTE, TT.GLOBAL_REMOTE, TT.AMERICAN_ENGLISH)); box11.setHole(2, new TTNumber(10, TT.NO_NUMBER_OPERATION, 0, 0, 0)); // We just made a box with 3 holes. The hole labeled with "Up" contains a // remote control for the distance from the bottom side. The hole labeled // with "Last Key" contains a remote control for the last key pressed. The // third hole contains the integer 10. TTRobot robot12 = new Robot1850_124686375(notebook); TTBox box13 = new TTBox(3); TTBox wants2 = box13; // This robot will only accept a box with 3 holes. The hole labeled with "Up" // contains any number (for example, a remote control for the distance from // the bottom side). The hole labeled with "Last Key" contains a remote // control for the last key pressed. The third hole contains any number. wants2.setHole(0, TT.BLANK_NUMBER); wants2.setHole(1, new TTText("Up arrow")); wants2.setHole(2, TT.BLANK_NUMBER); robot12.setWants(wants2); TTTeam team12 = new TTTeam(box11, robot12); picture10.addTeam(team12); TTBox box14 = new TTBox(3); box14.setHole(0, new TTRemoteInteger(83, null, TT.NO_NUMBER_OPERATION, TT.Y_REMOTE, picture10, TT.BRITISH_ENGLISH)); box14.setHole(1, new TTRemotePicture(-2147483648, null, TT.NO_NUMBER_OPERATION, TT.LAST_KEYSTROKE_REMOTE, TT.GLOBAL_REMOTE, TT.AMERICAN_ENGLISH)); box14.setHole(2, new TTNumber(-10, TT.NO_NUMBER_OPERATION, 0, 0, 0)); // We just made a box with 3 holes. The hole labeled with "Up" contains a // remote control for the distance from the bottom side. The hole labeled // with "Last Key" contains a remote control for the last key pressed. The // third hole contains the integer -10. TTRobot robot15 = new Robot1850_124686375(notebook); TTBox box16 = new TTBox(3); TTBox wants3 = box16; // This robot will only accept a box with 3 holes. The hole labeled with "Up" // contains any number (for example, a remote control for the distance from // the bottom side). The hole labeled with "Last Key" contains a remote // control for the last key pressed. The third hole contains any number. wants3.setHole(0, TT.BLANK_NUMBER); wants3.setHole(1, new TTText("Down arrow")); wants3.setHole(2, TT.BLANK_NUMBER); robot15.setWants(wants3); TTTeam team15 = new TTTeam(box14, robot15); picture10.addTeam(team15); TTObject temp2 = new TTText("Move Up and Down\rwith arrow keys"); picture10.addOnBack(temp2); return picture10; } public static TTPicture PicturePart5(TTNotebook notebook, TTPicture container) { TTPicture picture17 = new TTRectangle(500, 500, 44, 59, 0, 0, 128, 0, 0, false, true, true); TTBox box18 = new TTBox(2); box18.setHole(0, new TTRemoteInteger(0, null, TT.NO_NUMBER_OPERATION, TT.X_HIT_OR_MISS_REMOTE, picture17, TT.AMERICAN_ENGLISH)); box18.setHole(1, new TTRemoteInteger(455, null, TT.NO_NUMBER_OPERATION, TT.X_SPEED_REMOTE, picture17, TT.BRITISH_ENGLISH)); // We just made a box with 2 holes. The hole labeled with "Right Collide?" // contains a remote control for the left/right movement collision detector. // The hole labeled with "Right Speed1" contains a remote control for the // speed towards the right. TTRobot robot19 = new Robot25_2285445166(notebook); TTBox box20 = new TTBox(2); TTBox wants4 = box20; // This robot will only accept a box with 2 holes. The hole labeled with // "Right Collide?" contains a movie of the hit or miss cartoon. The hole // labeled with "Right Speed1" contains any number (for example, a remote // control for the speed towards the right). wants4.setHole(0, new TTNumber(1)); wants4.setHole(1, TT.BLANK_NUMBER); robot19.setWants(wants4); TTTeam team19 = new TTTeam(box18, robot19); picture17.addTeam(team19); TTBox box22 = new TTBox(2); box22.setHole(0, new TTRemoteInteger(0, null, TT.NO_NUMBER_OPERATION, TT.Y_HIT_OR_MISS_REMOTE, picture17, TT.AMERICAN_ENGLISH)); box22.setHole(1, new TTRemoteInteger(344, null, TT.NO_NUMBER_OPERATION, TT.Y_SPEED_REMOTE, picture17, TT.BRITISH_ENGLISH)); // We just made a box with 2 holes. The hole labeled with "Up Collide?" // contains a remote control for the up/down movement collision detector. The // hole labeled with "Up Speed" contains a remote control for the speed // towards the top. TTRobot robot23 = new Robot25_2285445166(notebook); TTBox box24 = new TTBox(2); TTBox wants5 = box24; // This robot will only accept a box with 2 holes. The hole labeled with // "Right Collide?" contains a movie of the hit or miss cartoon. The hole // labeled with "Right Speed1" contains any number (for example, a remote // control for the speed towards the right). wants5.setHole(0, new TTNumber(1)); wants5.setHole(1, TT.BLANK_NUMBER); robot23.setWants(wants5); TTTeam team23 = new TTTeam(box22, robot23); picture17.addTeam(team23); TTObject temp3 = new TTText("Bounce off\rof things"); picture17.addOnBack(temp3); return picture17; } public static TTPicture PicturePart6(TTNotebook notebook, TTPicture container) { TTPicture picture26 = new TTRectangle(500, 500, 44, 59, 0, 0, 0, 128, 0, false, true, true); TTBox box27 = new TTBox(2); box27.setHole(0, new TTRemoteInteger(0, null, TT.NO_NUMBER_OPERATION, TT.HIT_OR_MISS_REMOTE, picture26, TT.AMERICAN_ENGLISH)); box27.setHole(1, new TTSound("pop.au", "Pop")); // We just made a box with 2 holes. The hole labeled with "Collide?" contains // a remote control for the detector which shows a simple cartoon of either a // collision or a miss. You can turn a collision into a miss by pointing to // the detector and pressing +. The hole labeled with "Sound" contains a // sound "Pop". TTRobot robot28 = new Robot27_10113136(notebook); TTBox box29 = new TTBox(2); TTBox wants6 = box29; // This robot will only accept a box with 2 holes. The hole labeled with // "Collide?" contains a movie of the hit or miss cartoon. The second hole // contains any sound. wants6.setHole(0, new TTNumber(1)); wants6.setHole(1, TT.BLANK_SOUND); robot28.setWants(wants6); TTTeam team28 = new TTTeam(box27, robot28); picture26.addTeam(team28); TTObject temp4 = new TTText("Make Sound\rWhen Colliding"); picture26.addOnBack(temp4); return picture26; } public static TTPicture PicturePart7(TTNotebook notebook, TTPicture container) { TTPicture picture31 = new TTRectangle(500, 500, 44, 59, 0, 0, 128, 128, 0, false, true, true); TTBox box32 = new TTBox(5); box32.setHole(0, new TTRemoteInteger(614, null, TT.NO_NUMBER_OPERATION, TT.X_REMOTE, picture31, TT.BRITISH_ENGLISH)); box32.setHole(1, new TTScale('>')); box32.setHole(2, new TTNumber(0, TT.NO_NUMBER_OPERATION, 0, 0, 0)); box32.setHole(3, new TTBird()); box32.hole(3).setNest(nest0); box32.setHole(4, new TTSound("plop.au", "Plop")); // We just made a box with 5 holes. The hole labeled with "Right" contains a // remote control for the distance from the left side. The second hole // contains a tottering scale. The third hole contains the integer 0. The // fourth hole contains a bird. The fifth hole contains a sound "Plop". TTRobot robot34 = new Robot28_811171888(notebook); TTBox box35 = new TTBox(5); TTBox wants7 = box35; // This robot will only accept a box with 5 holes. The hole labeled with // "Right" contains any number (for example, a remote control for the // distance from the left side). The second hole contains a tottering scale. // The third hole contains the integer 0. The fourth hole contains a bird. // The fifth hole contains a sound "Plop". wants7.setHole(0, TT.BLANK_NUMBER); wants7.setHole(1, new TTScale('<')); wants7.setHole(2, new TTNumber(0, TT.NO_NUMBER_OPERATION, 0, 0, 0)); wants7.setHole(3, new TTBird()); wants7.setHole(4, new TTSound("plop.au", "Plop")); robot34.setWants(wants7); TTTeam team34 = new TTTeam(box32, robot34); picture31.addTeam(team34); TTObject temp5 = new TTText("Serve Again\rif off the left side"); picture31.addOnBack(temp5); return picture31; } protected static TTNest nest0; private void intializeNests() { nest0 = new TTNest(); } private void intializeToonTalkImages() { } }