Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Why doesnt this logical tile loading system not work as I a begginer expect it to and many others for that matter?

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    9
    My Mood
    Cold
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Why doesnt this logical tile loading system not work as I a begginer expect it to and many others for that matter?

    Hello This is for a Java game

    Why does this system only draw portions of tiles, it looks as if it only ever iterates a couple times
    and doesn't iterate to load the entire map even though my txt file images\map.txt has something like.

    1 1 1 1 1 1 1 2 2 2 1 1 3 4 1 1 1 1 2 3 ect.


    please take a look at the sample.jpg I,ve attached.

    I don't understand Ive spent a couple days now trying to load a full map.



    This is my method of loading a java game map at run time.
    Please help Thankyou.


     private void load() throws FileNotFoundException
                                                                        {
                                                                          Scanner coords_scanner = new Scanner(new File("txt\\hud_map.txt")) ;
     
     
                                                                                    while(coords_scanner.hasNextInt())
                                                                                    {
                                                                                      int i = 0 ;  
     
                                                                                      for(i = 0; i < 100; i++)
                                                                                      {
                                                                                           switch(coords_scanner.nextInt())
                                                                                           {                                                                                                  
                                                                                               case 1 :
                                                                                                        draw_x_coords[i] +=  70 ;  // horizontal tile
                                                                                               break ;
                                                                                               case 2 :
                                                                                                       draw_y_coords[i] += 70 ;   // vertical tile
                                                                                               break ;
                                                                                               case 3 :
                                                                                                       draw_x_coords[i] += 140 ; // horizontal space
                                                                                               break ;
                                                                                               case 4 :
                                                                                                       draw_y_coords[i] += 140 ; // veritcal space
                                                                                               break ;
                                                                                           }
                                                                                      }
                                                                                   }
                                                                        }


     for(int i = 0; i < draw_x_coords.length ; i++)
                                                    {
     
     
                                                        g2d.drawImage(METAL_TILE,draw_x_coords[i],draw_y_coords[i],70,70,null) ;
     
                                                    }
    Attached Images Attached Images


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Why doesnt this logical tile loading system not work as I a begginer expect it to and many others for that matter?

    Can you post a small complete program the compiles, executes and shows the problem?
    Its not possible to test the small pieces of code that was posted.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Why doesnt my constructor work?
    By hairLess in forum What's Wrong With My Code?
    Replies: 13
    Last Post: July 25th, 2012, 11:38 AM
  2. [SOLVED] (Beginner) Program doesnt work
    By moneyman021 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: January 15th, 2012, 04:28 AM
  3. HI, could someone please tell me why my code doesnt work?
    By joelmeler in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 3rd, 2011, 01:37 AM
  4. begginer wondering why his guessing game won't work
    By Ligawulf in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 8th, 2010, 12:22 AM
  5. my menu doesnt work can u tell me whats wrong
    By claymore in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 8th, 2010, 04:16 AM