Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Laberinto extends ApplicationAdapter {
- SpriteBatch batch;
- Texture ficheroHoja;
- TextureRegion hojaSprites;
- TextureRegion trozos[][];
- private OrthographicCamera camara;
- @Override
- public void create () {
- batch = new SpriteBatch();
- ficheroHoja=new Texture(Gdx.files.internal("hojasprites.png"));
- hojaSprites=new TextureRegion();
- hojaSprites.setRegion(ficheroHoja);
- trozos=hojaSprites.split(32,32);
- camara = new OrthographicCamera();
- camara.setToOrtho(false, 800, 480);
- }
- @Override
- public void render () {
- Gdx.gl.glClearColor(1, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- camara.update();
- batch.setProjectionMatrix(camara.combined);
- batch.begin();
- dibujarFondoCesped();
- dibujarSetos();
- dibujarBorde();
- batch.end();
- }
- private void dibujarBorde() {
- for(int x=0;x<800;x+=32){
- batch.draw(trozos[3][6],x,0);
- batch.draw(trozos[3][6],x,480-32);
- }
- for(int y=0;y<800;y+=32){
- batch.draw(trozos[3][6],0,y);
- batch.draw(trozos[3][6],800-32,y);
- }
- }
- private void dibujarSetos() {
- for(int x=96;x<800-32;x=x+96){
- for(int y=96;y<480-32;y=y+96){
- batch.draw(trozos[1][6],x,y);
- }
- }
- }
- private void dibujarFondoCesped() {
- for(int i=32;i<800-32;i=i+32){
- for(int j=32;j<480-32;j=j+32){
- batch.draw(trozos[2][6],i,j);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement