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 3 of 3

Thread: [2 Part Qestion] Saving Game Data & Hiding GUI from taskbar

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Location
    U.S.A.
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question [2 Part Qestion] Saving Game Data & Hiding GUI from taskbar

    Hello,
    I am new to these forums, so I apologize ahead of time if these things have been posted here before. I've done a search for both of these, and found nothing that answered my question.

    First I will give you a brief description of the project that I am working on so you may possibly be able to start thinking of possible ways to do what I am trying to figure out. Also, please not I am kind of a beginner at programming, I've been doing basics since I was 12, but am now just taking formal classes which explains everything.

    I am creating a Text based RPG game using NetBeans IDE 6.9 and using BreezySwing GUI. The game is a one(1) player turn based RPG where the player has these basic stats:

        private String[] playerStatName = {"HP", "Atk", "Str", "Def", "Agi", "Int", "Prayer"};
        private int[] playerStatExp = {1154, 0, 0, 0, 0, 0, 0};
        private int[] playerStatLevel = {10, 1, 1, 1, 1, 1, 1};

    I do not have everything created that the player will have, such as weapons, armor, and potions, but these will all be stored in their game save as well. Now, onto my questions.

    I've never done this before, but I've read a few things that gave me an idea on how to make a game save fine such as save1.dat, but I have no idea how to make the flat file.

    I would like this game save to store the player name, player combat level, player stats, stat levels, and stat experience, along with their inventory, and their rights. Player Rights are either 1 or 0, 1 being administrator, 0 being normal player, this will be determined by a certain username that is entered when you create a new game.

    Now, I would like the game save to look something like this

    ------------


    //Player Basics

    Username: (store username here)
    Combat: (store combat level here)

    //Player Stats

    Hitpoints: (store hitpoint experience here) (store hitpoint level here)
    Attack: (store attack experience here) (store attack level here)
    Strength: (store strength experience here) (store strength level here)
    Defense: (store defense experience here) (store defense level here)
    Agility: (store agility experience here) (store agility level here)
    Intelligence: (store intelligence experience here) (store intelligence level here)
    Prayer: (store prayer experience here) (store prayer level here)

    //Player Inventory

    Beadys: (store amount of beadys here)
    there would be something for weapons here
    there would be something for armor here
    and something for potions here



    ------------

    I do not yet have weapons, armor, or potions made, but if I see how the other stuff is done, once I have them created I can probably figure out how to add them into the file.

    So, what I need to know is how would I be able to save the game so the player can close the game, and then later re-open the game and load the game save.

    Here is how the game will be saved and loaded


    private JMenuItem saveGame, newGame, loadGame
     
     
    public void menuItemSelected(JMenuItem menu){
    if(menu == saveGame){
    what code would I put here so that it saves the data for the player that is stored in the Player.java??
    }
    if(menu == loadGame){
    what code would I put here so that it reads and loads the data from the saved game?
    }
    }

    That is my basic question. I hope I explained it correctly, and thoroughly so that you all can understand what I am asking properly.
    Also, I apologize for the extremely long post.



    Now, my second concern is this. I have a JMenuItem shop; also. And I have a Shop.java where it has the GUI stuff declared.
    Right now I have it set, in the Shop.java

    this.setUndecorated(true);
    and
    this.setResizable(false);

    this way the minimize, maximize, and close buttons do not show up, and you cannot move the shop, or change the size.

    As of right now I have the shop window popping up on top of the general GUI that has the players HUD and
    general game options, and what I want is that the player has NO way of minimizing this window, because
    I do not want the player to be able to have the shop open and fight a monster at the same time, this giving
    them the ability to buy the health potions in the middle of the fight.

    My question on this topic is, is it possible to some how hide the shop window from the taskbar so they cannot
    use that as a means to minimize the shop window?

    If there is, how do I go about doing this?

    Thank you all for reading this, and I appreciate any answers I get on these topics, and I'm always willing to take extra information
    on how to do things better than I already am.

    And again, I apologize for such a long post, I am just trying to be as thorough as I possibly can to avoid having to post replies back
    to people explaining things in more detail.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: [2 Part Qestion] Saving Game Data & Hiding GUI from taskbar

    1: I suggest reading the IO tutorials at Oracle: Lesson: Basic I/O (The Java™ Tutorials > Essential Classes) Might seem overwhelming at first, but the details for reading and writing local files are in there.

    2: Look into JDialog's or setting a JFrame to undecorated.

    If you have more questions, I recommend breaking them down into individual posts and concentrating on one problem at a time

  3. The Following User Says Thank You to copeg For This Useful Post:

    Jello36 (April 28th, 2012)

  4. #3
    Junior Member
    Join Date
    Apr 2012
    Location
    U.S.A.
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: [2 Part Qestion] Saving Game Data & Hiding GUI from taskbar

    @copeg

    Thank you for your reply. I will read into both of those things now that I know where to start looking. It is much appreciated!

Similar Threads

  1. [SOLVED] I need help with saving state data.
    By JonLane in forum Collections and Generics
    Replies: 6
    Last Post: February 27th, 2012, 03:48 AM
  2. Saving the dialog box data
    By nrao in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: February 24th, 2011, 02:53 PM
  3. saving the data of the child jsp into parent jsp
    By nrao in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 15th, 2011, 11:05 AM
  4. need help with saving data
    By bardd in forum Java Theory & Questions
    Replies: 5
    Last Post: September 19th, 2010, 02:33 PM
  5. Data hiding and maintainability
    By humdinger in forum Object Oriented Programming
    Replies: 11
    Last Post: December 5th, 2009, 01:10 PM

Tags for this Thread