Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.darichey.libgdxtest;
- import com.badlogic.gdx.*;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.OrthographicCamera;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.utils.viewport.FitViewport;
- import com.badlogic.gdx.utils.viewport.Viewport;
- public class LibGDXTest extends ApplicationAdapter
- {
- SpriteBatch batch;
- Texture wall;
- OrthographicCamera camera;
- int CAM_WIDTH = 50;
- int CAM_HEIGHT = 30;
- @Override
- public void create ()
- {
- batch = new SpriteBatch();
- wall = new Texture("wall.png");
- camera = new OrthographicCamera(CAM_WIDTH, CAM_HEIGHT);
- camera.position.set(CAM_WIDTH / 2, CAM_HEIGHT / 2, 0);
- }
- @Override
- public void render ()
- {
- Gdx.gl.glClearColor(0f, 10f, 200f, 0f);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- camera.update();
- batch.setProjectionMatrix(camera.combined);
- batch.begin();
- batch.draw(wall, 0, 0);
- batch.end();
- // Input stuff
- if(Gdx.input.isKeyPressed(Input.Keys.RIGHT))
- camera.translate(1f,0f);
- if(Gdx.input.isKeyPressed(Input.Keys.LEFT))
- camera.translate(-1f,0f);
- if(Gdx.input.isKeyPressed(Input.Keys.UP))
- camera.translate(0f,1f);
- if(Gdx.input.isKeyPressed(Input.Keys.DOWN))
- camera.translate(0f,-1f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement