Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.zz.maps;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.maps.MapProperties;
- import com.badlogic.gdx.maps.tiled.TiledMap;
- import com.badlogic.gdx.maps.tiled.TmxMapLoader;
- import com.zz.characters.Player;
- public class RpgMap {
- private TiledMap map;
- private MapProperties properties;
- private Player player;
- private int columns, rows, width, height, tilesize;
- public RpgMap() {
- this.map = new TmxMapLoader().load("maps/newmap.tmx");
- properties = map.getProperties();
- columns = properties.get("width", Integer.class);
- rows = properties.get("height", Integer.class);
- tilesize = properties.get("tilewidth", Integer.class);
- width = columns * tilesize;
- height = rows * tilesize;
- player = new Player(40,20, this);
- }
- public TiledMap getMap() {
- return map;
- }
- public void draw(SpriteBatch batch) {
- player.draw(batch);
- }
- public void update(float dt) {
- player.update(dt);
- }
- public boolean checkColision(float x, float y, int width, int height) {
- if(x <= 0 || x + width > getWidth() || y <= 0 || y+height > getHeight()) {
- System.out.println("X: " + x + " Y: " + y);
- return true;
- }
- return false;
- }
- public Player getPlayer() {
- return player;
- }
- public int getColumns() {
- return columns;
- }
- public int getRows() {
- return rows;
- }
- public int getWidth() {
- return width;
- }
- public int getHeight() {
- return height;
- }
- public int getTilesize() {
- return tilesize;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement