Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. package com.zz.maps;
  2.  
  3. import com.badlogic.gdx.graphics.g2d.SpriteBatch;
  4. import com.badlogic.gdx.maps.MapProperties;
  5. import com.badlogic.gdx.maps.tiled.TiledMap;
  6. import com.badlogic.gdx.maps.tiled.TmxMapLoader;
  7. import com.zz.characters.Player;
  8.  
  9. public class RpgMap {
  10.  
  11. private TiledMap map;
  12. private MapProperties properties;
  13. private Player player;
  14. private int columns, rows, width, height, tilesize;
  15.  
  16. public RpgMap() {
  17. this.map = new TmxMapLoader().load("maps/newmap.tmx");
  18. properties = map.getProperties();
  19. columns = properties.get("width", Integer.class);
  20. rows = properties.get("height", Integer.class);
  21. tilesize = properties.get("tilewidth", Integer.class);
  22. width = columns * tilesize;
  23. height = rows * tilesize;
  24. player = new Player(40,20, this);
  25. }
  26.  
  27. public TiledMap getMap() {
  28. return map;
  29. }
  30.  
  31. public void draw(SpriteBatch batch) {
  32. player.draw(batch);
  33. }
  34.  
  35. public void update(float dt) {
  36. player.update(dt);
  37. }
  38.  
  39. public boolean checkColision(float x, float y, int width, int height) {
  40. if(x <= 0 || x + width > getWidth() || y <= 0 || y+height > getHeight()) {
  41. System.out.println("X: " + x + " Y: " + y);
  42. return true;
  43. }
  44. return false;
  45. }
  46.  
  47.  
  48. public Player getPlayer() {
  49. return player;
  50. }
  51.  
  52. public int getColumns() {
  53. return columns;
  54. }
  55.  
  56. public int getRows() {
  57. return rows;
  58. }
  59.  
  60. public int getWidth() {
  61. return width;
  62. }
  63.  
  64. public int getHeight() {
  65. return height;
  66. }
  67.  
  68. public int getTilesize() {
  69. return tilesize;
  70. }
  71.  
  72.  
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement