Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtles.*;
- ////////My turtle library uses a modified sprite which is the character from the Touhou game series, Marisa Kirisame. Just to clear up some possible confusion later
- ////////Select and uncomment each section of code (ctrl+/) one at a time to test each script
- public class Testing extends TurtleProgram {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public void run() {
- this.setSize(1600, 900);
- ////start code1 ////// 9/15/10 First test of while statements
- // int var;
- // int rav;
- // rav = 50;
- // var = 0;
- // while(var < 3) {
- // Turtle eltrey;
- // eltrey = new Turtle(200, rav);
- // eltrey.forward(100);
- // eltrey.hide();
- // var = var + 1;
- // rav = rav + 50;
- // }
- // }
- //}
- ////end code1
- ////start code2 ////// 9/15/10 First test of readInt command
- // Turtle eltrey; //hurr
- // eltrey = new Turtle(50, 50); //durr
- // int degrees = this.readInt(); //--//Input number of degrees to turn in all
- // int dPerIt = this.readInt(); //--//Input number of degrees to turn per iteration
- // int pPerIt = this.readInt(); //--//Input number of pixels to move per iteration
- // degrees = degrees / dPerIt; //compensates for the degree change due to 'right(dPerIt)'
- // int amt = 0; //sets initial amount of iterations
- // while (amt < degrees) { //start while loop to repeat following lines until 'degrees' if fulfilled
- // eltrey.forward(pPerIt); //moves eltrey 'pPerIt' pixels
- // eltrey.right(dPerIt); //turns eltrey 'dPerIt' degrees
- // amt = amt + 1; //changes amount of iterations
- // }
- //// eltrey.forward(50); //following lines create 100px line tangent to the created semi/circle
- //// eltrey.right(180);
- //// eltrey.forward(100);
- //
- // }
- //}
- ////end code2
- ////start code3 //////// 9/15/10 Creates a semicircle using two turtle objects and creates a tangent line 100px long.
- // Turtle eltrey; //hurr
- // eltrey = new Turtle(50, 50); //durr
- // Turtle yertle; //initialises a second turtle
- // yertle = new Turtle(50, 165); //places the second turtle
- // int degrees = 90; //each turtle makes a quarter of a circle
- // int amt = 0; //sets initial amount of iterations
- // while (amt < degrees) { //start while loop to repeat following lines until 'degrees' if fulfilled
- // eltrey.forward(5); //moves eltrey '5' pixels
- // eltrey.right(5); //turns eltrey '5' degrees
- // yertle.forward(5); //moves yertle '5' pixels
- // yertle.left(5); //turns yertle '5' degrees
- // amt = amt + 5; //changes amount of iterations
- // }
- // eltrey.forward(50); //following lines create 100px line tangent to the created semi/circle
- // yertle.forward(50);
- //
- // }
- //}
- ////end code3
- ////start code4 //////// 9/16/10 Input the number of sides you want on the N-Gon that is to be generated by the script.
- // Turtle marisa; //Makes turtle named Marisa
- // marisa = new Turtle (500, 500); // (named after the character sprite used)
- // int sides = this.readInt("How many sides?"); //--//Input number of sides for the N-Gon to have
- // int reps = 0; //Sets variable 'reps' which is the amount of repetitions of the while statemen completed.
- // double deg = 360 / sides; //Calculates number of degrees for Marisa to turn to initiate each side (from
- // while(reps < sides -1) { //Start of the loop to creat the main meat of the output, the N-Gon. As for the -1, see after this while statement.
- // marisa.forward(1200 / sides); //Draws the side, the '/ sides' just ensures that in case you want a 100-Gon it doesn't draw to infinity and beyond
- // marisa.left(deg); //Turns the appropriate angle to create the next edge
- // reps = reps + 1; //Acts as a counter for the while statement, simply to end the loop at the appropriate time, no matter what 'sides' is.
- // }
- // marisa.forward(1200 / sides); //Utilises the -1 just so that the animation doesn't end with her doing a fruitless turn. It just annoys me for
- // } // no real reason. Instead of the while statement completing the last line and turning, it goes to this and
- //} // draws the last line.
- ////end code4
- ////start code5 //////// 9/17/10 Workspace for the first code to be implemented into the Castle text adventure.
- // String name = readLine("What is your name, hero?");
- // println("Welcome to the Castle Alpha, " + name);
- //
- //
- //
- // }
- // }
- ////end code5
- ////start code6 //////// 9/17/10 Password entry test.
- // String exit = "n"; //ensures that the 'exit' variable is not set to 'yes'
- // int failed = 0; //used to count how many times the user has failed in inputting the correct password
- // int locked = 0; //indicates whether or not the account is locked from too incorrect many password entries
- // int correct = 0; //indicates whether or not the given entry matches the selected password or not
- // while(!exit.equals("y")) { //while 'yes' was not (yet) selected at the "Quit?" prompt...
- // String password = readLine("Enter new password."); //creates the password
- // while (locked == 0) { //while the account is not locked...
- // while (correct != 1) { //while the password is not correct...
- // while (locked != 1) {
- // String enteredPass = readLine("Password? "); //enter the chosen password
- // if (enteredPass.equals(password)) { //if it is correct
- // correct = 1; //then log the fact that it is correct
- // } else if (failed < 3) { //else if it is incorrect
- // println("Access denied"); //then say "Access denied"
- // failed = failed + 1; //and give them a strike
- // } else if (failed >= 3) { //but if they fail thrice
- // println("Too many attempts."); //alert them off this fact
- // locked = 1; //and banhammer them
- // }
- // }
- // } if (correct == 1) {
- // println("OK");
- // }
- // exit = readLine("Quit? y/n");
- // }
- // } exit = readLine("Logging Off");
- // System.exit(0);
- // }
- //}
- ////end code6
- ////start code7
- // Turtle marisa = new Turtle(500, 500);
- // int forward = 1;
- // while(true){
- // marisa.forward(forward);
- // marisa.right(50);
- // forward = forward + 1;
- // }
- // }
- //}
- ////end code7
Advertisement
Add Comment
Please, Sign In to add comment