Animasi Menggunkan Java



PROJEK ANIMASI PEMANDANGAN ALAM
Fiqri muhammad Luthfi
20170910059
SI  2017 A

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication9;


import java.awt.*;
import javax.swing.*;


public class JavaApplication9 extends JPanel {
    int xroda=0,yroda=0;
    int roda=0, troda=0;
    int arah=0;
    int xawan=0,yawan=0;
    

   
        private void gerak(){
        xroda = xroda+5;
        if(xroda>=1000){
            xroda=2;
       
        roda = troda+5;
        if(roda<=1100){
            roda=2;
        
        
        }
        }   
    }
         
            public void paint(Graphics g){
            super.paint(g);
            //background
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, 1080, 250);
           
            //backgroundh
            g.setColor(Color.LIGHT_GRAY);
            g.fillRect(0, 250, 1080, 250);
           
            g.setColor(Color.orange);
            g.fillOval(400, 10, 70, 70);
            g.fillRect(435, 85, 2, -20);
            g.fillRect(435, 13, 2, 12);
            g.fillRect(475, 45, 20, -2);
           
            //awan1
            g.setColor(Color.LIGHT_GRAY);
            g.fillOval(50+xroda, 10, 30, 30);
            g.fillOval(70+xroda, 5, 30, 30);
            g.fillOval(90+xroda, 10, 30, 30);
            g.fillOval(95+xroda, 30, 30, 30);
            g.fillOval(55+xroda, 30, 30, 30);
            g.fillOval(75+xroda, 30, 30, 30);
            g.fillOval(115+xroda, 20, 30, 30);
            g.fillOval(170+xroda, 50, 30, 30);
            g.fillOval(150+xroda, 60, 30, 30);
            g.fillOval(150+xroda, 80, 30, 30);
            g.fillOval(170+xroda, 60, 30, 30);
            g.fillOval(170+xroda, 80, 30, 30);
            g.fillOval(190+xroda, 60, 30, 30);
           

            //awan2
            g.fillOval(420, 15, 30, 30);
            g.fillOval(440, 15, 30, 30);
            g.fillOval(460, 25, 30, 30);
            g.fillOval(450, 35, 30, 30);
            g.fillOval(425, 35, 30, 30);
            g.fillOval(430, 35, 30, 30);
            g.fillOval(410, 35, 30, 30);
            //
            g.fillOval(340, 25, 30, 30);
            g.fillOval(360, 25, 30, 30);
            g.fillOval(380, 35, 30, 30);
            g.fillOval(370, 45, 30, 30);
            g.fillOval(345, 45, 30, 30);
            g.fillOval(320, 45, 30, 30);
             //awan2
            g.fillOval(920-xroda, 55, 30, 30);
            g.fillOval(940-xroda, 55, 30, 30);
            g.fillOval(960-xroda, 65, 30, 30);
            g.fillOval(950-xroda, 75, 30, 30);
            g.fillOval(925-xroda, 75, 30, 30);
            g.fillOval(900-xroda, 75, 30, 30);
           
            //jalan
            g.setColor(Color.BLACK);
            g.drawRect(-1, 400, 1080, 200);
            g.fillRect(-1, 400, 1080, 200);
            g.setColor(Color.WHITE);          
            g.fillRect(0, 490, 30, 10);
            g.fillRect(100, 490, 50, 10);
            g.fillRect(200, 490, 50, 10);
            g.fillRect(300, 490, 50, 10);
            g.fillRect(400, 490, 50, 10);
            g.fillRect(500, 490, 50, 10);
            g.fillRect(600, 490, 50, 10);
            g.fillRect(700, 490, 50, 10);
            g.fillRect(800, 490, 50, 10);
            g.fillRect(900, 490, 50, 10);
            g.fillRect(1000, 490, 50, 10);
           
