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

    Default Combining shapes?


    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
    Washington, DC
    Rep Power


    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 - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power


    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