GPWiki.org
GPWiki.org
It is currently Thu May 23, 2013 2:39 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Might be my computer...
PostPosted: Mon Mar 21, 2011 9:36 pm 
Bytewise
User avatar

Joined: Wed Jun 13, 2007 10:38 pm
Posts: 273
Location: Bath, New York, USA
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:

Spoiler: show
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?

_________________
Graduated and working on game now. w00T!

Married 05.02.2009


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 4:05 am 
Octogenarian

Joined: Thu Aug 04, 2011 12:00 am
Posts: 87
Location: Arizona
This is a pretty old post so I'm probably not going to be much help replying now, but I was interested in your question about array performance. If you still want to talk about this, OP?

_________________
Amazon Author Page
Game Dev Forum
Facebook Page


Top
 Profile  
 
PostPosted: Fri Jun 01, 2012 6:09 pm 
Bytewise
User avatar

Joined: Wed Jun 13, 2007 10:38 pm
Posts: 273
Location: Bath, New York, USA
Sorry been gone for so long, been busy RL like and such... but yeah I would still like ta talk about it. >.<

_________________
Graduated and working on game now. w00T!

Married 05.02.2009


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group