iMackshun

Snippet. of My Render Method

Jun 24th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.98 KB | None | 0 0
  1. @Override
  2.     public void render(float delta) {
  3.         // Clear the Screen!
  4.         Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  5.         Gdx.gl.glClearColor(0, 0, 0, 1);
  6.         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
  7.         System.out.println("DrawCalls: " + GLProfiler.drawCalls);
  8.         // Convert the touch coordinates
  9.         FixedTouch = viewport.unproject(new Vector2(Gdx.input.getX(), Gdx.input.getY()));
  10.         // Set the position of the camera, based on the players location. The
  11.         // Player will always be centered!
  12.         Camera3D.Position.x = player.Position.x + 0.5f;
  13.         Camera3D.Position.z = -player.Position.z + 32.25f;
  14.         // Set this instance of WhichOption
  15.         WhichOption = pauseMenuButtons.WhichOption;
  16.         // Debugging
  17.         // player.Debug();
  18.         Sign.Update(player.Position, player.Direction);
  19.         player.Talking = Talking;
  20.         // Run Methods
  21.         // CameraControls();
  22.         // ModelControls();
  23.         // TextControls();
  24.         HandleControls();
  25.         HandleMenus();
  26.         PauseMenuControls();
  27.         // Update the sprite for animation purposes.
  28.         pokemonSprite.Update(delta, false);
  29.         // Make the pokemon bounce.
  30.         if (WhichMenu == "PokemonMenu") {
  31.             Timer.Update(delta);
  32.             if (Timer.getTimeElapsed() < Timer.getTargetTime() / 2) {
  33.                 YAdd = 0;
  34.             }
  35.             if (Timer.getTimeElapsed() > Timer.getTargetTime() / 2) {
  36.                 YAdd = 2;
  37.             }
  38.             if (Timer.isCompleted()) {
  39.                 Timer.Reset();
  40.                 Timer.Start();
  41.             }
  42.         }
  43.         // Update All of the Objects
  44.         pauseMenuButtons.Update();
  45.         player.Update(delta, PalletTownCollisionMap);
  46.         Camera.update();
  47.         poketch.Update();
  48.         PalletTown.Update(delta);
  49.         tweenManager.update(delta);
  50.         Camera3D.Update();
  51.         // Draw 3d Stuff
  52.         modelBatch.begin(Camera3D.Camera);
  53.         PalletTown.Draw(modelBatch, environment);
  54.         modelBatch.end();
  55.         if(player.CalculateDistance){
  56.             for (int i = 0; i < Trees.size(); i++) {
  57.                 Trees.get(i).CalculateDistance(player);
  58.             }
  59.             for (int i = 0; i < Flowers.size(); i++) {
  60.                 Flowers.get(i).CalculateDistance(player);
  61.             }
  62.             for(int i = 0; i < Grass.size(); i++) {
  63.                 Grass.get(i).CalculateDistance(player);
  64.             }
  65.             player.CalculateDistance = false;
  66.         }
  67. //When placed here drawcalls is 332.
  68.         GLProfiler.reset();
  69.         // Draw All of the Decals!
  70.         for (int i = 0; i < Trees.size(); i++) {
  71.             if (Trees.get(i).DistanceFromPlayer < DrawDistance) {
  72.                 Trees.get(i).Draw(decalBatch);
  73.             }
  74.         }
  75.         for (int i = 0; i < Flowers.size(); i++) {
  76.             if (Flowers.get(i).DistanceFromPlayer < DrawDistance) {
  77.                 Flowers.get(i).Draw(decalBatch);
  78.             }
  79.         }
  80.         for(int i = 0; i < Grass.size(); i++) {
  81.             if (Grass.get(i).DistanceFromPlayer < DrawDistance) {
  82.                 Grass.get(i).Draw(decalBatch);
  83.             }
  84.         }
  85.         player.Draw(decalBatch, Camera3D);
  86.         if (OtherPlayers.size() > 0) {
  87.             for (int i = 0; i < OtherPlayers.size(); i++) {
  88.                 OtherPlayers.get(i).SecondaryUpdate(delta, player.Position, player.Direction);
  89.                 OtherPlayers.get(i).Draw(decalBatch, Camera3D);
  90.             }
  91.         }
  92.         decalBatch.flush();
  93. //When reset is placed here, the drawcalls is 8.
  94. }
Advertisement
Add Comment
Please, Sign In to add comment