EDIT**
Wow, I didn’t realize how long it took to fetch the images. I added in 2 image members, initialized them to the brown/green images in the constructor, and changed it in the loops from fetching the images to just drawing those members, and wa-la, sped up the program like 5000x
/EDIT****
Yea, that was pretty dumb. I always do something really stupid right off. So I’ve changed it to this:
public class TestMap extends Map {
public TestMap(){populate();}
public void populate(){
for(int i=0;i<yMax;i++){
ArrayList<Integer> list = new ArrayList<Integer>(xMax);
for(int k=0;k<xMax;k++){
if((i+k)%2 == 0) list.add(new Integer(0));
else list.add(new Integer(1));
}
tree.put(i, list);
}
}
public void drawMap(Graphics g, FSEM screen, int x, int y) throws java.io.IOException{
int mapX = x-12, mapY = y-5;
int bitX=0,bitY=0;
for(int i=0;i<12;i++){
ArrayList<Integer> list = (ArrayList<Integer>)tree.get(mapY);
for(int k=0;k<26;k++){
if(list.get(mapX).equals(0)) g.drawImage(javax.imageio.ImageIO.read(new File("brown.gif")), bitX,bitY,screen);
else g.drawImage(javax.imageio.ImageIO.read(new File("green.gif")),bitX,bitY,screen);
bitX+=50; mapX++;
}
mapX=x-12; bitX=0;
bitY+=50; mapY++;
}
}
}
So this one actually runs correctly, but now it’s really really slow. I’m pretty sure it’s still poorly written, haven’t figured out just what it is, any ideas anybody? Also, I tried looking up a tutorial for this sort of mapping, but I couldn’t find any. I found this one, http://javacooperation.gmxhome.de/TutorialStartEng.html, the platform game tutorial, but what’s done there is different from what I’m trying to do, the background there doesn’t really change, it’s just the obsticals that are changing. If anybody knows of any good tutorials or examples, point me their way!