diff options
author | Starla Insigna <hatkirby@fourisland.com> | 2012-06-03 16:37:20 -0400 |
---|---|---|
committer | Starla Insigna <hatkirby@fourisland.com> | 2012-06-03 16:37:20 -0400 |
commit | de89b524f3f42c8d875b9fe432f46275c2819b94 (patch) | |
tree | 6ac9e4c6706feb948b9d734aa5feb349d969c225 /src/com/fourisland | |
parent | 3f71b9f4a6173be5b39fb9bc9808ac464de2b394 (diff) | |
download | frigidearth-de89b524f3f42c8d875b9fe432f46275c2819b94.tar.gz frigidearth-de89b524f3f42c8d875b9fe432f46275c2819b94.tar.bz2 frigidearth-de89b524f3f42c8d875b9fe432f46275c2819b94.zip |
Added colored characters
Diffstat (limited to 'src/com/fourisland')
5 files changed, 28 insertions, 14 deletions
diff --git a/src/com/fourisland/frigidearth/MapViewGameState.java b/src/com/fourisland/frigidearth/MapViewGameState.java index 86fe437..08bb151 100644 --- a/src/com/fourisland/frigidearth/MapViewGameState.java +++ b/src/com/fourisland/frigidearth/MapViewGameState.java | |||
@@ -510,7 +510,7 @@ public class MapViewGameState implements GameState | |||
510 | 510 | ||
511 | if (displayChar != ' ') | 511 | if (displayChar != ' ') |
512 | { | 512 | { |
513 | g.drawImage(SystemFont.getCharacter(grid[x][y].getDisplayCharacter()), (x-viewportx)*TILE_WIDTH, (y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 513 | g.drawImage(SystemFont.getCharacter(grid[x][y].getDisplayCharacter(), Color.WHITE), (x-viewportx)*TILE_WIDTH, (y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
514 | } | 514 | } |
515 | } | 515 | } |
516 | } | 516 | } |
@@ -521,12 +521,12 @@ public class MapViewGameState implements GameState | |||
521 | { | 521 | { |
522 | if ((gridLighting[mob.x][mob.y]) && (isInViewport(mob.x, mob.y))) | 522 | if ((gridLighting[mob.x][mob.y]) && (isInViewport(mob.x, mob.y))) |
523 | { | 523 | { |
524 | g.drawImage(SystemFont.getCharacter(mob.getDisplayCharacter()), (mob.x-viewportx)*TILE_WIDTH, (mob.y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 524 | g.drawImage(SystemFont.getCharacter(mob.getDisplayCharacter(), mob.getDisplayColor()), (mob.x-viewportx)*TILE_WIDTH, (mob.y-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | 527 | ||
528 | // Render player | 528 | // Render player |
529 | g.drawImage(SystemFont.getCharacter('@'), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 529 | g.drawImage(SystemFont.getCharacter('@', Color.WHITE), (playerx-viewportx)*TILE_WIDTH, (playery-viewporty)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
530 | 530 | ||
531 | // Render messages | 531 | // Render messages |
532 | g.setColor(new Color(53, 63, 62)); | 532 | g.setColor(new Color(53, 63, 62)); |
@@ -538,7 +538,7 @@ public class MapViewGameState implements GameState | |||
538 | { | 538 | { |
539 | for (int j=0; j<messages[i].length(); j++) | 539 | for (int j=0; j<messages[i].length(); j++) |
540 | { | 540 | { |
541 | g.drawImage(SystemFont.getCharacter(messages[i].charAt(j)), j*TILE_WIDTH, (VIEWPORT_HEIGHT+i)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); | 541 | g.drawImage(SystemFont.getCharacter(messages[i].charAt(j), Color.WHITE), j*TILE_WIDTH, (VIEWPORT_HEIGHT+i)*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT, null); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | } | 544 | } |
diff --git a/src/com/fourisland/frigidearth/Mob.java b/src/com/fourisland/frigidearth/Mob.java index fdc7a8a..b89831c 100644 --- a/src/com/fourisland/frigidearth/Mob.java +++ b/src/com/fourisland/frigidearth/Mob.java | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | package com.fourisland.frigidearth; | 5 | package com.fourisland.frigidearth; |
6 | 6 | ||
7 | import java.awt.Color; | ||
7 | import java.awt.Point; | 8 | import java.awt.Point; |
8 | 9 | ||
9 | /** | 10 | /** |
@@ -35,5 +36,6 @@ public abstract class Mob | |||
35 | } | 36 | } |
36 | 37 | ||
37 | public abstract char getDisplayCharacter(); | 38 | public abstract char getDisplayCharacter(); |
39 | public abstract Color getDisplayColor(); | ||
38 | public abstract String getName(); | 40 | public abstract String getName(); |
39 | } | 41 | } |
diff --git a/src/com/fourisland/frigidearth/SystemFont.java b/src/com/fourisland/frigidearth/SystemFont.java index 2ea5057..46946ea 100644 --- a/src/com/fourisland/frigidearth/SystemFont.java +++ b/src/com/fourisland/frigidearth/SystemFont.java | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | package com.fourisland.frigidearth; | 5 | package com.fourisland.frigidearth; |
6 | 6 | ||
7 | import java.awt.Color; | ||
7 | import java.awt.GraphicsConfiguration; | 8 | import java.awt.GraphicsConfiguration; |
8 | import java.awt.GraphicsDevice; | 9 | import java.awt.GraphicsDevice; |
9 | import java.awt.GraphicsEnvironment; | 10 | import java.awt.GraphicsEnvironment; |
@@ -12,6 +13,8 @@ import java.awt.Transparency; | |||
12 | import java.awt.image.BufferedImage; | 13 | import java.awt.image.BufferedImage; |
13 | import java.awt.image.FilteredImageSource; | 14 | import java.awt.image.FilteredImageSource; |
14 | import java.io.IOException; | 15 | import java.io.IOException; |
16 | import java.util.HashMap; | ||
17 | import java.util.Map; | ||
15 | import java.util.logging.Level; | 18 | import java.util.logging.Level; |
16 | import java.util.logging.Logger; | 19 | import java.util.logging.Logger; |
17 | import javax.imageio.ImageIO; | 20 | import javax.imageio.ImageIO; |
@@ -22,9 +25,9 @@ import javax.imageio.ImageIO; | |||
22 | */ | 25 | */ |
23 | public class SystemFont | 26 | public class SystemFont |
24 | { | 27 | { |
25 | private static BufferedImage fontGraphic = null; | 28 | private static Map<Color,BufferedImage> fontGraphic = new HashMap<Color,BufferedImage>(); |
26 | 29 | ||
27 | public static void initalize() | 30 | public static void initalize(Color color) |
28 | { | 31 | { |
29 | try | 32 | try |
30 | { | 33 | { |
@@ -32,21 +35,22 @@ public class SystemFont | |||
32 | GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); | 35 | GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
33 | GraphicsDevice device = env.getDefaultScreenDevice(); | 36 | GraphicsDevice device = env.getDefaultScreenDevice(); |
34 | GraphicsConfiguration config = device.getDefaultConfiguration(); | 37 | GraphicsConfiguration config = device.getDefaultConfiguration(); |
35 | fontGraphic = config.createCompatibleImage(temp.getWidth(), temp.getHeight(), Transparency.TRANSLUCENT); | 38 | BufferedImage g = config.createCompatibleImage(temp.getWidth(), temp.getHeight(), Transparency.TRANSLUCENT); |
36 | fontGraphic.createGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(temp.getRGB(0, 0)))),0,0,null); | 39 | g.createGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(temp.getRGB(0, 0), color.getRGB()))),0,0,null); |
40 | fontGraphic.put(color, g); | ||
37 | } catch (IOException ex) | 41 | } catch (IOException ex) |
38 | { | 42 | { |
39 | Logger.getLogger(SystemFont.class.getName()).log(Level.SEVERE, null, ex); | 43 | Logger.getLogger(SystemFont.class.getName()).log(Level.SEVERE, null, ex); |
40 | } | 44 | } |
41 | } | 45 | } |
42 | 46 | ||
43 | public static BufferedImage getCharacter(char c) | 47 | public static BufferedImage getCharacter(char c, Color color) |
44 | { | 48 | { |
45 | if (fontGraphic == null) | 49 | if (!fontGraphic.containsKey(color)) |
46 | { | 50 | { |
47 | initalize(); | 51 | initalize(color); |
48 | } | 52 | } |
49 | 53 | ||
50 | return fontGraphic.getSubimage((c % 16) * 12, (c / 16) * 12, 12, 12); | 54 | return fontGraphic.get(color).getSubimage((c % 16) * 12, (c / 16) * 12, 12, 12); |
51 | } | 55 | } |
52 | } | 56 | } |
diff --git a/src/com/fourisland/frigidearth/TransparentPixelFilter.java b/src/com/fourisland/frigidearth/TransparentPixelFilter.java index 3f7e92b..6821caf 100644 --- a/src/com/fourisland/frigidearth/TransparentPixelFilter.java +++ b/src/com/fourisland/frigidearth/TransparentPixelFilter.java | |||
@@ -14,9 +14,11 @@ import java.awt.image.RGBImageFilter; | |||
14 | public class TransparentPixelFilter extends RGBImageFilter { | 14 | public class TransparentPixelFilter extends RGBImageFilter { |
15 | 15 | ||
16 | private int trans; | 16 | private int trans; |
17 | public TransparentPixelFilter(int i) | 17 | private int replace; |
18 | public TransparentPixelFilter(int i, int j) | ||
18 | { | 19 | { |
19 | trans = i; | 20 | trans = i; |
21 | replace = j; | ||
20 | 22 | ||
21 | canFilterIndexColorModel = true; | 23 | canFilterIndexColorModel = true; |
22 | } | 24 | } |
@@ -28,7 +30,7 @@ public class TransparentPixelFilter extends RGBImageFilter { | |||
28 | { | 30 | { |
29 | return 0; | 31 | return 0; |
30 | } else { | 32 | } else { |
31 | return rgb; | 33 | return replace; |
32 | } | 34 | } |
33 | } | 35 | } |
34 | 36 | ||
diff --git a/src/com/fourisland/frigidearth/mobs/Mouse.java b/src/com/fourisland/frigidearth/mobs/Mouse.java index 5fdf7cd..af9fe44 100644 --- a/src/com/fourisland/frigidearth/mobs/Mouse.java +++ b/src/com/fourisland/frigidearth/mobs/Mouse.java | |||
@@ -5,6 +5,7 @@ | |||
5 | package com.fourisland.frigidearth.mobs; | 5 | package com.fourisland.frigidearth.mobs; |
6 | 6 | ||
7 | import com.fourisland.frigidearth.Mob; | 7 | import com.fourisland.frigidearth.Mob; |
8 | import java.awt.Color; | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * | 11 | * |
@@ -24,6 +25,11 @@ public class Mouse extends Mob | |||
24 | return 'm'; | 25 | return 'm'; |
25 | } | 26 | } |
26 | 27 | ||
28 | public Color getDisplayColor() | ||
29 | { | ||
30 | return Color.GRAY; | ||
31 | } | ||
32 | |||
27 | public String getName() | 33 | public String getName() |
28 | { | 34 | { |
29 | return "Mouse"; | 35 | return "Mouse"; |