Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.*;
- import java.awt.*;
- import java.awt.image.BufferedImage;
- public class asd extends Applet{
- double prevRotation=0, boatRotation=0, x1, x2, y1, y2, i, r;
- BufferedImage img = new BufferedImage(500, 500, BufferedImage.TYPE_BYTE_BINARY);
- Graphics g1 = img.getGraphics();
- StringBuffer c = new StringBuffer("summon Boat ~ ~2 ~ {");
- String p = "}";
- boolean resize = true;
- /**********************************************************************/
- double length = 6*Math.PI;
- String riddenEntity = "Arrow, Riding:{id:MinecartRideable}";
- //Functions being graphed. Change length to show more/less
- public double f(double i){
- //return 6*Math.cos(5D/7D*i); //length 7*PI
- //return 7.3*Math.cos(2D/5D*i); //length 10*PI
- return 7.3*Math.cos(4D/3D*i); //length 6*PI
- //return i;
- }
- /**********************************************************************/
- public void init(){
- setSize(500,500);
- }
- public void update(Graphics g){
- while(i<length){
- r = f(i);
- x1 = x2 = r*Math.cos(i);
- y1 = y2 = r*Math.sin(i);
- while(Math.pow((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1), 0.5)<0.4){
- i+=0.00001;//instead of doing math let's use a *really* big loop =D
- r = f(i);
- x2 = r*Math.cos(i);
- y2 = r*Math.sin(i);
- }
- r = f(i-0.001);
- x1 = r*Math.cos(i-0.001);
- y1 = r*Math.sin(i-0.001);
- prevRotation = boatRotation;
- boatRotation= Math.atan((y2-y1)/(x2-x1))*57.2957;
- while(boatRotation<prevRotation){
- boatRotation+=180;
- }
- g1.fillRect(250+(int)(20*x2), 250+(int)(20*y2), 2, 2);
- c.append("Rotation:["+(int)(boatRotation*10)/10D+"F,0F],Riding:{id:Boat,");
- p+="}";
- }
- c.replace(c.length()-5, c.length(), riddenEntity+p);
- System.out.print(resize?(c.length()<16376?c:c+"\ntoo long for command block!"):"");
- resize=false;
- g.drawImage(img, 0, 0, null);
- }
- public void paint(Graphics g){
- update(g);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement