SHARE
TWEET

Untitled

a guest Oct 25th, 2015 115 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. e com.mouse.game;
  2.  
  3. import com.badlogic.gdx.Gdx;
  4. import com.badlogic.gdx.Input;
  5. import com.badlogic.gdx.Screen;
  6. import com.badlogic.gdx.graphics.GL20;
  7. import com.badlogic.gdx.graphics.OrthographicCamera;
  8. import com.badlogic.gdx.maps.tiled.TiledMap;
  9. import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
  10. import com.badlogic.gdx.maps.tiled.TmxMapLoader;
  11. import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
  12. import com.badlogic.gdx.math.Vector2;
  13. import com.badlogic.gdx.physics.box2d.*;
  14. import com.badlogic.gdx.utils.viewport.FitViewport;
  15. import com.badlogic.gdx.utils.viewport.ScreenViewport;
  16. import com.badlogic.gdx.utils.viewport.StretchViewport;
  17. import com.badlogic.gdx.utils.viewport.Viewport;
  18.  
  19.  
  20. public class PlayScreen implements Screen {
  21.  
  22.     private MouseGame game;
  23.     private OrthographicCamera cam;
  24.     private Viewport gameView;
  25.     private TiledMap map;
  26.     private OrthogonalTiledMapRenderer mapRenderer;
  27.  
  28.     public World world;
  29.  
  30.     public Box2DDebugRenderer debug;
  31.  
  32.     public PlayScreen(MouseGame game){
  33.         this.game = game;
  34.         cam = new OrthographicCamera();
  35.  
  36.         cam.setToOrtho(false);
  37.  
  38.       //  world = new World(new Vector2(0, 0), true);
  39.  
  40.         map = new TmxMapLoader().load("TestMap2.tmx");
  41.         mapRenderer = new OrthogonalTiledMapRenderer(map, 16f);
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.         debug = new Box2DDebugRenderer();
  49.  
  50.         //BodyDef bdef = new BodyDef();
  51.        // PolygonShape shape = new PolygonShape();
  52.         //Fixture fdef = new FixtureDef();
  53.     }
  54.  
  55.     public void handleInput(float dt){
  56.  
  57.         if (Gdx.input.isKeyPressed(Input.Keys.D)) cam.position.x += 150;
  58.  
  59.     }
  60.  
  61.     public void update(float dt){
  62.         handleInput(dt);
  63.         cam.update();
  64.         mapRenderer.setView(cam);
  65.     }
  66.  
  67.     @Override
  68.     public void show() {
  69.  
  70.     }
  71.  
  72.     @Override
  73.     public void render(float delta) {
  74.         Gdx.gl.glClearColor(0, 0 ,0 ,1);
  75.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  76.  
  77.         mapRenderer.render();
  78.         game.batch.setProjectionMatrix(cam.combined);
  79.  
  80.         System.out.println(mapRenderer.getViewBounds());
  81.  
  82.  
  83.  
  84.     }
  85.  
  86.     @Override
  87.     public void resize(int width, int height) {
  88.  
  89.  
  90.  
  91.     }
  92.  
  93.     @Override
  94.     public void pause() {
  95.  
  96.     }
  97.  
  98.     @Override
  99.     public void resume() {
  100.  
  101.     }
  102.  
  103.     @Override
  104.     public void hide() {
  105.  
  106.     }
  107.  
  108.     @Override
  109.     public void dispose() {
  110.         map.dispose();
  111.         mapRenderer.dispose();
  112.  
  113.  
  114.     }
  115. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top