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

    Default three questions in Swing

    So, I have a game. I would like to make a game where you press "start" and THEN it starts.

    Also, I want to have collision with triangles, not just squares. The way I handle collision right now is with if statements, if the object is within the other, game over.
    How would I do collision with triangles?

    Lastly, how do I set a high score?
    Oh and how to change fonts and fontisize in swing?

    Thanks

    PS: This is the game: ball has to jump over obstacles
    three questions in Swing-screen-shot-2014-02-10-11.21.40-am.png

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: three questions in Swing

    How would I do collision with triangles?
    Look at the Shapes interface. It has some useful methods: contains() and intersects(). It might have some useful classes that implement it.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: three questions in Swing

    But the shapes interface doesn't let you do anything unless you create a graphics2d object, and what I am doing is drawing on the paintComponent..

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: three questions in Swing

    Write a very small testing program that uses some Shape objects and test how its methods work.

    There is no requirement for a Graphcs2D object.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: three questions in Swing

    Thanks, Norm!

    Lastly, do you know how I can get rid of that unpleasant java cup that marks "java" as the icon? I tried the .setIconImage(blah blah) method, but nothing happens. Thanks !

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default Re: three questions in Swing

    I have no idea.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,097
    Rep Power
    6

    Default Re: three questions in Swing

    Quote Originally Posted by MW130 View Post
    Lastly, do you know how I can get rid of that unpleasant java cup that marks "java" as the icon?
    Where exactly? In your initial screenshot for example I don't see it.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,778
    Rep Power
    5

    Default Re: three questions in Swing

    What does paintComponent have to do with anything. Just cast the Graphics context to a Graphics2D context (assuming you need it of course).

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

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

    Default Re: three questions in Swing

    gimbal, this is the file that shows up:

    three questions in Swing-screen-shot-2014-02-10-9.03.58-pm.png

    On a side note, anyone know how to get mouse coordinates? I am implementing the MouseListener, but am unsure which method to put it within. None of the five allow you to find the points at any time: the closest I got is to find the points when the mouse enters, and for that the user needs to take the mouse in and out. Anyone know how to get the coords without clicks or anything?
    Last edited by MW130; 02-11-2014 at 03:36 AM.

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

    Default Re: three questions in Swing

    I got the mouselistener thing. Still can't figure the icon

Similar Threads

  1. java swing questions
    By Darego in forum New To Java
    Replies: 2
    Last Post: 05-04-2013, 05:46 PM
  2. Replies: 0
    Last Post: 01-17-2013, 01:12 AM
  3. Replies: 6
    Last Post: 05-14-2012, 12:59 PM
  4. Swing Timer Questions
    By morfasto in forum New To Java
    Replies: 9
    Last Post: 11-14-2009, 03:48 PM
  5. Two swing questions
    By carderne in forum New To Java
    Replies: 10
    Last Post: 12-24-2008, 05:01 PM

Posting Permissions

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