Results 1 to 9 of 9
  1. #1
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Question for my Swing game

    I have a game where peter griffin moves around trying to get a burger, and he needs to avoid a moving ball.
    -when I approach (and eat) the burger horizontally, I get a billion run time errors regarding events but still get points (if I do it vertically, absolutely no problem!)
    -I have a JOptionPane which is coded as follows
    Java Code:
    if(life<=0){
    			Object[] possibleValues = { "Close", "Restart"};
    			Object selectedValue = JOptionPane.showInputDialog(null,
    			"Your score was:"+score, "You Lose!",
    			JOptionPane.INFORMATION_MESSAGE, null,
    			possibleValues, possibleValues[0]);
    			if (selectedValue == possibleValues[0]){
    				System.exit(1);
    			}
    			if (selectedValue == possibleValues[1]){
                  ResetGame();
    			}
    to let the user reset or quit, but I need to get rid of the cancel message. Also, I'd like to get rid of the Java Icon on it.

    Third, does anyone know any good tuts on double buffering? I heard it's what will make my character movement stop looking laggy

    Lastly, does anyone know how I can put a custom image as the game icon? I've tried numerous tutorials but it never changes (filepath is always right)

    Thanks for and if you do take your time to answer these :)

    Please just ask if you need my code :D

    PS. Other than a jlabel, what could I display a timer on?
    Last edited by MW130; 01-24-2014 at 04:07 AM.

  2. #2
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Question for my Swing game

    For your last question:

    "public void setIconImage(Image image)
    Sets the image to be displayed as the icon for this window.
    This method can be used instead of setIconImages() to specify a single image as a window's icon.

    The following statement:

    setIconImage(image);

    is equivalent to:
    ArrayList<Image> imageList = new ArrayList<Image>();
    imageList.add(image);
    setIconImages(imageList);

    Note : Native windowing systems may use different images of differing dimensions to represent a window, depending on the context (e.g. window decoration, window list, taskbar, etc.). They could also use just a single image for all contexts or no image at all.

    Overrides:
    setIconImage in class Window
    Parameters:
    image - the icon image to be displayed.
    See Also:
    Window.setIconImages(java.util.List<? extends java.awt.Image>), Window.getIconImages()"

    ImageIO has 4 methods to convert different objects into bufferedimages.
    static BufferedImage read(File input)
    Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered.
    static BufferedImage read(ImageInputStream stream)
    Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered.
    static BufferedImage read(InputStream input)
    Returns a BufferedImage as the result of decoding a supplied InputStream with an ImageReader chosen automatically from among those currently registered.
    static BufferedImage read(URL input)
    Returns a BufferedImage as the result of decoding a supplied URL with an ImageReader chosen automatically from among those currently registered.

    I strongly recommend looking at the the java docs.
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  3. #3
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Question for my Swing game

    Right, and I did. But, like I previously said, I have run
    frame.setIconImage(image);
    a billion times, with the correct file path for the image, and it does not ever change.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: Question for my Swing game

    Quote Originally Posted by zFollette View Post
    I strongly recommend looking at the the java docs.
    Yep. And and the Java tutorials as well.

    Regards,
    Jim
    Last edited by jim829; 01-24-2014 at 04:46 AM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: Question for my Swing game

    The docs also say that icon sizes are specific (not word for word, but you get it) I believe the imageicon size is 32x32
    1000011 1100001 1101110 100000 1111001 1101111 1110101 100000 1110010 1100101 1100001 1100100 100000 1000010 1101001 1101110 1100001 1110010 1111001 111111

  6. #6
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Question for my Swing game

    Jim, I know you don't believe me, but I really do read it. I come here when I cannot understand. zFollette, I had not known the 32x32 thing. But unfortunately, it still did not work

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,616
    Rep Power
    5

    Default Re: Question for my Swing game

    Actually I do believe you. But how many times have your read them? I barely ever get it on the first go around. In some cases it takes me three or more readings because of all the methods and their subtleties. And the Java tutorials cover almost everything you are trying to do in your game. They even have downloadable compilable examples. I still refer to them often (especially when I haven't done something in a while).

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  8. #8
    MW130 is offline Senior Member
    Join Date
    Jan 2013
    Posts
    317
    Rep Power
    2

    Default Re: Question for my Swing game

    Well, I read them and try to understand. When I don't, I come to this forum where I am enlightened by knowledgeable programmers such as yourself :)
    Here, I am considered terrible with Java, but at my school everyone asks me for help haha. But yeah, I do look, and come to experts like you when I don't understand. I am sorry if I offend you for it though, my only goal is to learn

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,029
    Rep Power
    6

    Default Re: Question for my Swing game

    Oh the abuse of the word 'offense', that is the only offending thing happening.

    What you have to realize is that a forum is not a substitute for a tutor. You are asking a lot of the people in a forum when you go to them with a problem of understanding; those are far better solved through personal sacrifice in the form of intense study and experimentation. If one source of information is not satisfactory (and I find the java tutorials VERY unsatisfactory), apply another.

    PS: you so coolly mention that classmates come to you for help, in that you admit one big failure: apparently you don't return that honor. I think you should spend more time working things out with your classmates; that was a strategy that worked VERY well for me even though I too was the guy that everyone went to for answers. Doing stuff alone simply doesn't work well.
    Last edited by gimbal2; 01-24-2014 at 09:32 AM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 4
    Last Post: 07-08-2012, 09:07 AM
  2. Swing question
    By BenH in forum AWT / Swing
    Replies: 2
    Last Post: 02-11-2012, 06:12 AM
  3. Memory game - swing
    By Vizualni in forum AWT / Swing
    Replies: 7
    Last Post: 07-27-2010, 06:56 PM
  4. Swing question
    By Psyclone in forum New To Java
    Replies: 0
    Last Post: 02-02-2010, 10:50 PM
  5. Swing Question, can you help?
    By Silentstormz in forum AWT / Swing
    Replies: 4
    Last Post: 09-21-2008, 03:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •