Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package com.softskill.game;
  2.  
  3. import android.graphics.Bitmap;
  4. import android.graphics.Canvas;
  5.  
  6. public class Background {
  7.     Bitmap Backbitmap;
  8.     int x,y;
  9.     int Screenwitdh;
  10.     int Count_Background;
  11.     GamePanel root_gamepanel;
  12.    
  13.    
  14. public Background(Bitmap bitmap, int Screen_w, GamePanel Game_panel ) {
  15.     this.Backbitmap = bitmap;
  16.     this.x=0;
  17.     this.y=0;
  18.     this.Screenwitdh = Screen_w;
  19.     Count_Background = Screenwitdh/Backbitmap.getWidth()+1;
  20.     root_gamepanel = Game_panel;
  21. }
  22. public void draw(Canvas canvas){
  23.     for(int i = 0; i<Count_Background+1; i++){
  24.         if(canvas != null)
  25.             canvas.drawBitmap(Backbitmap, Backbitmap.getWidth()*i++ ,y ,null);
  26.     }
  27.     if(Math.abs(x)>Backbitmap.getWidth()){
  28.         x = x + Backbitmap.getWidth();
  29.     }
  30. }
  31. public void update(float dt){
  32.     x =(int) ( x - root_gamepanel.ShipSpeed*dt);
  33.    
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement