Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.ImageIcon;
- import javax.swing.Timer;
- public class fireball implements ActionListener
- {
- private int rx;
- private int ry;
- protected int dir;
- private boolean stop;
- protected Rectangle fireRec;
- Timer flameMove;
- private Image FIRE;
- public fireball(int x, int y, int dir)
- {
- this.dir=dir;
- setx(x);
- sety(y);
- fireRec=new Rectangle(rx,ry,48,48);
- flameMove=new Timer(500,this);
- FIRE=new ImageIcon("sprites/fireball.png").getImage();
- flameMove.start();
- }
- @Override
- public void actionPerformed(ActionEvent evt){
- if(dir==0){
- fireRec.x=fireRec.x-48;
- }
- if(dir==1){
- fireRec.x=fireRec.x+48;
- }
- if(dir==2){
- fireRec.y=fireRec.y-48;
- }
- if(dir==3){
- fireRec.y=fireRec.y+48;
- }
- }
- public void setx(int n)
- {
- rx=n;
- }
- public void sety(int n)
- {
- ry=n;
- }
- public void update(){
- }
- public void draw(Graphics g){
- g.drawImage(FIRE, fireRec.x, fireRec.y, null);
- }
- public boolean playerCol(int x, int y){
- if(x==fireRec.x&&y==fireRec.y){
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment