Guest User

Untitled

a guest
May 15th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. package net.devox.amori.controls;
  2.  
  3. import java.awt.Graphics2D;
  4. import java.awt.image.BufferedImage;
  5.  
  6. public class Animation
  7. {
  8.     private BufferedImage buff;
  9.     private int x, y, frames;
  10.     private BufferedImage[] images;
  11.     private int curFrame;
  12.     private int counter=0;
  13.    
  14.     public Animation(int frames, BufferedImage[] bi, int interval, int x, int y){
  15.         this.x = x;
  16.         this.y = y;
  17.         this.frames = frames;
  18.         this.images = bi;
  19.     }
  20.    
  21.     public void Update(){
  22.         frames++;
  23.     }
  24.    
  25.     public void Draw(Graphics2D g2d){
  26.         g2d.drawImage(images[curFrame], x, y, null);
  27.     }
  28.    
  29.     public void LoopAnim(int speed){
  30.         if(counter == speed){
  31.             curFrame++;
  32.             if(curFrame>frames){
  33.                 curFrame=0;
  34.             }
  35.         }
  36.         counter++;
  37.         if(counter==speed){
  38.             counter=0;
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment