Results 1 to 5 of 5

Thread: Connect Four

  1. #1
    tabchas's Avatar
    tabchas is offline Member
    Join Date
    Mar 2011
    Location
    Austin
    Posts
    60
    Rep Power
    0

    Default Connect Four

    Hey Guys,

    I am planning to build a Connect Four Two-Player Game. However, I do not know how to start the drawing of the board. What is the best way to draw the board so I can start coding the actions in the back?

    Thanks!
    Tabish Chasmawala

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    A couple of ways come to my mind:
    • Draw a board grid onto a BufferedImage and use this as your board, or
    • Make the board be a JPanel that uses a GridLayout, perhaps "drawing" lines by having gaps between the cells of the grid and placing it over a non-white JPanel. It could hold JPanels or cells that could be empty or could hold JLabels each holding an image of a colored disk.
    • Or some combination of the two.
    • Or a better suggestion from one of the Swing GUI gurus.

  3. #3
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    If you're worried about coding the back-end, you can create a temporary method to output the grid to the console (so you can debug it more easily), something like:

    Java Code:
    - - - - - - - -
    - - - - - - - -
    - - - - - - - -
    - - - - - - - -
    - - - - O - - -
    - - O X O - - -
    - - X O X - - -
    - X O O X O X X

    ...until you've decided on a rendering method (Swing, LWJGL, JOGL, jME3, etc.).

  4. #4
    tabchas's Avatar
    tabchas is offline Member
    Join Date
    Mar 2011
    Location
    Austin
    Posts
    60
    Rep Power
    0

    Default

    Well, I still do not know what to do. Fubarable... How do you draw a grid on a BufferedImage? What do you mean by that?
    Tabish Chasmawala

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. connect through usb
    By taufiqbzz in forum Networking
    Replies: 0
    Last Post: 11-02-2010, 12:04 AM
  2. Connect Four
    By chick in forum New To Java
    Replies: 3
    Last Post: 05-04-2010, 05:33 AM
  3. Connect 4
    By pansylea in forum New To Java
    Replies: 0
    Last Post: 12-11-2009, 04:36 PM
  4. connect to ftp
    By anki.gulsvart in forum Networking
    Replies: 21
    Last Post: 10-20-2009, 09:19 PM
  5. how connect
    By herfnai in forum JDBC
    Replies: 1
    Last Post: 08-18-2008, 07:34 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
  •