Results 1 to 3 of 3
  1. #1
    snj00u is offline Member
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Default Combining shapes?

    Hello

    I wondered if anyone could advise?

    I am trying to write a very simple target game in java, with a flying spaceship moving from left to right at the top of the JPanel.

    I was trying to build a flying saucer, with a circle for the window part and oval for the main part.

    I wondered how best to combin the two shapes, so I could move the two combined together using one set of x and y? Could I use the Area Class?

    Thank you

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    One solution might just be to have a draw(Graphics g) method in your SpaceShip class, which uses its x and y to draw itself however you want. Then call that method from the paintComponent(Graphics g) method you overrode, passing in the Graphics as a parameter.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,431
    Rep Power
    25

    Default

    Another idea, create an image in a BufferedImage and draw that in the paintComponent method.

Similar Threads

  1. Java combining arrays
    By trakke in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 09:32 PM
  2. problem with combining RGB binary images
    By meth in forum New To Java
    Replies: 0
    Last Post: 01-20-2011, 12:35 PM
  3. Combining these 2 projects
    By fresh83 in forum New To Java
    Replies: 14
    Last Post: 12-28-2009, 08:52 AM
  4. combining two separate codes into one
    By jaiminparikh in forum Advanced Java
    Replies: 22
    Last Post: 02-18-2009, 05:35 PM
  5. Help combining loops into 1 program.
    By kewlgeye in forum New To Java
    Replies: 5
    Last Post: 04-22-2008, 09:58 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
  •