1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| import javax.swing.JFrame;
import java.awt.Graphics; import java.awt.Color;
import java.awt.event.WindowEvent; import java.awt.event.WindowAdapter;
public class Puzzle extends JFrame { private static final int SIZE = 15; private static int WIDTH = 10; private static int HEIGHT = 40;
public Puzzle() { super("Steel Platoon Combat -Chris Gillis(poisonousparrot)-kevglass");
addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
setSize(700,700); setVisible(true); }
public void paint(Graphics g) { g.setColor(Color.white); g.fillRect(0,0,1000,1000);
g.translate(50,50);
for (int y=0;y<HEIGHT;y++) { for (int x=0;x<WIDTH;x++) { int offset = 0;
if (y % 2 != 0) { offset = (int) (SIZE*2); }
drawHex(g,(x*(SIZE*4))+offset,y*(SIZE)); } } }
private void drawHex(Graphics g,int xp,int yp) { g.setColor(Color.black);
g.drawLine((int) (xp-(SIZE*1.5)),(int) yp,(int) (xp-(SIZE*0.5)),(int) (yp-(SIZE))); g.drawLine((int) (xp-(SIZE*1.5)),(int) yp,(int) (xp-(SIZE*0.5)),(int) (yp+(SIZE)));
g.drawLine((int) (xp+(SIZE*1.5)),(int) yp,(int) (xp+(SIZE*0.5)),(int) (yp-(SIZE))); g.drawLine((int) (xp+(SIZE*1.5)),(int) yp,(int) (xp+(SIZE*0.5)),(int) (yp+(SIZE)));
g.drawLine((int) (xp-(SIZE*0.5)),(int) yp-(SIZE),(int) (xp+(SIZE*0.5)),(int) yp-(SIZE)); g.drawLine((int) (xp-(SIZE*0.5)),(int) yp+(SIZE),(int) (xp+(SIZE*0.5)),(int) yp+(SIZE)); }
public static void main(String[] args) { new Puzzle(); }
} |