{"action":"created","issue":{"url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/3","repository_url":"https://api.github.com/repos/CalvinMT/LITIengine_test","labels_url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/3/comments","events_url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/3/events","html_url":"https://github.com/CalvinMT/LITIengine_test/issues/3","id":387377711,"node_id":"MDU6SXNzdWUzODczNzc3MTE=","number":3,"title":"So now that I have a sprite working, how do I get collision between the map and the player? Or collision with another object?  ","user":{"login":"Dmartin42","id":45320702,"node_id":"MDQ6VXNlcjQ1MzIwNzAy","avatar_url":"https://avatars2.githubusercontent.com/u/45320702?v=4","gravatar_id":"","url":"https://api.github.com/users/Dmartin42","html_url":"https://github.com/Dmartin42","followers_url":"https://api.github.com/users/Dmartin42/followers","following_url":"https://api.github.com/users/Dmartin42/following{/other_user}","gists_url":"https://api.github.com/users/Dmartin42/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmartin42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmartin42/subscriptions","organizations_url":"https://api.github.com/users/Dmartin42/orgs","repos_url":"https://api.github.com/users/Dmartin42/repos","events_url":"https://api.github.com/users/Dmartin42/events{/privacy}","received_events_url":"https://api.github.com/users/Dmartin42/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-12-04T16:42:26Z","updated_at":"2018-12-11T21:44:33Z","closed_at":null,"author_association":"NONE","body":"Also, I used your rotation system and was wondering if there was a way to put an x and a y on my player. \r\nAttached is my source code. \r\n`public class mainLoader {\r\n\t\r\n\tpublic static List <Player> listPlayers = new ArrayList <Player> ();\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\t// TODO Auto-generated method stub\r\n\t\t\r\n\t\tResources.setEncoding(Resources.ENCODING_UTF_8);\r\n\t\tGame.setInfo(\"gameInfo.xml\");\r\n\t\t\r\n\t\t\r\n\t\tGame.init();\r\n\t\tGame.getRenderEngine().setBaseRenderScale((float) 1.5);\r\n\t\tGame.getScreenManager().setResolution(Resolution.custom(1280, 720, \"1280*720\"));\r\n\t\tGame.getScreenManager().addScreen(new mainMenu());\r\n\t\tGame.getScreenManager().addScreen(mainGameScreen.getInstance());\r\n\t\tGame.getScreenManager().displayScreen(mainMenu.NAME);\r\n\t\tGame.start();\r\n\t\tSystem.out.println(\"Game version is: \" + Game.getInfo().getVersion());\r\n\t\tSystem.out.println(\"Currently active screen: \" + Game.getScreenManager().getCurrentScreen().getName());\r\n\t}\r\n\r\n}\r\n`\r\n`package Screens;\r\n\r\nimport java.awt.Image;\r\n\r\nimport javax.swing.ImageIcon;\r\n\r\nimport de.gurkenlabs.litiengine.Game;\r\nimport de.gurkenlabs.litiengine.gui.ImageComponent;\r\nimport de.gurkenlabs.litiengine.gui.screens.Screen;\r\n\r\npublic class mainMenu extends Screen{\r\n\tpublic static final String NAME = \"Menu\";\r\n\tpublic mainMenu() {\r\n\t\tsuper(\"Menu\");\r\n\t}\r\n\tpublic void prepare() {\r\n\t\tsuper.prepare();\r\n\t}\r\n\tprotected void initializeComponents () {\r\n\t\tImage imageCursorMain = new ImageIcon(\"resources/cursor_white_164.png\").getImage();\r\n\t\tGame.getScreenManager().getRenderComponent().setCursor(imageCursorMain, 0, 0);\r\n\t\tfinal double screenCenterX = Game.getScreenManager().getResolution().getWidth() / 2.0;\r\n\t\tfinal double screenCenterY = Game.getScreenManager().getResolution().getHeight() / 2.0;\r\n\t\tImageComponent start = new ImageComponent(screenCenterX-150, screenCenterY-50, 300, 100, null, \"Start Game\", null);\r\n\t\tImageComponent exit = new ImageComponent(start.getX(), start.getY()+start.getHeight(), 300, 100, null, \"Exit Game\", null);\r\n\t\t\r\n\t\tstart.onClicked(e -> {\r\n\t\t\tImage imageCursor = new ImageIcon(\"resources/cursor_invisible_1.png\").getImage();\r\n\t\t\tGame.getScreenManager().getRenderComponent().setCursor(imageCursor, 0, 0);\r\n\t\t\tGame.getScreenManager().displayScreen(mainGameScreen.NAME);\r\n\t\t});\r\n\t\t\r\n\t\texit.onClicked(e -> System.exit(0));\r\n\t\t\r\n\t\tthis.getComponents().add(start);\r\n\t\tthis.getComponents().add(exit);\r\n\t}\r\n\r\n\t\r\n\r\n}\r\n`\r\n`package Screens;\r\n\r\nimport java.awt.Graphics2D;\r\nimport java.awt.geom.Point2D;\r\nimport java.util.ArrayList;\r\nimport java.util.Arrays;\r\nimport java.util.HashMap;\r\n\r\nimport Engine.MoreRotaion;\r\nimport Entities.Player;\r\nimport de.gurkenlabs.litiengine.Game;\r\nimport de.gurkenlabs.litiengine.environment.EntitySpawner;\r\nimport de.gurkenlabs.litiengine.environment.Environment;\r\nimport de.gurkenlabs.litiengine.environment.tilemap.IMap;\r\nimport de.gurkenlabs.litiengine.gui.ImageComponent;\r\nimport de.gurkenlabs.litiengine.gui.screens.Screen;\r\n\r\npublic class mainGameScreen extends Screen{\r\n\tpublic static final String NAME = \"Game\";\r\n\tprivate static mainGameScreen instance;\r\n\t//private EntitySpawner <Ennemy> ennemySpawner;\r\n\tprotected mainGameScreen() {\r\n\t\tsuper(\"Game\");\r\n\t}\r\n\tpublic static mainGameScreen getInstance() {\r\n\t\tif(instance==null)\r\n\t\t\tinstance = new mainGameScreen();\r\n\t\treturn instance;\r\n\t}\r\n\tpublic void prepare () {\r\n\t\tsuper.prepare();\r\n\t\t\r\n\t\t// Initialize Game\r\n\t\tfinal double startX = 10;\r\n\t\tfinal double startY = 100;\r\n\t\t\r\n\t\tGame.load(\"Resources\\\\maps\\\\tmap.litidata\");\r\n\t\tEnvironment myEnv = new Environment(\"TestMap.tmx\");\r\n\t\tGame.loadEnvironment(myEnv);\r\n\t\tGame.getCamera().setClampToMap(true);\r\n\t\tPlayer player = new Player(new Point2D.Double(startX, startY));\r\n\t\tGame.getEnvironment().add(player);\r\n\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t}\r\n\tpublic void render (final Graphics2D graphics2D) {\r\n\t\tif (Game.getEnvironment() != null) {\r\n\t\t\tGame.getEnvironment().render(graphics2D);\r\n\t\t}\r\n\t\r\n\t\r\n\t\t\r\n\t\tsuper.render(graphics2D);\r\n\t}\r\n}\r\n`\r\n`package Engine;\r\n\r\npublic enum MoreRotaion {\r\n\tNONE, ROTATE_45, ROTATE_90, ROTATE_135, ROTATE_180, ROTATE_225, ROTATE_270, ROTATE_315;\r\n\r\n\t  public double getRadians() {\r\n\t    int value;\r\n\t    switch (this) {\r\n\t    \tcase ROTATE_45:\r\n\t\t      value = 45;\r\n\t\t      break;\r\n\t\t    case ROTATE_90:\r\n\t\t      value = 90;\r\n\t\t      break;\r\n\t\t    case ROTATE_135:\r\n\t\t      value = 135;\r\n\t\t      break;\r\n\t\t    case ROTATE_180:\r\n\t\t      value = 180;\r\n\t\t      break;\r\n\t\t    case ROTATE_225:\r\n\t\t      value = 225;\r\n\t\t      break;\r\n\t\t    case ROTATE_270:\r\n\t\t      value = 270;\r\n\t\t      break;\r\n\t\t    case ROTATE_315:\r\n\t\t      value = 315;\r\n\t\t      break;\r\n\t\t    default:\r\n\t\t      value = 0;\r\n\t\t      break;\r\n\t    }\r\n\r\n\t    return Math.toRadians(value);\r\n\t  }\r\n\r\n}\r\n`\r\n`package Entities;\r\n\r\nimport java.awt.event.KeyEvent;\r\nimport java.awt.geom.Point2D;\r\n\r\nimport javax.swing.ImageIcon;\r\n\r\nimport Engine.MoreRotaion;\r\nimport Engine.mainLoader;\r\nimport Screens.mainMenu;\r\nimport de.gurkenlabs.litiengine.Direction;\r\nimport de.gurkenlabs.litiengine.Game;\r\nimport de.gurkenlabs.litiengine.entities.Creature;\r\nimport de.gurkenlabs.litiengine.entities.IMobileEntity;\r\nimport de.gurkenlabs.litiengine.environment.tilemap.MapLoader;\r\nimport de.gurkenlabs.litiengine.graphics.animation.EntityAnimationController;\r\nimport de.gurkenlabs.litiengine.graphics.animation.PropAnimationController;\r\nimport de.gurkenlabs.litiengine.input.Input;\r\nimport de.gurkenlabs.litiengine.input.KeyboardEntityController;\r\n\r\npublic class Player extends Creature{\r\n\tprivate MoreRotaion rotation;\r\n\t\r\n\t\r\n\t\r\n\tpublic Player (Point2D position) {\r\n\t\tthis.setName(\"player1\");\r\n\t\tthis.setTeam(1);\r\n\t\tthis.setLocation(position.getX() - (46/2), position.getY() - (46/2));\r\n\t\tthis.rotation = MoreRotaion.NONE;\r\n\t\tmainLoader.listPlayers.add(this);\r\n\t\tthis.initialize();\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\tpublic void initialize () {\r\n\t\tKeyboardEntityController <Player> keyboardController = new KeyboardEntityController<Player>(this, KeyEvent.VK_UP, KeyEvent.VK_DOWN, KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT);\r\n\t\tthis.addController(keyboardController);\r\n\t\tthis.setController(EntityAnimationController.class, new PlayerAnimationController(this));\t\t\r\n\t\tthis.initializeInputs();\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\tprivate void initializeInputs () {\r\n\t\tInput.keyboard().onKeyPressed(KeyEvent.VK_UP, (key) -> this.changeDirection(Direction.UP));\r\n\t\tInput.keyboard().onKeyPressed(KeyEvent.VK_DOWN, (key) -> this.changeDirection(Direction.DOWN));\r\n\t\tInput.keyboard().onKeyPressed(KeyEvent.VK_LEFT, (key) -> this.changeDirection(Direction.LEFT));\r\n\t\tInput.keyboard().onKeyPressed(KeyEvent.VK_RIGHT, (key) -> this.changeDirection(Direction.RIGHT));\r\n\t\t\r\n//\t\tInput.keyboard().onKeyTyped(KeyEvent.VK_SPACE, (key) -> {\r\n//\t\t\tthis.fire(this);\r\n//\t\t});\r\n\t\t\r\n\t\tInput.keyboard().onKeyTyped(KeyEvent.VK_ESCAPE, (key) -> {\r\n\t\t\tSystem.exit(0);\r\n\t\t\tGame.getScreenManager().displayScreen(mainMenu.NAME);\r\n\t\t\tGame.getScreenManager().getRenderComponent().setCursor(new ImageIcon(\"resources/cursor_white_64.png\").getImage(), 0, 0);\r\n\t\t\ttry {\r\n\t\t\t\t//TODO - Finalizes this instance of InGameScreen\r\n\t\t\t\t//Game.getScreenManager().getCurrentScreen()..finalize();\r\n\t\t\t} catch (Throwable e) {\r\n\t\t\t\te.printStackTrace();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\tprivate void changeDirection (Direction direction) {\r\n\t\tswitch (direction) {\r\n\t\t\tcase UP:\r\n\t\t\t\tif (Input.keyboard().isPressed(KeyEvent.VK_LEFT)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_left\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_270;\r\n\t\t\t\t}\r\n\t\t\t\telse if (Input.keyboard().isPressed(KeyEvent.VK_RIGHT)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_right\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_45;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_top\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.NONE;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase DOWN:\r\n\t\t\t\tif (Input.keyboard().isPressed(KeyEvent.VK_LEFT)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_left\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_225;\r\n\t\t\t\t}\r\n\t\t\t\telse if (Input.keyboard().isPressed(KeyEvent.VK_RIGHT)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_right\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_135;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_bottom\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_180;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase LEFT:\r\n\t\t\t\tif (Input.keyboard().isPressed(KeyEvent.VK_UP)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_left\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_315;\r\n\t\t\t\t}\r\n\t\t\t\telse if (Input.keyboard().isPressed(KeyEvent.VK_DOWN)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_back\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_225;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_left\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_270;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tcase RIGHT:\r\n\t\t\t\tif (Input.keyboard().isPressed(KeyEvent.VK_UP)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_front\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_45;\r\n\t\t\t\t}\r\n\t\t\t\telse if (Input.keyboard().isPressed(KeyEvent.VK_DOWN)) {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_right\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_135;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\tthis.getAnimationController().playAnimation(\"player_right\");\r\n\t\t\t\t\tthis.rotation = MoreRotaion.ROTATE_90;\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\tthis.getAnimationController().update();\r\n\t}\r\n\t\r\n\t\r\n\t\r\n//\tprivate void fire (Player player) {\r\n//\t\tFirePlayer firePlayer = new FirePlayer(player);\r\n//\t\tlistFired.add(firePlayer);\r\n//\t\tGame.getEnvironment().add(firePlayer);\r\n//\t}\r\n\t\r\n\t\r\n\t\r\n\tpublic boolean canBeKilledBy (final IMobileEntity otherEntity) {\r\n\t\tif (otherEntity instanceof Player) {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\t\r\n\t\r\n\tpublic MoreRotaion getRotation () {\r\n\t\treturn this.rotation;\r\n\t}\r\n\r\n}\r\n`\r\n"},"comment":{"url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/comments/446373684","html_url":"https://github.com/CalvinMT/LITIengine_test/issues/3#issuecomment-446373684","issue_url":"https://api.github.com/repos/CalvinMT/LITIengine_test/issues/3","id":446373684,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjM3MzY4NA==","user":{"login":"CalvinMT","id":24891656,"node_id":"MDQ6VXNlcjI0ODkxNjU2","avatar_url":"https://avatars1.githubusercontent.com/u/24891656?v=4","gravatar_id":"","url":"https://api.github.com/users/CalvinMT","html_url":"https://github.com/CalvinMT","followers_url":"https://api.github.com/users/CalvinMT/followers","following_url":"https://api.github.com/users/CalvinMT/following{/other_user}","gists_url":"https://api.github.com/users/CalvinMT/gists{/gist_id}","starred_url":"https://api.github.com/users/CalvinMT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CalvinMT/subscriptions","organizations_url":"https://api.github.com/users/CalvinMT/orgs","repos_url":"https://api.github.com/users/CalvinMT/repos","events_url":"https://api.github.com/users/CalvinMT/events{/privacy}","received_events_url":"https://api.github.com/users/CalvinMT/received_events","type":"User","site_admin":false},"created_at":"2018-12-11T21:44:33Z","updated_at":"2018-12-11T21:44:33Z","author_association":"OWNER","body":"Collisions are working for me.\r\nI managed them threw the map files (i.e.: \".tmx\" and \".litidata\").\r\nI use Tiled to open the \".tmx\" file, and utiLITI to open the \".litidata\" file.\r\n\r\nIt is possible to use X and Y inputs for controller support if that is what you're asking for.\r\nPlease follow this link: https://forum.litiengine.com/d/11-gamepad-inputs"}}
{"actor":{"display_login":"CalvinMT"}}