zopiac

20/9/10

Sep 20th, 2010
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.28 KB | None | 0 0
  1. import turtles.*;
  2. ////////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
  3. ////////Select and uncomment each section of code (ctrl+/) one at a time to test each script
  4. public class Testing extends TurtleProgram {
  5.     public void run() {
  6.         this.setSize(1600, 900);
  7.        
  8. ////start code1                                         ////// 9/15/10 First test of while statements
  9. //      int var;
  10. //      int rav;
  11. //      rav = 50;
  12. //      var = 0;
  13. //      while(var < 3) {
  14. //              Turtle eltrey;
  15. //              eltrey = new Turtle(200, rav);
  16. //              eltrey.forward(100);
  17. //              eltrey.hide();
  18. //              var = var + 1;
  19. //              rav = rav + 50;
  20. //      }
  21. //    }
  22. //}
  23. ////end code1
  24.        
  25. ////start code2                                         ////// 9/15/10 First test of readInt command
  26. //      Turtle eltrey;                                  //hurr
  27. //      eltrey = new Turtle(50, 50);                    //durr
  28. //      int degrees = this.readInt();                   //--//Input number of degrees to turn in all
  29. //      int dPerIt = this.readInt();                    //--//Input number of degrees to turn per iteration
  30. //      int pPerIt = this.readInt();                    //--//Input number of pixels to move per iteration
  31. //      degrees = degrees / dPerIt;                     //compensates for the degree change due to 'right(dPerIt)'
  32. //      int amt = 0;                                    //sets initial amount of iterations
  33. //      while (amt < degrees) {                         //start while loop to repeat following lines until 'degrees' if fulfilled
  34. //                      eltrey.forward(pPerIt);         //moves eltrey 'pPerIt' pixels
  35. //                      eltrey.right(dPerIt);           //turns eltrey 'dPerIt' degrees
  36. //                      amt = amt + 1;                  //changes amount of iterations
  37. //              }
  38. //      eltrey.forward(50);                             //following lines create 100px line tangent to the created semi/circle
  39. //      eltrey.right(180);
  40. //      eltrey.forward(100);
  41. //      
  42. //    }
  43. //}
  44. ////end code2
  45.  
  46. ////start code3                                         //////// 9/15/10 Creates a semicircle using two turtle objects and creates a tangent line 100px long.
  47. //      Turtle eltrey;                                  //hurr
  48. //      eltrey = new Turtle(50, 50);                    //durr
  49. //      Turtle yertle;                                  //initialises a second turtle
  50. //      yertle = new Turtle(50, 165);                   //places the second turtle
  51. //      int degrees = 90;                               //each turtle makes a quarter of a circle
  52. //      int amt = 0;                                    //sets initial amount of iterations
  53. //      while (amt < degrees) {                         //start while loop to repeat following lines until 'degrees' if fulfilled
  54. //                      eltrey.forward(5);              //moves eltrey '5' pixels
  55. //                      eltrey.right(5);                //turns eltrey '5' degrees
  56. //                      yertle.forward(5);              //moves yertle '5' pixels
  57. //                      yertle.left(5);                 //turns yertle '5' degrees
  58. //                      amt = amt + 5;                  //changes amount of iterations
  59. //              }
  60. //      eltrey.forward(50);                             //following lines create 100px line tangent to the created semi/circle
  61. //      yertle.forward(50);
  62. //      
  63. //    }
  64. //}
  65. ////end code3
  66.        
  67. ////start code4                                         //////// 9/16/10 Input the number of sides you want on the N-Gon that is to be generated by the script.
  68. //      Turtle marisa;                                  //Makes turtle named Marisa
  69. //      marisa = new Turtle (500, 800);                 //              (named after the character sprite used)
  70. //      int sides = this.readInt("How many sides?");                     //--//Input number of sides for the N-Gon to have
  71. //      int reps = 0;                                   //Sets variable 'reps' which is the amount of repetitions of the while statemen completed.
  72. //      double deg = 360 / sides;                       //Calculates number of degrees for Marisa to turn to initiate each side (from
  73. //      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.
  74. //              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
  75. //              marisa.left(deg);                       //Turns the appropriate angle to create the next edge
  76. //              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.
  77. //      }
  78. //      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
  79. //    }                                                 //              no real reason. Instead of the while statement completing the last line and turning, it goes to this and
  80. //}                                                     //              draws the last line.
  81. ////end code4
  82.        
  83. ////start code5                                         //////// 9/17/10 Workspace for the first code to be implemented into the Castle text adventure.
  84. //      String name = readLine("What is your name, hero?");
  85. //      println("Welcome to the Castle Alpha, " + name);
  86. //     
  87. //     
  88. //         
  89. //      }
  90. //  }  
  91. ////end code5
  92.  
  93. //start code6                                                       //////// 9/17/10 Password entry test.
  94.         String exit = "n";                                          //ensures that the 'exit' variable is not set to 'yes'
  95.         int failed = 0;                                             //used to count how many times the user has failed in inputting the correct password
  96.         int locked = 0;                                             //indicates whether or not the account is locked from too incorrect many password entries
  97.         int correct = 0;                                            //indicates whether or not the given entry matches the selected password or not
  98.         while(!exit.equals("y")) {                                  //while 'yes' was not (yet) selected at the "Quit?" prompt...
  99.             String password = readLine("Enter new password.");      //creates the password
  100.             while (locked == 0) {                                   //while the account is not locked...
  101.                 while (correct != 1) {                              //while the password is not correct...
  102.                     String enteredPass = readLine("Password? ");    //enter the chosen password
  103.                     if (!enteredPass.equals(password)) {            //if it is correct
  104.                         correct = 1;                                //then log the fact that it is correct
  105.                     } else if (failed < 3) {                        //else if it is incorrect
  106.                         println("Access denied");                   //then say "Access denied"
  107.                         failed = failed + 1;                        //and give them a strike
  108.                     } else if (failed >= 3) {                       //but if they fail thrice
  109.                         println("Too many attempts.");              //alert them off this fact
  110.                         locked = 1;                                 //banhammer them
  111. //                      failed = 0;
  112.                     }
  113.                 } if (correct == 1) {
  114.                     println("OK");
  115.                 }
  116.             exit = readLine("Quit? y/n");
  117.             }
  118.         } exit = readLine("Logging Off");
  119.         System.exit(0);
  120.     }
  121. }
  122.        
  123.  
  124. //end code6
Advertisement
Add Comment
Please, Sign In to add comment