For some reason, I'm having a hard time drawing objects on screen. Here's my code:
Level.java
package com.gravitygamesinteractive.kylethecaiman; import java.awt.*; import java.util.*; import java.io.File; public class Level { public Tile tile; private Scanner s; private int objectId; private int spx; private int spy; private String oidstr; private String xstr; private String ystr; private ArrayList<String> objarray= new ArrayList<String>(); private ArrayList<String> xarray= new ArrayList<String>(); private ArrayList<String> yarray= new ArrayList<String>(); public Level(){ setStage(); } public void tick(){ } public void render(Graphics g){ } public void setStage(){ tile=new Tile(0,0); tile=new Tile(0,0); } } }
Tile.java:
package com.gravitygamesinteractive.kylethecaiman; import java.awt.*; import javax.swing.JFrame; public class Tile extends Rectangle{ private static final long serialVersionUID=1L; public Tile(int x, int y){ this.x=x; this.y=y; } public void render(Graphics g){ g.setColor(Color.red); g.drawRect(x,y,16,16); } }
The problem is that the Tile object will only be created at the last instance of "tile=new Tile". I can't seem to figure out how to create them both. Just writing new Tile doesn't work either, as the objects won't draw.