diff --git a/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java b/core/src/ru/deadsoftware/cavecraft/game/GameRenderer.java
index b8b53249be9296363957889c991ae7bf377f5a80..944093826043bbd51204107b89fabddd04e193c9 100644 (file)
package ru.deadsoftware.cavecraft.game;
import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import ru.deadsoftware.cavecraft.Assets;
import ru.deadsoftware.cavecraft.CaveGame;
-import ru.deadsoftware.cavecraft.Items;
import ru.deadsoftware.cavecraft.GameScreen;
+import ru.deadsoftware.cavecraft.Items;
import ru.deadsoftware.cavecraft.game.mobs.Mob;
import ru.deadsoftware.cavecraft.game.objects.Player;
Assets.minecraftFont.draw(fontBatch, str, x, y);
}
- private void drawWorld() {
- int minX = (int) (camera.position.x/16);
- int minY = (int) (camera.position.y/16);
+ private void drawWorldBackground() {
+ int minX = (int) (camera.position.x/16)-1;
+ int minY = (int) (camera.position.y/16)-1;
int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1;
int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1;
- if (minX<0) minX=0;
if (minY<0) minY=0;
- if (maxX>gameProc.world.getWidth()) maxX = gameProc.world.getWidth();
if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
for (int y=minY; y<maxY; y++) {
for (int x=minX; x<maxX; x++) {
- if (gameProc.world.getForeMap(x,y)>0){/* &&
- !Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).foreground) {
- spriteBatch.draw(
- Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture(),
- x * 16 - camera.position.x,y * 16 - camera.position.y);*/
+ if (gameProc.world.getForeMap(x,y)>0){
} else if (gameProc.world.getBackMap(x,y)>0) {
spriteBatch.draw(
Items.BLOCKS.getValueAt(gameProc.world.getBackMap(x,y)).getTexture(),
}
private void drawWorldForeground(){
- int minX = (int) (camera.position.x/16);
- int minY = (int) (camera.position.y/16);
+ int minX = (int) (camera.position.x/16)-1;
+ int minY = (int) (camera.position.y/16)-1;
int maxX = (int) ((camera.position.x+camera.viewportWidth)/16)+1;
int maxY = (int) ((camera.position.y+camera.viewportHeight)/16)+1;
- if (minX<0) minX=0;
if (minY<0) minY=0;
- if (maxX>gameProc.world.getWidth()) maxX = gameProc.world.getWidth();
if (maxY>gameProc.world.getHeight()) maxY = gameProc.world.getHeight();
for (int y=minY; y<maxY; y++) {
for (int x=minX; x<maxX; x++) {
- if (gameProc.world.getForeMap(x,y)>0) { /*&&
- Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).foreground) {*/
+ if (gameProc.world.getForeMap(x,y)>0) {
spriteBatch.draw(
Items.BLOCKS.getValueAt(gameProc.world.getForeMap(x,y)).getTexture(),
x * 16 - camera.position.x,y * 16 - camera.position.y);
}
private void drawGamePlay() {
- drawWorld();
+ drawWorldBackground();
Mob.animateMobs();
for (Mob mob : gameProc.mobs) drawMob(mob);
drawPlayer(gameProc.player);