SHARE
TWEET

Untitled

a guest Oct 25th, 2015 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package 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.         gameView = new FitViewport(game.V_WIDTH, game.V_HEIGHT, cam);
  36.  
  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.  
  64.         cam.setToOrtho(false, Gdx.graphics.getWidth() / 2 , Gdx.graphics.getHeight() / 2);
  65.         cam.update();
  66.  
  67.         mapRenderer.setView(cam);
  68.     }
  69.  
  70.     @Override
  71.     public void show() {
  72.  
  73.     }
  74.  
  75.     @Override
  76.     public void render(float delta) {
  77.         Gdx.gl.glClearColor(0, 0 ,0 ,1);
  78.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  79.  
  80.         mapRenderer.render();
  81.         game.batch.setProjectionMatrix(cam.combined);
  82.  
  83.         System.out.println(mapRenderer.getViewBounds());
  84.  
  85.  
  86.  
  87.     }
  88.  
  89.     @Override
  90.     public void resize(int width, int height) {
  91.  
  92.  
  93.  
  94.     }
  95.  
  96.     @Override
  97.     public void pause() {
  98.  
  99.     }
  100.  
  101.     @Override
  102.     public void resume() {
  103.  
  104.     }
  105.  
  106.     @Override
  107.     public void hide() {
  108.  
  109.     }
  110.  
  111.     @Override
  112.     public void dispose() {
  113.         map.dispose();
  114.         mapRenderer.dispose();
  115.  
  116.  
  117.     }
  118. }
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