This commit is contained in:
Sem van der Hoeven
2020-05-25 19:52:46 +02:00
parent 8668bc2017
commit afeb7afa29
3 changed files with 34 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMapTile;
import netwerkprog.game.util.graphics.Renderable;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
@@ -22,6 +23,8 @@ public class MapRenderer implements Renderable {
public static TextureRegion WALL_TILE;
public static TextureRegion PATH_TILE;
private TextureRegion[][] sprites;
public MapRenderer(Map map, int tileWidth, SpriteBatch batch, OrthographicCamera camera) {
this.map = map;
@@ -35,10 +38,12 @@ public class MapRenderer implements Renderable {
private void makeTiles() {
Texture texture = new Texture(Gdx.files.internal(tilePath));
TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);
FLOOR_TILE = tiles[1][6];
WALL_TILE = tiles[0][4];
PATH_TILE = tiles[4][6];
this.sprites = new TextureRegion[map.getHeight()][map.getWidth()];
}
public int getTileWidth() {
@@ -69,8 +74,8 @@ public class MapRenderer implements Renderable {
batch.draw(FLOOR_TILE, x, y);
} else if (map.get(row, col) == '#') {
batch.draw(WALL_TILE, x, y);
} else if (map.get(row,col) == 'x') {
batch.draw(PATH_TILE,x,y);
} else if (map.get(row, col) == 'x') {
batch.draw(PATH_TILE, x, y);
}
x += 32;
}
@@ -92,4 +97,8 @@ public class MapRenderer implements Renderable {
cam.update();
batch.setProjectionMatrix(cam.combined);
}
public TextureRegion[][] getSprites() {
return sprites;
}
}

View File

@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.TimeUtils;
import netwerkprog.game.client.MainGame;
import netwerkprog.game.util.application.InputTransform;
import java.util.ArrayList;
import java.util.Arrays;
@@ -119,6 +120,8 @@ public class GameInputProcessor implements InputProcessor {
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
float pointerX = InputTransform.getCursorToModelX((int)game.getScreenWidth(), (int)game.getScreenWidth(),screenX);
float pointerY = InputTransform.getCursorToModelY((int)game.getScreenHeight(),(int)game.getScreenHeight(),screenY);
return false;
}

View File

@@ -0,0 +1,20 @@
package netwerkprog.game.client.map;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class Tile {
private TextureRegion textureRegion;
private int xPos;
private int yPos;
public Tile(TextureRegion textureRegion, int xPos, int yPos) {
this.textureRegion = textureRegion;
this.xPos = xPos;
this.yPos = yPos;
}
public boolean contains(int x, int y) {
return false;
}
}