Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Brick.java

By: bassex96 on Apr 18th, 2013  |  syntax: Java  |  size: 1.31 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package com.psillicoder.brickbreaker;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.graphics.Texture;
  5. import com.badlogic.gdx.math.Rectangle;
  6. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  7. import com.badlogic.gdx.math.Vector2;
  8. public class Brick {
  9.        
  10.         private Texture brickImage;
  11.        
  12.         public Rectangle brickRect;
  13.        
  14.         public boolean isVisible;
  15.         boolean isDestroyed;
  16.         //private Vector2 brickLoc;
  17.        
  18.         private int brickType;
  19.        
  20.         public Brick(int type, int brickx, int bricky, boolean visible) {
  21.                 brickType = type;
  22.                 if (brickType == 1) {
  23.                 brickImage = new Texture(Gdx.files.internal("data/bluebrick.PNG"));
  24.                
  25.                 }
  26.                 if (brickType == 2) {
  27.                 brickImage = new Texture(Gdx.files.internal("data/yellowbrick.PNG"));
  28.                 }
  29.                 if (brickType == 3) {
  30.                         brickImage = new Texture(Gdx.files.internal("data/redbrick.PNG"));
  31.                 }
  32.                 brickRect = new Rectangle();
  33.                 //brickType = type;
  34.                 brickRect.x = brickx;
  35.                 brickRect.y = bricky;
  36.                 brickRect.width = 32;
  37.                 brickRect.height = 16;
  38.                
  39.                 if (visible == true) {
  40.                         this.isVisible = true;
  41.                 }else{this.isVisible = false;}
  42.                
  43.         }
  44.        
  45.         public boolean GetVisible() {
  46.                 return this.isVisible;
  47.         }
  48.  
  49.         public Rectangle getRect() {
  50.                 return brickRect;
  51.         }
  52.        
  53. public void draw(SpriteBatch spritebatch)
  54. {
  55.         spritebatch.draw(brickImage,brickRect.x,brickRect.y);
  56. }
  57.  
  58. }