Akai wrote: |
was bored |
Code: Show/Hide package servertools.map.content; import java.awt.Graphics; import javax.swing.ImageIcon; import servertools.Consts; public abstract class MapContent { int width, height; boolean pixels; public abstract ImageIcon getIcon(); public MapContent(int width, int height, boolean inPixels) { //convert to tiles if possible if (width % Consts.tileWidth == 0 && height % Consts.tileWidth == 0) { //valid in tiles pixels = false; this.width = width / Consts.tileWidth; this.height = height / Consts.tileWidth; } else { this.width = width; this.height = height; this.pixels = true; } } public int getWidthPixels() { if (pixels) { return this.width; } else { return this.width * Consts.tileWidth; } } public int getHeightPixels() { if (pixels) { return this.height; } else { return this.height * Consts.tileWidth; } } public int getHeightTiles() { if (pixels) { return this.height / Consts.tileWidth; } else { return this.height; } } public int getWidthTiles() { if (pixels) { return this.width / Consts.tileWidth; } else { return this.width; } } protected void setHeight(int height) { this.height = height; } protected void setWidth(int width) { this.width = width; } public static boolean isValidMapObject(Object o) { if (o instanceof MapContent) { return true; } return false; } public abstract void paint(Graphics g, Map m); } |
Code: Show/Hide package servertools.map.tools; import java.awt.*; import java.awt.event.*; import servertools.map.*; import servertools.map.content.*; import javax.swing.*; public abstract class Tool { public String toolName; public abstract ImageIcon getIcon(); public abstract void paintTool(Graphics g); public abstract boolean onMouseEvent( MouseEvent e, Coordinate clicked, Map m, MapContent primary, MapContent secondary); public final boolean sendMouseEvent( MouseEvent e, Coordinate clicked, Map m, MapContent primary, MapContent secondary) { if (onMouseEvent(e, clicked, m, primary, secondary)) { return true; } else { return false; } } private boolean KEYMASK_ALT = false; private boolean KEYMASK_SHIFT = false; private boolean KEYMASK_CTRL = false; public Tool(String name) { this.toolName = name; } private final void setToolName(String n) { this.toolName = n; } public final String getToolName() { return this.toolName; } public final void onKeyEvent(KeyEvent e) { //alt if (e.getModifiers() == KeyEvent.ALT_DOWN_MASK) this.KEYMASK_ALT = true; else { this.KEYMASK_ALT = false; } //ctrl if (e.getModifiers() == KeyEvent.CTRL_DOWN_MASK) this.KEYMASK_CTRL = true; else { this.KEYMASK_CTRL = false; } //shift if (e.getModifiers() == KeyEvent.SHIFT_DOWN_MASK) this.KEYMASK_SHIFT = true; else { this.KEYMASK_SHIFT = false; } } public abstract Cursor getCursor(); } |
Cyan~Fire wrote: |
Ship rotating? Settings? This is gonna get a tad bulky... |