Advertisement
wreed12345

Untitled

Jun 6th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.pv.game;
  2.  
  3. import com.badlogic.gdx.Game;
  4. import com.badlogic.gdx.Gdx;
  5. import com.badlogic.gdx.Screen;
  6. import com.badlogic.gdx.graphics.FPSLogger;
  7. import com.badlogic.gdx.graphics.GL20;
  8. import com.badlogic.gdx.graphics.OrthographicCamera;
  9. import com.badlogic.gdx.graphics.g2d.BitmapFont;
  10. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  11. import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
  12. import com.badlogic.gdx.maps.tiled.TiledMap;
  13. import com.badlogic.gdx.maps.tiled.TmxMapLoader;
  14. import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
  15.  
  16. public class GameScreen implements Screen {
  17.    
  18.     Game game;
  19.     OrthographicCamera camera;
  20.     SpriteBatch batch;
  21.     ShapeRenderer shapeRenderer;
  22.     BitmapFont currentFont;
  23.     FPSLogger fps;
  24.     TiledMap map;
  25.     OrthogonalTiledMapRenderer renderer;
  26.    
  27.     public GameScreen(Game game) {
  28.         this.game = game;
  29.  
  30.         camera = new OrthographicCamera(Gdx.graphics.getWidth(),
  31.                 Gdx.graphics.getHeight());
  32.         camera.setToOrtho(false, Gdx.graphics.getWidth(),
  33.                 Gdx.graphics.getHeight());
  34.         batch = new SpriteBatch();
  35.         shapeRenderer = new ShapeRenderer();
  36.        
  37.         map = new TmxMapLoader().load("world/1.tmx");
  38.         renderer = new OrthogonalTiledMapRenderer(map, 1 / 16f);
  39.  
  40.         //Objects
  41.         fps = new FPSLogger();
  42.     }
  43.    
  44.     public void update(float delta) {
  45.        
  46.     }
  47.    
  48.     public void draw(float delta) {
  49.         Gdx.gl.glClearColor(255f, 255f, 255f, 1);
  50.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  51.         batch.begin();
  52.        
  53.         currentFont.draw(batch, "FPS : +" + Gdx.graphics.getFramesPerSecond(),
  54.                 800, 50);
  55.        
  56.        
  57.         batch.end();
  58.     }
  59.  
  60.     public void render(float delta) {
  61.         update(delta);
  62.         draw(delta);
  63.         renderer.setView(camera);
  64.         renderer.render();
  65.     }
  66.    
  67.     //BREAK
  68.  
  69.     public void resize(int width, int height) {
  70.        
  71.     }
  72.  
  73.     public void show() {
  74.        
  75.     }
  76.  
  77.     public void hide() {
  78.        
  79.     }
  80.  
  81.     public void pause() {
  82.        
  83.     }
  84.  
  85.     public void resume() {
  86.        
  87.     }
  88.  
  89.     public void dispose() {
  90.        
  91.     }
  92.  
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement