SHARE
TWEET

Untitled

a guest Oct 24th, 2015 76 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.       //  world = new World(new Vector2(0, 0), true);
  37.  
  38.         map = new TmxMapLoader().load("TestMap2.tmx");
  39.         mapRenderer = new OrthogonalTiledMapRenderer(map);
  40.  
  41.  
  42.         cam.position.set(gameView.getWorldWidth() / 2, gameView.getWorldHeight() / 2, 0);
  43.  
  44.  
  45.  
  46.         debug = new Box2DDebugRenderer();
  47.  
  48.         //BodyDef bdef = new BodyDef();
  49.        // PolygonShape shape = new PolygonShape();
  50.         //Fixture fdef = new FixtureDef();
  51.     }
  52.  
  53.     public void handleInput(float dt){
  54.  
  55.         if (Gdx.input.isKeyPressed(Input.Keys.D)) cam.position.x += 150;
  56.  
  57.     }
  58.  
  59.     public void update(float dt){
  60.         handleInput(dt);
  61.         cam.update();
  62.         mapRenderer.setView(cam);
  63.     }
  64.  
  65.     @Override
  66.     public void show() {
  67.  
  68.     }
  69.  
  70.     @Override
  71.     public void render(float delta) {
  72.         Gdx.gl.glClearColor(0, 0 ,0 ,1);
  73.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  74.  
  75.         mapRenderer.render();
  76.         game.batch.setProjectionMatrix(cam.combined);
  77.  
  78.  
  79.  
  80.     }
  81.  
  82.     @Override
  83.     public void resize(int width, int height) {
  84.  
  85.         gameView.update(width, height);
  86.  
  87.     }
  88.  
  89.     @Override
  90.     public void pause() {
  91.  
  92.     }
  93.  
  94.     @Override
  95.     public void resume() {
  96.  
  97.     }
  98.  
  99.     @Override
  100.     public void hide() {
  101.  
  102.     }
  103.  
  104.     @Override
  105.     public void dispose() {
  106.         map.dispose();
  107.         mapRenderer.dispose();
  108.  
  109.  
  110.     }
  111. }
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