            g.setColor(Color.DARK_GRAY);
            g.fillRect(0, 390, 1080, 20);
            g.fillRect(0, 600, 1080, 20);
                       //hujan
            g.setColor(Color.WHITE);
            g.fillRect(0, 190+xroda, 2, 5);
            g.fillRect(100, 120+xroda, 2, 5);
            g.fillRect(200, 120+xroda, 2, 5);
            g.fillRect(300, 120+xroda, 2, 5);
            g.fillRect(400, 120+xroda, 2, 5);
            g.fillRect(500, 120+xroda, 2, 5);
            g.fillRect(600, 120+xroda, 2, 5);
            g.fillRect(700, 120+xroda, 2, 5);
            g.fillRect(800, 120+xroda, 2, 5);
            g.fillRect(900, 120+xroda, 2, 5);
            g.fillRect(1000, 120+xroda, 2, 5);
            //
            g.fillRect(150, 70+xroda, 2, 5);
            g.fillRect(230, 70+xroda, 2, 5);
            g.fillRect(350, 70+xroda, 2, 5);
            g.fillRect(460, 70+xroda, 2, 5);
            g.fillRect(550, 70+xroda, 2, 5);
            g.fillRect(660, 70+xroda, 2, 5);
            g.fillRect(760, 70+xroda, 2, 5);
            g.fillRect(860, 70+xroda, 2, 5);
            g.fillRect(960, 70+xroda, 2, 5);
            g.fillRect(1600, 70+xroda, 2, 5);
            //
            g.fillRect(110, 40+xroda, 2, 5);
            g.fillRect(130, 40+xroda, 2, 5);
            g.fillRect(330, 40+xroda, 2, 5);
            g.fillRect(440, 40+xroda, 2, 5);
            g.fillRect(550, 40+xroda, 2, 5);
            g.fillRect(60, 40+xroda, 2, 5);
            g.fillRect(720, 40+xroda, 2, 5);
            g.fillRect(820, 40+xroda, 2, 5);
            g.fillRect(920, 40+xroda, 2, 5);
            g.fillRect(1300, 40+xroda, 2, 5);
            //
            g.fillRect(90, 20+xroda, 2, 5);
            g.fillRect(190, 20+xroda, 2, 5);
            g.fillRect(320, 20+xroda, 2, 5);
            g.fillRect(420, 20+xroda, 2, 5);
            g.fillRect(520, 20+xroda, 2, 5);
            g.fillRect(620, 20+xroda, 2, 5);
            g.fillRect(720, 20+xroda, 2, 5);
            g.fillRect(820, 20+xroda, 2, 5);
            g.fillRect(960, 20+xroda, 2, 5);
            g.fillRect(1200, 20+xroda, 2, 5);
            //
            g.fillRect(150, 5+xroda, 2, 5);
            g.fillRect(250, 5+xroda, 2, 5);
            g.fillRect(310, 5+xroda, 2, 5);
            g.fillRect(420, 5+xroda, 2, 5);
            g.fillRect(520, 5+xroda, 2, 5);
            g.fillRect(630, 5+xroda, 2, 5);
            g.fillRect(740, 5+xroda, 2, 5);
            g.fillRect(850, 5+xroda, 2, 5);
            g.fillRect(960, 5+xroda, 2, 5);
            g.fillRect(1700, 5+xroda, 2, 5);
            //
            g.fillRect(50, 200+xroda, 2, 5);
            g.fillRect(250, 200+xroda, 2, 5);
            g.fillRect(310,200+xroda, 2, 5);
            g.fillRect(420, 200+xroda, 2, 5);
            g.fillRect(520, 200+xroda, 2, 5);
            g.fillRect(630, 200+xroda, 2, 5);
            g.fillRect(740, 200+xroda, 2, 5);
            g.fillRect(850, 200+xroda, 2, 5);
            g.fillRect(960, 5+xroda, 2, 5);
            g.fillRect(1700, 5+xroda, 2, 5);
            g.fillRect(50, 300+xroda, 2, 5);
            g.fillRect(250, 300+xroda, 2, 5);
            g.fillRect(310, 300+xroda, 2, 5);
            g.fillRect(420, 300+xroda, 2, 5);
            g.fillRect(520, 300+xroda, 2, 5);
            g.fillRect(630, 300+xroda, 2, 5);
            g.fillRect(740, 300+xroda, 2, 5);
            g.fillRect(850, 300+xroda, 2, 5);
            g.fillRect(960, 300+xroda, 2, 5);
            g.fillRect(1700, 300+xroda, 2, 5);
            g.fillRect(170, 350+xroda, 2, 5);
            g.fillRect(250, 350+xroda, 2, 5);
            g.fillRect(310, 350+xroda, 2, 5);
            g.fillRect(420, 350+xroda, 2, 5);
            g.fillRect(520, 350+xroda, 2, 5);
            g.fillRect(630, 350+xroda, 2, 5);
            g.fillRect(740, 350+xroda, 2, 5);
            g.fillRect(850, 350+xroda, 2, 5);
            g.fillRect(960, 350+xroda, 2, 5);
            g.fillRect(1700, 350+xroda, 2, 5);
            g.fillRect(1800, 350+xroda, 2, 5);
            //
            g.fillRect(190, 400+xroda, 2, 5);
            g.fillRect(290, 400+xroda, 2, 5);
            g.fillRect(390, 400+xroda, 2, 5);
            g.fillRect(490, 400+xroda, 2, 5);
            g.fillRect(590, 400+xroda, 2, 5);
            g.fillRect(690, 400+xroda, 2, 5);
            g.fillRect(790, 400+xroda, 2, 5);
            g.fillRect(890, 400+xroda, 2, 5);
            g.fillRect(990, 400+xroda, 2, 5);
            g.fillRect(1900, 400+xroda, 2, 5);
            g.fillRect(2000, 400+xroda, 2, 5);
            g.fillRect(170, 450+xroda, 2, 5);
            g.fillRect(250, 450+xroda, 2, 5);
            g.fillRect(310, 450+xroda, 2, 5);
            g.fillRect(420, 450+xroda, 2, 5);
            g.fillRect(520, 450+xroda, 2, 5);
            g.fillRect(630, 450+xroda, 2, 5);
            g.fillRect(740, 450+xroda, 2, 5);
            g.fillRect(850, 450+xroda, 2, 5);
            g.fillRect(960, 450+xroda, 2, 5);
            g.fillRect(1700, 450+xroda, 2, 5);
            g.fillRect(1800, 450+xroda, 2, 5);
            //
            g.fillRect(200, 500+xroda, 2, 5);
            g.fillRect(300, 500+xroda, 2, 5);
            g.fillRect(340, 500+xroda, 2, 5);
            g.fillRect(450, 500+xroda, 2, 5);
            g.fillRect(550, 500+xroda, 2, 5);
            g.fillRect(660, 500+xroda, 2, 5);
            g.fillRect(770, 500+xroda, 2, 5);
            g.fillRect(880, 500+xroda, 2, 5);
            g.fillRect(990, 500+xroda, 2, 5);
            g.fillRect(1730, 500+xroda, 2, 5);
            g.fillRect(1830, 500+xroda, 2, 5);
            //
            g.fillRect(170, 550+xroda, 2, 5);
            g.fillRect(250, 550+xroda, 2, 5);
            g.fillRect(310, 550+xroda, 2, 5);
            g.fillRect(420, 550+xroda, 2, 5);
            g.fillRect(520, 550+xroda, 2, 5);
            g.fillRect(630, 550+xroda, 2, 5);
            g.fillRect(740, 550+xroda, 2, 5);
            g.fillRect(850, 550+xroda, 2, 5);
            g.fillRect(960, 550+xroda, 2, 5);
            g.fillRect(1700, 550+xroda, 2, 5);
            g.fillRect(1800, 550+xroda, 2, 5);
            //
            g.fillRect(170, 550+xroda, 2, 5);
            g.fillRect(250, 550+xroda, 2, 5);
            g.fillRect(310, 550+xroda, 2, 5);
            g.fillRect(420, 550+xroda, 2, 5);
            g.fillRect(520, 550+xroda, 2, 5);
            g.fillRect(630, 550+xroda, 2, 5);
            g.fillRect(740, 550+xroda, 2, 5);
            g.fillRect(850, 550+xroda, 2, 5);
            g.fillRect(960, 550+xroda, 2, 5);
            g.fillRect(1700, 550+xroda, 2, 5);
            g.fillRect(1800, 550+xroda, 2, 5);
            //"pohon">
            g.setColor(new Color(50, 148, 19));
            g.fillOval(70,280, 30,40);
            g.fillOval(60 ,300, 30,30);
            g.fillOval(80, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(80,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(660,280, 30,40);
            g.fillOval(650, 300, 30,30);
            g.fillOval(670, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(670,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(790,300, 30,40);
            g.fillOval(780, 320, 30,30);
            g.fillOval(800, 320, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(800,340,9 ,60 );
      
            g.setColor(new Color(50, 148, 19));
            g.fillOval(100,280, 30,40);
            g.fillOval(90, 300, 30,30);
            g.fillOval(110, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(110,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(160,280, 30,40);
            g.fillOval(150, 300, 30,30);
            g.fillOval(170, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(170,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(600,280, 30,40);
            g.fillOval(590, 300, 30,30);
            g.fillOval(610, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(610,320,9 ,60 );


            g.setColor(new Color(50, 148, 19));
            g.fillOval(500,280, 30,40);
            g.fillOval(490, 300, 30,30);
            g.fillOval(510, 300,30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(510,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(460,280, 30,40);
            g.fillOval(450, 300, 30,30);
            g.fillOval(470, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(470,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(360,280, 30,40);
            g.fillOval(350, 300, 30,30);
            g.fillOval(370, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(370,320,9 ,60 );

            g.setColor(new Color(50, 148, 19));
            g.fillOval(407,280, 30,40);
            g.fillOval(390, 300, 30,30);
            g.fillOval(420, 300, 30,30);
            g.setColor(new Color (162, 81, 31));
            g.fillRect(417,320,9 ,60 );
   
    
            //mobil
            int xmobil[] = {5+xroda,-15+xroda,20+xroda,50+xroda,130+xroda,140+xroda,200+xroda,210+xroda};
            int ymobil[] = {465,430,430,400,400,430,430,465};
            g.setColor(Color.BLUE);
            g.fillPolygon(xmobil, ymobil, xmobil.length);
            //roda
            g.setColor(Color.DARK_GRAY);
            g.fillOval(145+xroda, 445, 30, 30);
            g.fillOval(15+xroda, 445, 30, 30);
           
            g.setColor(Color.WHITE);          
            g.fillOval(149+xroda, 449, 22, 22);
            g.fillOval(19+xroda, 449, 22, 22);
           

            //jendela
            g.setColor(Color.WHITE);
            g.fillRect(55+xroda, 405, 70, 25);
           
            int xj2[] = {90+xroda,125+xroda,133+xroda};
            int yj2[] = {430,405,430};
            g.fillPolygon(xj2, yj2, xj2.length);
            int xj[] = {25+xroda,55+xroda,133+xroda};
            int yj[] = {430,405,430};
            g.fillPolygon(xj, yj, xj.length);
           
            g.setColor(Color.black);
            g.fillRect(75+xroda, 405, 3, 25);
           
            //pintu            
            g.setColor(Color.RED);
            g.drawRect(75+xroda, 428, 60, 30);
            g.fillRect(75+xroda, 435, 60, 25);
         
            //mobil2
            int xmobil2[] = {5-xroda,0-xroda,70-xroda,70-xroda,130-xroda,140-xroda,180-xroda,190-xroda};
            int ymobil2[] = {565,530,530,500,500,530,530,565};
            g.setColor(Color.RED);
            g.fillPolygon(xmobil2, ymobil2, xmobil2.length);
            //roda
            g.setColor(Color.DARK_GRAY);
            g.fillOval(145-xroda, 545, 30, 30);
            g.fillOval(15-xroda, 545, 30, 30);
           
            g.setColor(Color.WHITE);          
            g.fillOval(149-xroda, 549, 22, 22);
            g.fillOval(19-xroda, 549, 22, 22);
            

            //jendela
            g.setColor(Color.WHITE);
            g.fillRect(75-xroda, 505, 50, 25);
           
            int xjj2[] = {90-xroda,125-xroda,133-xroda};
            int yjj2[] = {530,505,530};
            g.fillPolygon(xjj2, yjj2, xjj2.length);
           
           
            g.setColor(Color.black);
            g.fillRect(75-xroda, 505, 3, 25);
           
            //pintu           
            g.setColor(Color.blue);
            g.drawRect(75-xroda, 528, 60, 30);
            g.fillRect(75-xroda, 535, 60, 25);
           
             //gunung
            g.setColor(Color.GRAY);
            int m[] = {-200,220,550};
            int n[] = {250,100,250};
            g.fillPolygon(m, n, 3);
            int a[] = {-500,30,350};
            int b[] = {250,100,250};
            g.fillPolygon(a, b, 3);
           
            //gedung1
            g.setColor(Color.BLACK);
            g.fillRect(980, 300, 100, 60);
            g.fillRect(980, 330, 100, 60);
            //kaca
            g.setColor(Color.yellow);
            g.fillRect(985, 305,30, 20);
            g.fillRect(985, 305, 30, 20);
            //kaca1
            g.setColor(Color.yellow);
            g.fillRect(1030, 305,30, 20);
            g.fillRect(1030, 305, 30, 20);
            //kaca1
            g.setColor(Color.yellow);
            g.fillRect(1030, 330,30, 20);
            g.fillRect(1030, 330, 30, 20);
            //kaca1
            g.setColor(Color.yellow);
            g.fillRect(985, 330,30, 20);
            g.fillRect(985, 330, 30, 20);
            //kaca1
            g.setColor(Color.yellow);
            g.fillRect(985, 355,30, 20);
            g.fillRect(985, 355, 30, 20);
            //kaca1
            g.setColor(Color.yellow);
            g.fillRect(1030, 355,30, 20);
            g.fillRect(1030, 355, 30, 20);
           
            //gedung2
            g.setColor(Color.BLACK);
            g.fillRect(890, 325, 90, 60);
            g.fillRect(890, 330, 90, 60);
            //kaca2
            g.setColor(Color.yellow);
            g.fillRect(895, 355,30, 20);
            g.fillRect(895, 355, 30, 20);
            //kaca2
            g.setColor(Color.yellow);
            g.fillRect(895, 330,30, 20);
            g.fillRect(895, 330, 30, 20);
            //kaca2
            g.setColor(Color.yellow);
            g.fillRect(940, 330,30, 20);
            g.fillRect(940, 330, 30, 20);
            //kaca2
            g.setColor(Color.yellow);
            g.fillRect(940, 355,30, 20);
            g.fillRect(940, 355, 30, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(28, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(20, 220, 20, 20);
            g.fillOval(14, 230, 20, 20);
            g.fillOval(28, 230, 20, 20);
            g.fillOval(33, 240, 20, 20);
            g.fillOval(10, 240, 20, 20);
            g.fillOval(20, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(78, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(70, 220, 20, 20);
            g.fillOval(64, 230, 20, 20);
            g.fillOval(78, 230, 20, 20);
            g.fillOval(83, 240, 20, 20);
            g.fillOval(60, 240, 20, 20);
            g.fillOval(70, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(128, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(120, 220, 20, 20);
            g.fillOval(114, 230, 20, 20);
            g.fillOval(128, 230, 20, 20);
            g.fillOval(133, 240, 20, 20);
            g.fillOval(110, 240, 20, 20);
            g.fillOval(120, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(178, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(170, 220, 20, 20);
            g.fillOval(164, 230, 20, 20);
            g.fillOval(178, 230, 20, 20);
            g.fillOval(183, 240, 20, 20);
            g.fillOval(160, 240, 20, 20);
            g.fillOval(170, 240, 20, 20);
             //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(228, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(220, 220, 20, 20);
            g.fillOval(214, 230, 20, 20);
            g.fillOval(228, 230, 20, 20);
            g.fillOval(233, 240, 20, 20);
            g.fillOval(210, 240, 20, 20);
            g.fillOval(220, 240, 20, 20);
             //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(278, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(270, 220, 20, 20);
            g.fillOval(264, 230, 20, 20);
            g.fillOval(278, 230, 20, 20);
            g.fillOval(283, 240, 20, 20);
            g.fillOval(260, 240, 20, 20);
            g.fillOval(270, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(328, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(320, 220, 20, 20);
            g.fillOval(314, 230, 20, 20);
            g.fillOval(328, 230, 20, 20);
            g.fillOval(333, 240, 20, 20);
            g.fillOval(310, 240, 20, 20);
            g.fillOval(320, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(378, 250, 10, 30);
            g.setColor(Color.green);
            g.fillOval(370, 220, 20, 20);
            g.fillOval(364, 230, 20, 20);
            g.fillOval(378, 230, 20, 20);
            g.fillOval(383, 240, 20, 20);
            g.fillOval(360, 240, 20, 20);
            g.fillOval(370, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(428, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(420, 220, 20, 20);
            g.fillOval(414, 230, 20, 20);
            g.fillOval(428, 230, 20, 20);
            g.fillOval(433, 240, 20, 20);
            g.fillOval(410, 240, 20, 20);
            g.fillOval(420, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(478, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(470, 220, 20, 20);
            g.fillOval(464, 230, 20, 20);
            g.fillOval(478, 230, 20, 20);
            g.fillOval(483, 240, 20, 20);
            g.fillOval(460, 240, 20, 20);
            g.fillOval(470, 240, 20, 20);
             //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(528, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(520, 220, 20, 20);
            g.fillOval(514, 230, 20, 20);
            g.fillOval(528, 230, 20, 20);
            g.fillOval(533, 240, 20, 20);
            g.fillOval(510, 240, 20, 20);
            g.fillOval(520, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(578, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(570, 220, 20, 20);
            g.fillOval(564, 230, 20, 20);
            g.fillOval(578, 230, 20, 20);
            g.fillOval(583, 240, 20, 20);
            g.fillOval(560, 240, 20, 20);
            g.fillOval(570, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(628, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(620, 220, 20, 20);
            g.fillOval(614, 230, 20, 20);
            g.fillOval(628, 230, 20, 20);
            g.fillOval(633, 240, 20, 20);
            g.fillOval(610, 240, 20, 20);
            g.fillOval(620, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(678, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(670, 220, 20, 20);
            g.fillOval(664, 230, 20, 20);
            g.fillOval(678, 230, 20, 20);
            g.fillOval(683, 240, 20, 20);
            g.fillOval(660, 240, 20, 20);
            g.fillOval(670, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(728, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(720, 220, 20, 20);
            g.fillOval(714, 230, 20, 20);
            g.fillOval(728, 230, 20, 20);
            g.fillOval(733, 240, 20, 20);
            g.fillOval(710, 240, 20, 20);
            g.fillOval(720, 240, 20, 20);
             //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(778, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(770, 220, 20, 20);
            g.fillOval(764, 230, 20, 20);
            g.fillOval(778, 230, 20, 20);
            g.fillOval(783, 240, 20, 20);
            g.fillOval(760, 240, 20, 20);
            g.fillOval(770, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(828, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(820, 220, 20, 20);
            g.fillOval(814, 230, 20, 20);
            g.fillOval(828, 230, 20, 20);
            g.fillOval(833, 240, 20, 20);
            g.fillOval(810, 240, 20, 20);
            g.fillOval(820, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(878, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(870, 220, 20, 20);
            g.fillOval(864, 230, 20, 20);
            g.fillOval(878, 230, 20, 20);
            g.fillOval(883, 240, 20, 20);
            g.fillOval(860, 240, 20, 20);
            g.fillOval(870, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(928, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(920, 220, 20, 20);
            g.fillOval(914, 230, 20, 20);
            g.fillOval(928, 230, 20, 20);
            g.fillOval(933, 240, 20, 20);
            g.fillOval(910, 240, 20, 20);
            g.fillOval(920, 240, 20, 20);
             //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(978, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(970, 220, 20, 20);
            g.fillOval(964, 230, 20, 20);
            g.fillOval(978, 230, 20, 20);
            g.fillOval(983, 240, 20, 20);
            g.fillOval(960, 240, 20, 20);
            g.fillOval(970, 240, 20, 20);
            //pohon
            g.setColor(Color.DARK_GRAY);
            g.fillRect(1028, 250, 10, 30);
            g.setColor(Color.GREEN);
            g.fillOval(1020, 220, 20, 20);
            g.fillOval(1014, 230, 20, 20);
            g.fillOval(1028, 230, 20, 20);
            g.fillOval(1033, 240, 20, 20);
            g.fillOval(1010, 240, 20, 20);
            g.fillOval(1020, 240, 20, 20);
           
            //"semak">  
            int xmak[] = {600, 630, 500};
            int ymak[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak, ymak, 3);
  
            int xmak1[] = {650, 680, 620};
            int ymak1[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak1, ymak1, 3);
    
            int xmak2[] = {700, 730, 670};
            int ymak2[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak2, ymak2, 3);
    
            int xmak3[] = {750, 780, 720};
            int ymak3[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak3, ymak3, 3);
    
            int xmak4[] = {800, 830, 770};
            int ymak4[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak4, ymak4, 3);
    
            int xmak5[] = {850, 880, 820};
            int ymak5[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak5, ymak5, 3);
    
            int xmak6[] = {900, 930, 870};
            int ymak6[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak6, ymak6, 3);
    
            int xmak7[] = {950, 980, 920};
            int ymak7[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak7, ymak7, 3);
    
            int xmak8[] = {1000, 1030, 970};
            int ymak8[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak8, ymak8, 3);
    
            int xmak9[] = {1050, 1080, 1030};
            int ymak9[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak9, ymak9, 3);
    
            int xmak10[] = {1100, 1130, 1080};
            int ymak10[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak10, ymak10, 3);
    
            int xmak11[] = {1150, 1180, 1080};
            int ymak11[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak11, ymak11, 3);
    
            int xmak12[] = {1200, 1230, 1130};
            int ymak12[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak12, ymak12, 3);
    
            int xmak13[] = {1250, 1280, 1180};
            int ymak13[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak13, ymak13, 3);
    
            int xmak14[] = {1350, 1330, 1230};
            int ymak14[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak14, ymak14, 3);
    
            int xmak15[] = {1400, 1380, 1280};
            int ymak15[] = {600, 730, 730};
            g.setColor(new Color(44, 133, 55));
            g.fillPolygon(xmak15, ymak15, 3);
            g.setColor(new Color (73, 195, 12));
            g.fillOval(250, 650, 300, 100);
            g.fillOval(0, 600, 300, 200);
            g.fillOval(-90, 580, 200, 300);
    //
        }
      
        public static void main (String[] args) throws InterruptedException {     
            JFrame f = new JFrame("Animasi");
        f.setSize(1080, 700);
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JavaApplication9 b = new JavaApplication9();
        f.add(b);
        while (true) {           
            b.gerak();           
            Thread.sleep(1000/24);
            b.repaint();
           
    }  
}
}




  
Hasil Run