Results 1 to 2 of 2
Thread: Help with Grid Layout
- 08-06-2007, 05:54 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
Help with Grid Layout
Hello, I'm trying to write a game in Java. The Sea Battle game where you should hit and sink the opponents ships...
It has to be in a field 10x10 squares and i had written the code for a square.
But i have know idea what to do next. I know I should put them in a Grid Layout, but how the hell should I program the ships?Java Code:import java.awt.*; import javax.swing.*; public class Tile extends JButton{ public Tile() { super(""); } public void paintComponent (Graphics g) { g.setColor (getForeground()); } }
Thanks.
- 08-06-2007, 08:03 PM #2
Here's an idea. Try drawing your grid in the paintComponent method of a JPanel, the sea, and drawing images of the ships in the grid cells. Keep a boolean array that matches the grid structure. You can set/change the boolean values for availability of targets. Use keyboard navigation to maneuver your ship among the cells, to rotate and to fire.
Similar Threads
-
Object locations via grid coordinates HELP.
By deadman_uk in forum New To JavaReplies: 4Last Post: 11-18-2007, 08:32 PM -
Help creating a changing grid
By adlb1300 in forum New To JavaReplies: 11Last Post: 10-24-2007, 01:41 PM -
JGraph Layout Pro 1.4.0.3
By levent in forum Java SoftwareReplies: 0Last Post: 07-31-2007, 06:43 PM -
Grid Resources for Industrial Applications 5.1
By levent in forum Java SoftwareReplies: 0Last Post: 05-24-2007, 09:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks