But it could be my poor coding too. I was wondering when it comes to arrays, does size and type of the arrays matter as to how fast they get processed?
Reason I'm asking is I have two single-dimensional arrays that are 100 indices long that are both strings and they apparently load, but nothing is happening...
I have also had a double-dimensional array of 200+ indices long that was made up of drawn out squares done by built-in java libraries, it was laggy, but it worked.
I think that's how I want to ask that. >.<
Regardless, code is located below:
Code:
public Map()
{
mapID=3;
loadTiles();
loadMove();
loadTileMap();
panel.setLayout(new GridLayout(10,10,0,0));
add(panel);
}
private void loadTileMap()
{ /*****************************
* Loads the Move Array into *
* tile map to allow for *
* visibility to come into *
* effect. *
*****************************/
tilemap = new Tile[10][10];
int i =0;
for(int x= 0; x<tilemap.length;x++)
{
for(int y= 0; y<tilemap[x].length;y++)
{
if(i <=movemap.length-1)
{
tilemap[x][y]=new Tile();
tilemap[x][y].setSymbol(movemap[i]);
panel.add(tilemap[x][y]);
i++;
}//End If
}//End FOR-Y
}//End FOR-X
}
private void loadMove()
{
/*****************************
* Loads the Tiles Array into*
* move array to allow for *
* character input and thus *
* movement. *
*****************************/
boolean characterPlaced=false;
movemap = new String[100];
movemap = tiles;
int m = 0;
while(characterPlaced!=true)
{
if(m<movemap.length)
{
if(movemap[m].equals("+"))
{
movemap[m] ="P";
characterPlaced=true;
}
m++;
}
}
}
private void loadTiles()
{
/*****************************
* Loads the Map's Tile Info *
* into the Tile Array *
*****************************/
try
{
input = new Scanner(new File("F:\\DOCUMENTS AND PROGRAMS\\PROGRAMMING\\JAVA\\TacticalGame\\src\\tacticalgame\\test"+mapID+".txt"));
tiles = new String[100];
while(input.hasNext())
{
for(int t =0;t<tiles.length;t++)
{
tiles[t]=input.next();
}
}
}
catch(NoSuchElementException nsee)
{
System.err.println("File improperly Formed");
input.close();
System.exit(1);
}
catch(IllegalStateException ise)
{
System.err.println("Error reading file");
System.exit(1);
}
catch(FileNotFoundException fnfe)
{
System.err.println("File cannot be found");
System.exit(1);
}
finally
{
if(input!=null)
input.close();
}
}
I spoilered it because it's such a large block of code. >.<
What I am trying to do is load my map as a String Array that doesn't get editted [called tiles], a movemap, another String array which is just a copy of the tiles array with the player's marker added and to allow for movement [not done yet though], and the tiles array, which is a double-dimensional array of tiles created as sets of drawn boxes using built in libraries from Java to display the movemap in an easily viewable format, seeing as I have no tiles or sprites yet implemented.
Here's the rub. Right now I have my two String Arrays set at 100 indices total, when I go to debug and check everything it seems to run fine but nothing happens, before this I had the two String Arrays at 40 indices total with no problem, I guess that is where my problem started.
Just so you don't have to dig for the question again, I'm going to post it here:
I was wondering when it comes to arrays, does size and type of the arrays matter as to how fast they get processed?