Skip to content

Commit 3fbcd30

Browse files
committed
working on PuzzleKoan w/Jim
1 parent 2e890eb commit 3fbcd30

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed
188 Bytes
Binary file not shown.

TeachingKidsProgramming/src/org/teachingkidsprogramming/section08tdd/PuzzleBoard.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import java.awt.Color;
44
import java.awt.Graphics2D;
5+
import java.awt.Image;
6+
import java.net.URL;
57

8+
import javax.swing.ImageIcon;
69
import javax.swing.JPanel;
710

811
import org.teachingextensions.logo.Paintable;
@@ -21,8 +24,36 @@ public void paint(Graphics2D g, JPanel caller)
2124
{
2225
Color color2 = PenColors.Blues.DarkBlue;
2326
g.setColor(color2);
24-
g.fillRect(20, 20, 400, 400);
27+
g.fillRect(20, 20, 410, 410);
2528
g.setColor(PenColors.Blues.SkyBlue);
26-
g.fillRect(30, 30, 380, 380);
29+
g.fillRect(30, 30, 386, 386);
30+
String[] tiles = {"Batgirl1a.png",
31+
"Batgirl1b.png",
32+
"Batgirl1c.png",
33+
"Batgirl2a.png",
34+
"Batgirl2b.png",
35+
"Batgirl2c.png",
36+
"Batgirl3a.png",
37+
"Batgirl3b.png",
38+
"Batgirl3c.png"};
39+
for (int i = 0; i < 8; i++)
40+
{
41+
if (i < 3)
42+
{
43+
drawTile(g, tiles[i], 35, 35 + (127 * i));
44+
}
45+
else if (i < 6)
46+
drawTile(g, tiles[i], 162, 35 + (127 * (i - 3)));
47+
else
48+
{
49+
drawTile(g, tiles[i], 289, 35 + (127 * (i - 6)));
50+
}
51+
}
52+
}
53+
private void drawTile(Graphics2D g, String tile, int x, int y)
54+
{
55+
URL imagePicture = this.getClass().getResource(tile);
56+
Image img = new ImageIcon(imagePicture).getImage();
57+
g.drawImage(img, x, y, 122, 122, null);
2758
}
2859
}

TeachingKidsProgramming/src/org/teachingkidsprogramming/section08tdd/PuzzleSolver.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ public PuzzleSolver()
2929
PuzzleBoard jboard = new PuzzleBoard();
3030
jboard.addTo(programWindow);
3131
programWindow.setVisible(true);
32-
//Image batGirl = batGirl.drawImage(batGirl, 0,0,100,100, null);
33-
//programWindow
34-
// .setBackgroundImage("http://upload.wikimedia.org/wikipedia/commons/thumb/a/a5/Batgirl.gif/120px-Batgirl.gif");
3532
}
3633
public static void main(String[] args)
3734
{

0 commit comments

Comments
 (0)