import com.badlogic.gdx.graphics.g2d.SpriteCache;\r
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;\r
import com.badlogic.gdx.graphics.glutils.ShaderProgram;\r
+import com.badlogic.gdx.math.MathUtils;\r
import com.badlogic.gdx.math.Matrix4;\r
import com.badlogic.gdx.math.Vector2;\r
import com.badlogic.gdx.utils.Disposable;\r
normalCacheId = new int[map.length][][];\r
blendedCacheId = new int[map.length][][];\r
for (layer = 0; layer < map.length; layer++) {\r
- normalCacheId[layer] = new int[(int)Math.ceil((float)map[layer].length / tilesPerBlockY)][];\r
- blendedCacheId[layer] = new int[(int)Math.ceil((float)map[layer].length / tilesPerBlockY)][];\r
+ normalCacheId[layer] = new int[(int)MathUtils.ceil((float)map[layer].length / tilesPerBlockY)][];\r
+ blendedCacheId[layer] = new int[(int)MathUtils.ceil((float)map[layer].length / tilesPerBlockY)][];\r
for (row = 0; row < normalCacheId[layer].length; row++) {\r
- normalCacheId[layer][row] = new int[(int)Math.ceil(map[layer][row].length / tilesPerBlockX)];\r
- blendedCacheId[layer][row] = new int[(int)Math.ceil(map[layer][row].length / tilesPerBlockX)];\r
+ normalCacheId[layer][row] = new int[(int)MathUtils.ceil((float)map[layer][row].length / tilesPerBlockX)];\r
+ blendedCacheId[layer][row] = new int[(int)MathUtils.ceil((float)map[layer][row].length / tilesPerBlockX)];\r
for (col = 0; col < normalCacheId[layer][row].length; col++) {\r
normalCacheId[layer][row][col] = addBlock(map[layer], layer, row, col, false);\r
blendedCacheId[layer][row][col] = addBlock(map[layer], layer, row, col, true);\r
* number is too high.\r
*/\r
public void render (float x, float y, int width, int height, int[] layers) {\r
- initialRow = (int)((mapHeightPixels - y - overdrawY) / (tilesPerBlockY * tileHeight));\r
+ lastRow = (int)((mapHeightPixels - (y - height + overdrawY)) / (tilesPerBlockY * tileHeight));\r
+ initialRow = (int)((mapHeightPixels - (y - overdrawY))/(tilesPerBlockY * tileHeight));\r
initialRow = (initialRow > 0) ? initialRow : 0; // Clamp initial Row > 0\r
+ \r
initialCol = (int)((x - overdrawX) / (tilesPerBlockX * tileWidth));\r
initialCol = (initialCol > 0) ? initialCol : 0; // Clamp initial Col > 0\r
- lastRow = (int)((mapHeightPixels - y + height + overdrawY) / (tilesPerBlockY * tileHeight)); // clamping done in render loop\r
- lastCol = (int)((x + width + overdrawX) / (tilesPerBlockX * tileWidth)); // clamping done in render loop\r
-\r
+ lastCol = (int)((x + width + overdrawX) / (tilesPerBlockX * tileWidth));\r
+ \r
Gdx.gl.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);\r
\r
cache.begin();\r
private static final int SCREEN_WIDTH = 480;\r
private static final int SCREEN_HEIGHT = 320;\r
\r
- private static final int[] layersList = {2,3};\r
+ //private static final int[] layersList = {2,3};\r
\r
SpriteBatch spriteBatch;\r
BitmapFont font;\r
tmp.set(0, 0, 0);\r
cam.unproject(tmp);\r
\r
- tileMapRenderer.render(tmp.x, tmp.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), layersList);\r
+ tileMapRenderer.render(tmp.x, tmp.y, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());//, layersList);\r
\r
spriteBatch.begin();\r
font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 20, 20);\r