zopiac

9/17/10

Sep 17th, 2010
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.53 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);                                                //commented out by default because it is boring
  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, 500);                 //              (named after the character sprite used)
  70. //      int sides = this.readInt();                             //--//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. //      marisa.hide();                                //              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. //}                                                                                    
  82. ////end code4
  83.        
  84. //start code5
Advertisement
Add Comment
Please, Sign In to add comment