click click click click #5

Merged
SemvdH merged 5 commits from add-clicking into master 2020-05-25 19:25:51 +00:00
3 changed files with 34 additions and 2 deletions
Showing only changes of commit afeb7afa29 - Show all commits

View File

@@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMapTile;
import netwerkprog.game.util.graphics.Renderable; import netwerkprog.game.util.graphics.Renderable;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
@@ -22,6 +23,8 @@ public class MapRenderer implements Renderable {
public static TextureRegion WALL_TILE; public static TextureRegion WALL_TILE;
public static TextureRegion PATH_TILE; public static TextureRegion PATH_TILE;
private TextureRegion[][] sprites;
public MapRenderer(Map map, int tileWidth, SpriteBatch batch, OrthographicCamera camera) { public MapRenderer(Map map, int tileWidth, SpriteBatch batch, OrthographicCamera camera) {
this.map = map; this.map = map;
@@ -35,10 +38,12 @@ public class MapRenderer implements Renderable {
private void makeTiles() { private void makeTiles() {
Texture texture = new Texture(Gdx.files.internal(tilePath)); Texture texture = new Texture(Gdx.files.internal(tilePath));
TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32); TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);
FLOOR_TILE = tiles[1][6]; FLOOR_TILE = tiles[1][6];
WALL_TILE = tiles[0][4]; WALL_TILE = tiles[0][4];
PATH_TILE = tiles[4][6]; PATH_TILE = tiles[4][6];
this.sprites = new TextureRegion[map.getHeight()][map.getWidth()];
} }
public int getTileWidth() { public int getTileWidth() {
@@ -69,8 +74,8 @@ public class MapRenderer implements Renderable {
batch.draw(FLOOR_TILE, x, y); batch.draw(FLOOR_TILE, x, y);
} else if (map.get(row, col) == '#') { } else if (map.get(row, col) == '#') {
batch.draw(WALL_TILE, x, y); batch.draw(WALL_TILE, x, y);
} else if (map.get(row,col) == 'x') { } else if (map.get(row, col) == 'x') {
batch.draw(PATH_TILE,x,y); batch.draw(PATH_TILE, x, y);
} }
x += 32; x += 32;
} }
@@ -92,4 +97,8 @@ public class MapRenderer implements Renderable {
cam.update(); cam.update();
batch.setProjectionMatrix(cam.combined); 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.math.MathUtils;
import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.TimeUtils;
import netwerkprog.game.client.MainGame; import netwerkprog.game.client.MainGame;
import netwerkprog.game.util.application.InputTransform;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -119,6 +120,8 @@ public class GameInputProcessor implements InputProcessor {
@Override @Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) { 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; 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;
}
}