Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.applet.Applet;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.geom.Ellipse2D;
- // import java.awt.geom.Ellipse2D.Double;
- public class Slinkey extends Applet {
- private static final long serialVersionUID = 4803949557086825455L;
- public void paint(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- int x = 10;
- int y = 10;
- int w = 100;
- int h = 100;
- int k = 0;
- int otherX = 0;
- double xpos = 0, ypos = 10;
- System.out.println(xpos + " " + ypos);
- Ellipse2D.Double c1 = new Ellipse2D.Double(ypos, ypos, w, h);
- for (k = 0; k < 155; k += 5) {
- xpos = x + k;
- ypos = getYStart(xpos);
- System.out.println(xpos + " " + ypos);
- c1.setFrame(xpos, ypos, w, h); // (10, 10) (Top left corner) (1325, 650) (Bottom right corner).
- g2.draw(c1);
- }
- for (double i = 160; i < 1325; i++) {
- xpos = x + i;
- ypos = getYMain(otherX);
- otherX++;
- System.out.println("Y Coordinate: " + xpos + " " + ypos);
- if (ypos < 652) {
- c1.setFrame(xpos, ypos, w, h);
- g2.draw(c1);
- }
- }
- }
- public static double getYStart(double x) { // Starting trajectory.
- return (0.029) * (Math.pow(x - 10, 2) + 10);
- }
- public static double getYMain(double x) { // Main equation that is causing problems.
- return (Math.pow(x - 100, 2) + 10);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement