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: Problem with changing level in game

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Location
    kathmandu, nepal
    Posts
    29
    My Mood
    Cheerful
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with changing level in game

    I am making boulderdash game and m stuck in changing and retrying the level in the game.. Here is my code !!

    public ReadFileReplace()
    {

    imageObject();
    replaceIcon();

    }

    public void imageObject()
    {
    objwall = new ImageIcon("wall_32.png");
    other more images


    }

    public void replaceIcon()
    {

    try
    {
    FileReader fileRead = new FileReader("level"+level+".txt"); --- i think the problem is here!!
    BufferedReader buffread = new BufferedReader(fileRead);
    String lineRead = buffread.readLine();
    int x=0;
    while(lineRead!=null)
    {
    for(int y=0;y<20;y++)
    {
    fileReadArray[x][y] = new JLabel();
    c=lineRead.charAt(y);
    if(c=='W')
    {
    fileReadArray[x][y].setIcon(objwall);
    mapPanel.add(fileReadArray[x][y]);
    }
    .
    .
    .
    .
    And other codes!!

    }
    lineRead = buffread.readLine();
    x++;

    }

    buffread.close();
    fileRead.close();
    }

    catch(Exception e)
    {
    e.printStackTrace();
    }

    }



    and on the other class, i called imageIcon() inside retry () method.......please help me !!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Problem with changing level in game

    stuck in changing and retrying the level
    Can you explain in programming terms what the problem. Levels have no meaning in java.

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. how to set up level class in 2d java game
    By hwoarang69 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 25th, 2012, 06:17 PM
  2. problem while changing file data
    By badhen in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 17th, 2012, 01:19 PM
  3. A level format problem
    By Gravity Games in forum Object Oriented Programming
    Replies: 8
    Last Post: June 4th, 2012, 02:20 PM
  4. Replies: 0
    Last Post: May 10th, 2012, 07:59 PM
  5. Problem changing the image in a JLabel
    By kc120us in forum AWT / Java Swing
    Replies: 1
    Last Post: October 16th, 2011, 10:16 PM