Advertisement
Guest User

Untitled

a guest
Mar 4th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. public class Laberinto extends ApplicationAdapter {
  2.     SpriteBatch batch;
  3.     Texture ficheroHoja;
  4.     TextureRegion hojaSprites;
  5.     TextureRegion trozos[][];
  6.     private OrthographicCamera camara;
  7.     @Override
  8.     public void create () {
  9.         batch = new SpriteBatch();
  10.         ficheroHoja=new Texture(Gdx.files.internal("hojasprites.png"));
  11.         hojaSprites=new TextureRegion();
  12.         hojaSprites.setRegion(ficheroHoja);
  13.         trozos=hojaSprites.split(32,32);
  14.         camara = new OrthographicCamera();
  15.         camara.setToOrtho(false, 800, 480);
  16.  
  17.     }
  18.  
  19.     @Override
  20.     public void render () {
  21.         Gdx.gl.glClearColor(1, 0, 0, 1);
  22.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  23.         camara.update();
  24.         batch.setProjectionMatrix(camara.combined);
  25.         batch.begin();
  26.         dibujarFondoCesped();
  27.         dibujarSetos();
  28.         dibujarBorde();
  29.         batch.end();
  30.     }
  31.  
  32.     private void dibujarBorde() {
  33.         for(int x=0;x<800;x+=32){
  34.                     batch.draw(trozos[3][6],x,0);
  35.                     batch.draw(trozos[3][6],x,480-32);
  36.         }
  37.         for(int y=0;y<800;y+=32){
  38.             batch.draw(trozos[3][6],0,y);
  39.             batch.draw(trozos[3][6],800-32,y);
  40. }
  41.        
  42.     }
  43.  
  44.     private void dibujarSetos() {
  45.         for(int x=96;x<800-32;x=x+96){
  46.             for(int y=96;y<480-32;y=y+96){
  47.                 batch.draw(trozos[1][6],x,y);
  48.             }
  49.         }
  50.     }
  51.  
  52.     private void dibujarFondoCesped() {
  53.  
  54.         for(int i=32;i<800-32;i=i+32){
  55.             for(int j=32;j<480-32;j=j+32){
  56.                 batch.draw(trozos[2][6],i,j);
  57.             }
  58.         }
  59.     }
  60.    
  61.    
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement