Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
15,892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. import android.graphics.Bitmap;
  2. import android.graphics.Canvas;
  3.  
  4. public class Background {
  5.  
  6.     private Bitmap image;
  7.     private int x, y, dx;
  8.  
  9.     public Background(Bitmap res)
  10.     {
  11.         image = res;
  12.     }
  13.     public void update()
  14.     {
  15.         x+=dx;
  16.         if(x<-GamePanel.WIDTH){
  17.             x=0;
  18.         }
  19.     }
  20.     public void draw(Canvas canvas)
  21.     {
  22.         canvas.drawBitmap(image, x, y,null);
  23.         if(x<0)
  24.         {
  25.             canvas.drawBitmap(image, x+GamePanel.WIDTH, y, null);
  26.         }
  27.     }
  28.     public void setVector(int dx)
  29.     {
  30.         this.dx = dx;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement