zopiac

Testing 9/28/10

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