Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package newyear;
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class Podar {
- public Image img;
- public int x,y;
- public Boolean act;
- Timer timerUpdate;
- public Podar(Image img)
- {
- timerUpdate = new Timer(500, new ActionLitener()) {
- public void actionPerformed(ActionEvent e) {
- down();
- }
- };
- this.img = img;
- act=false;
- }
- public void start()
- {
- timerUpdate.start();
- y = 0;
- x=(int)(Math.random()*700);
- act=true;
- }
- public void down()
- {
- if(act==true)
- {
- y+=6;
- }
- if((y+img.getHeight(null))>=470);
- {
- timerUpdate.stop();
- }
- }
- public void draw(Graphics gr)
- {
- if(act==true)
- {
- gr.drawImage(img,x,y,null);
- }
- }
- }
Add Comment
Please, Sign In to add comment