Jump to content
  • ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By gabefgonc
      Olá, quando tento fazer um jar com os códigos a seguir, e abro o executável, ele lança a seguinte exceção:
      java.io.FileNotFoundException: res/world/world1.txt (Arquivo ou diretório inexistente)
      at java.base/java.io.FileInputStream.open0(Native Method)
      at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
      at java.base/java.io.FileInputStream.(FileInputStream.java:157)
      at java.base/java.io.FileInputStream.(FileInputStream.java:112)
      at java.base/java.io.FileReader.(FileReader.java:60)
      at br.gabefgonc.javaxswingtests.utils.Utils.loadFileAsString(Utils.java:13)
      at br.gabefgonc.javaxswingtests.worlds.World.loadWorld(World.java:68)
      at br.gabefgonc.javaxswingtests.worlds.World.(World.java:25)
      at br.gabefgonc.javaxswingtests.main.states.GameState.(GameState.java:20)
      at br.gabefgonc.javaxswingtests.main.Game.init(Game.java:95)
      at br.gabefgonc.javaxswingtests.main.Game.run(Game.java:45)
      at java.base/java.lang.Thread.run(Thread.java:834)
      java.lang.NumberFormatException: For input string: “”
      at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.base/java.lang.Integer.parseInt(Integer.java:662)
      at java.base/java.lang.Integer.parseInt(Integer.java:770)
      at br.gabefgonc.javaxswingtests.utils.Utils.parseInt(Utils.java:26)
      at br.gabefgonc.javaxswingtests.worlds.World.loadWorld(World.java:71)
      at br.gabefgonc.javaxswingtests.worlds.World.(World.java:25)
      at br.gabefgonc.javaxswingtests.main.states.GameState.(GameState.java:20)
      at br.gabefgonc.javaxswingtests.main.Game.init(Game.java:95)
      at br.gabefgonc.javaxswingtests.main.Game.run(Game.java:45)
      at java.base/java.lang.Thread.run(Thread.java:834)
      Exception in thread “Thread-0” java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
      at br.gabefgonc.javaxswingtests.worlds.World.loadWorld(World.java:72)
      at br.gabefgonc.javaxswingtests.worlds.World.(World.java:25)
      at br.gabefgonc.javaxswingtests.main.states.GameState.(GameState.java:20)
      at br.gabefgonc.javaxswingtests.main.Game.init(Game.java:95)
      at br.gabefgonc.javaxswingtests.main.Game.run(Game.java:45)
      at java.base/java.lang.Thread.run(Thread.java:834)
      códigos:
      World.java:
      package br.gabefgonc.javaxswingtests.worlds;
      import br.gabefgonc.javaxswingtests.entities.EntityManager;
      import br.gabefgonc.javaxswingtests.entities.Player;
      import br.gabefgonc.javaxswingtests.entities.Tree;
      import br.gabefgonc.javaxswingtests.inventory.Inventory;
      import br.gabefgonc.javaxswingtests.items.Item;
      import br.gabefgonc.javaxswingtests.items.ItemManager;
      import br.gabefgonc.javaxswingtests.main.Game;
      import br.gabefgonc.javaxswingtests.main.Handler;
      import br.gabefgonc.javaxswingtests.main.tiles.Tile;
      import br.gabefgonc.javaxswingtests.utils.Utils;
      import java.awt.*;
      public class World {
      private int width, height, spawnX,spawnY;
      private int[][] tiles;
      private Handler handler;
      private EntityManager entityManager;
      private ItemManager itemManager;
      public World(Handler handler, String path){
      this.handler = handler;
      entityManager = new EntityManager(handler, new Player(handler, 0, 0));
      loadWorld(path);
      entityManager.getPlayer().setX(spawnX);
      entityManager.getPlayer().setY(spawnY);
      itemManager = new ItemManager(this.handler); } public void tick(){ entityManager.tick(); itemManager.tick(); } public void render(Graphics g){ int xStart = (int) Math.max(0, handler.getCamera().getxOffset() / Tile.TILE_WIDTH); int xEnd = (int) Math.min(width, (handler.getCamera().getxOffset() + handler.getWidth()) / Tile.TILE_WIDTH + 1); int yStart = (int) Math.max(0, handler.getCamera().getyOffset() / Tile.TILE_HEIGHT); int yEnd = (int) Math.min(height, (handler.getCamera().getyOffset() + handler.getHeight()) / Tile.TILE_HEIGHT + 1); for(int y = yStart; y < yEnd; y++){ for(int x = xStart; x < xEnd; x++){ getTile(x, y).render(g, (int) (x * Tile.TILE_WIDTH - handler.getCamera().getxOffset()), (int) (y * Tile.TILE_HEIGHT - handler.getCamera().getyOffset())); } } itemManager.render(g); entityManager.render(g); } public Tile getTile(int x, int y){ Tile t; if(x < width && y < height) t = Tile.tiles[tiles[x][y]]; else t = null; if(t == null){ return Tile.grassTile; } return t; } private void loadWorld(String path){ String file = Utils.loadFileAsString(path); String[] tokens = file.split("\\s+"); System.out.println(tokens[0]); width = Utils.parseInt(tokens[0]); height = Utils.parseInt(tokens[1]); spawnX = Utils.parseInt(tokens[2]); spawnY = Utils.parseInt(tokens[3]); tiles = new int[width][height]; for(int y = 0; y < height; y++){ for(int x = 0; x < width; x++){ tiles[x][y] = Utils.parseInt(tokens[(x + y * width) + 4]); if(Utils.parseInt(tokens[(x + y * width) + 4]) == 5){ entityManager.addEntity(new Tree(handler, x * Tile.TILE_WIDTH, y * Tile.TILE_HEIGHT)); } } } } public int getWidth() { return width; } public int getHeight() { return height; } public EntityManager getEntityManager(){ return entityManager; } public Handler getHandler() { return handler; } public void setHandler(Handler handler) { this.handler = handler; } public ItemManager getItemManager() { return itemManager; } public void setItemManager(ItemManager itemManager) { this.itemManager = itemManager; } }
      Utils.java:
      package br.gabefgonc.javaxswingtests.utils;
      import java.io.BufferedReader;
      import java.io.FileReader;
      import java.io.IOException;
      public class Utils {
      public static String loadFileAsString(String path){ StringBuilder builder = new StringBuilder(); ClassLoader classLoader = ClassLoader.getSystemClassLoader(); try { BufferedReader br = new BufferedReader(new FileReader(path)); String line; while((line = br.readLine()) != null){ builder.append(line + "\n"); } }catch(IOException e){ e.printStackTrace(); } return builder.toString(); } public static int parseInt(String number){ try{ return Integer.parseInt(number); }catch(NumberFormatException e){ e.printStackTrace(); return 0; } } }
      GameState.java:
      package br.gabefgonc.javaxswingtests.main.states;
      import br.gabefgonc.javaxswingtests.entities.EntityManager;
      import br.gabefgonc.javaxswingtests.entities.Player;
      import br.gabefgonc.javaxswingtests.entities.Tree;
      import br.gabefgonc.javaxswingtests.gfx.ImageLoader;
      import br.gabefgonc.javaxswingtests.gfx.SpriteSheet;
      import br.gabefgonc.javaxswingtests.main.Game;
      import br.gabefgonc.javaxswingtests.main.Handler;
      import br.gabefgonc.javaxswingtests.main.tiles.Tile;
      import br.gabefgonc.javaxswingtests.worlds.World;
      import java.awt.*;
      public class GameState extends State {
      private World world;
      public GameState(Handler handler){ super(handler); world = new World(handler, "res/world/world1.txt"); handler.setWorld(world); } public void tick() { world.tick(); } public void render(Graphics g) { world.render(g); } }
      classPath:
      /home/gabriel/Programacao/Games/JavaxSwingTests/res
      Obrigado!
    • By Zambi
      Tenho uma aplicação web em php e quero fazer um aplicativo mobile do meu site responsivo. Como fazer e publica-lo na playstore?
    • By edionas
      Bom dia,
      a tempos venho tentando exibir o conteudo dos links abaixo na forma de tabela organizada, usando importação dos dados atraves do link:
      http://api.tcm.ce.gov.br/sim/1_0/licitacoes?codigo_municipio=002&data_realizacao_autuacao_licitacao=20100101_20100115
      http://api.tcm.ce.gov.br/sim/1_0/licitacoes.xml?codigo_municipio=002&data_realizacao_autuacao_licitacao=20100101_20100115
      http://api.tcm.ce.gov.br/sim/1_0/licitacoes.json?codigo_municipio=002&data_realizacao_autuacao_licitacao=20100101_20100115
      Porem não tenho conseguido exito.
    • By Good
      Boa noite,
       
      estou com dúvidas e estive pensando... se eu fosse criar um sistema de criar lojas virtuais, como poderia ser a estrutura, principalmente nesta parte:
      - um banco de dados para cada loja ou um banco de dados para todas as lojas?
       
      Que seria separado apenas por id de loja, pedidos seriam unicamente visto por cada loja, óbvio...
       
      Qual a sua opinião sobre isto?
    • By gamesmax2
      Pessoal criei um app Webview, com leitor de código de barra, porém tiver que utilizar a Bíblioteca zxing barcode, tá funcionando só que é queria que ao ler o código de barra, no lugar do alert fizesse um redirecionamento com código via get para tá salvando com php no banco de dados.
       
      creio que seja uma função simples um redirecionamento, como tenho conhecimento somente com php, tenho dificuldades com Java do Android.
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.