diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/gamestate/mapview/CharSet.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/gamestate/mapview/CharSet.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com/fourisland/fourpuzzle/gamestate/mapview/CharSet.java b/src/com/fourisland/fourpuzzle/gamestate/mapview/CharSet.java new file mode 100644 index 0000000..b6e23d6 --- /dev/null +++ b/src/com/fourisland/fourpuzzle/gamestate/mapview/CharSet.java | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * To change this template, choose Tools | Templates | ||
3 | * and open the template in the editor. | ||
4 | */ | ||
5 | |||
6 | package com.fourisland.fourpuzzle.gamestate.mapview; | ||
7 | |||
8 | import com.fourisland.fourpuzzle.*; | ||
9 | import com.fourisland.fourpuzzle.util.ObjectLoader; | ||
10 | import java.awt.image.BufferedImage; | ||
11 | |||
12 | /** | ||
13 | * | ||
14 | * @author hatkirby | ||
15 | */ | ||
16 | public class CharSet { | ||
17 | |||
18 | private BufferedImage charSetImage; | ||
19 | |||
20 | private CharSet() | ||
21 | { | ||
22 | } | ||
23 | |||
24 | public BufferedImage getImage(int offset, Direction direction, int step) | ||
25 | { | ||
26 | int sx = ((offset % 4) * 72) + (step * 24); | ||
27 | int sy = ((offset / 4) * 128) + (direction.ordinal() * 32); | ||
28 | |||
29 | return charSetImage.getSubimage(sx, sy, 24, 32); | ||
30 | } | ||
31 | |||
32 | public static CharSet getCharSet(String charSet) throws Exception { | ||
33 | CharSet temp = new CharSet(); | ||
34 | temp.charSetImage = ObjectLoader.getImage("CharSet", charSet); | ||
35 | return temp; | ||
36 | } | ||
37 | |||
38 | } | ||