Results 1 to 3 of 3

Thread: Fish animation

  1. #1
    SwEeTAcTioN's Avatar
    SwEeTAcTioN is offline Member
    Join Date
    Oct 2009
    Posts
    69
    Rep Power
    0

    Default Fish animation

    So i was playin around with awt and drew a fish now i won the fish to move across the screen which ive sorta done ive gat it to mave but the line just gets thicker(run the code if you dont understand). How do i make it draw a new line (already done) but how do i make it erase the old line:confused:

    All help is appreciated:)


    Java Code:
    import java.io.*;
     import java.util.Random;
     import java.text.DecimalFormat;
     import javax.swing.*;
     import java.awt.*;
    import java.awt.event.*;
    import java.awt.Color;
    
    public class Template
    {
    	public static void main (String args[])throws IOException
    	{
          Windows win = new Windows();
          win.setSize(800,600);
          win.addWindowListener(new WindowAdapter() {public void
          windowClosing(WindowEvent e) {System.exit(0);}});
          win.show();
           }
    }
    
    class Windows extends Frame
    {
           public void paint(Graphics screen)
           {
        
             Polygon fish= new Polygon();
            
             for(int x1=1;x1<=60;x1++)
             {
             fish.addPoint((125+x1),150);
             fish.addPoint((125+x1),350);
             fish.addPoint((175+x1),250);
             screen.drawPolygon(fish);
             screen.drawLine((175+x1),250,(250+x1),400);
             screen.drawLine((250+x1),400,(375+x1),275);
             screen.drawLine((375+x1),275,(260+x1),125);
             screen.drawLine((175+x1),250,(260+x1),125);
             screen.drawOval((290+x1),225,50,50);
             screen.setColor(Color.green);
             screen.fillOval((308+x1),242,20,20);
             delay(5000);
             }
             
           } 
     public static void delay(double d)
         {
         double n;
         for(n=0;(n<=d);n+=.0001);
         } 
    /* public static move(int x1)           //comment out start
      {
    	int move=x1+=1;
    	return move;                           
      }
       public static move2(int x2)
      {
    	int move2=x2+=1;
    	return move2;
      }*/                                         // comment out end
    }
    Are you suggesting that Cocunuts migrate?!! -Monty Python

  2. #2
    SwEeTAcTioN's Avatar
    SwEeTAcTioN is offline Member
    Join Date
    Oct 2009
    Posts
    69
    Rep Power
    0

    Default

    um... a little help please
    Are you suggesting that Cocunuts migrate?!! -Monty Python

  3. #3
    SwEeTAcTioN's Avatar
    SwEeTAcTioN is offline Member
    Join Date
    Oct 2009
    Posts
    69
    Rep Power
    0

    Default

    Im gonna mark this as solved and open it up in the AWT section
    Are you suggesting that Cocunuts migrate?!! -Monty Python

Similar Threads

  1. Animation with Animated GIF
    By JavaBean in forum Java 2D
    Replies: 3
    Last Post: 06-04-2011, 04:26 PM
  2. need help about animation ?
    By h9h in forum Java 2D
    Replies: 1
    Last Post: 10-30-2009, 11:41 AM
  3. JTextArea Animation
    By hoglu in forum New To Java
    Replies: 1
    Last Post: 12-18-2008, 11:44 AM
  4. Two sleeps in animation
    By George1935 in forum AWT / Swing
    Replies: 4
    Last Post: 10-13-2008, 12:47 AM
  5. GUI Animation
    By serfster in forum New To Java
    Replies: 2
    Last Post: 06-11-2008, 03:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •