本文整理汇总了Java中de.dakror.gamesetup.GameFrame类的典型用法代码示例。如果您正苦于以下问题:Java GameFrame类的具体用法?Java GameFrame怎么用?Java GameFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameFrame类属于de.dakror.gamesetup包,在下文中一共展示了GameFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawTooltip
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void drawTooltip(int x, int y, Graphics2D g) {
if (!(Game.currentGame.getActiveLayer() instanceof WorldHUDLayer)) return;
String tooltip = type.getDescription();
String timer = "Dauer: " + Assistant.formatSeconds(timeleft);
int width = g.getFontMetrics(g.getFont().deriveFont(30f)).stringWidth(tooltip) + 35;
int w2 = g.getFontMetrics(g.getFont().deriveFont(27f)).stringWidth(timer) + 35;
width = w2 > width ? w2 : width;
ArrayList<Resource> filled = value.getFilled();
int height = 90 + filled.size() * 30;
int x1 = x;
int y1 = y - 80;
if (x1 + width > Game.getWidth()) x1 -= (x1 + width) - GameFrame.getWidth();
if (y1 + height > Game.getHeight()) y1 -= (y1 + height) - GameFrame.getHeight();
Helper.drawShadow(x1, y1, width, height, g);
Helper.drawString(tooltip, x1 + 15, y1 + 40, g, 30);
Helper.drawString(timer, x1 + 20, y1 + 70, g, 27);
for (int i = 0; i < filled.size(); i++) {
Assistant.drawResource(value, filled.get(i), x1 + 20, y1 + 80 + i * 30, 25, 30, g);
}
}
示例2: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
AffineTransform old = g.getTransform();
AffineTransform at = g.getTransform();
at.translate(x, y);
g.setTransform(at);
for (int i = 0; i < Math.ceil(width / (float) CHUNKSIZE); i++)
for (int j = 0; j < Math.ceil(height / (float) CHUNKSIZE); j++)
if (new Rectangle(0, 0, Game.getWidth(), Game.getHeight()).intersects(new Rectangle(minX + i * CHUNKSIZE + x, minY + j * CHUNKSIZE + y, CHUNKSIZE, CHUNKSIZE)))
g.drawImage(chunk, minX + i * CHUNKSIZE, minY + j * CHUNKSIZE, null);
Component hovered = null;
for (Component c : components) {
if (!new Rectangle(0, 0, Game.getWidth(), Game.getHeight()).intersects(new Rectangle(c.getX() + x, c.getY() + y, c.getWidth(), c.getHeight()))) continue;
c.draw(g);
if (c.state == 2) hovered = c;
}
if (hovered != null) hovered.drawTooltip(GameFrame.currentFrame.mouse.x, GameFrame.currentFrame.mouse.y, g);
g.setTransform(old);
}
示例3: drawTooltip
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void drawTooltip(int x, int y, Graphics2D g) {
int width = 150;
int height = TroopType.values().length * 30 + 70;
int x1 = x;
int y1 = y;
if (x1 + width > GameFrame.getWidth()) x1 -= (x1 + width) - GameFrame.getWidth();
if (y1 + height > GameFrame.getHeight()) y1 -= (y1 + height) - GameFrame.getHeight();
Helper.drawShadow(x1, y1, width, height, g);
Helper.drawString("Truppen", x1 + 20, y1 + 40, g, 35);
for (int i = 0; i < TroopType.values().length; i++) {
Resource r = TroopType.values()[i].getType();
Assistant.drawResource(CityLayer.resources, r, x1 + 20, y1 + i * 30 + 50, 30, 30, g);
}
}
示例4: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
g.drawImage(cache, 0, 0, null);
if (selectedBuilding != null) {
int width = 300, height = 200;
Helper.drawContainer(Game.getWidth() - width, Game.getHeight() - height, width, height, true, false, g);
}
Component hovered = null;
for (Component c : components) {
c.draw(g);
if (c.state == 2) hovered = c;
}
if (selectedBuilding != null) selectedBuilding.getGuiContainer().draw(g);
if (hovered != null && Game.currentGame.getActiveLayer() instanceof CityHUDLayer) hovered.drawTooltip(GameFrame.currentFrame.mouse.x, GameFrame.currentFrame.mouse.y, g);
}
示例5: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
int ty = state == 0 ? 124 : (state == 1 ? 202 : 280);
if (toggle) {
ty = selected ? 202 : 124;
}
if (!enabled) ty = 358;
Helper.drawImage(GameFrame.getImage("gui/gui.png"), x, y, width, height, 12, ty, WIDTH, HEIGHT, g);
Color c = g.getColor();
if (!enabled) g.setColor(Color.gray);
else g.setColor(Color.white);
if (toggle && selected) g.setColor(Color.decode("#7cde6a"));
Helper.drawHorizontallyCenteredString(text, x, width, y + height / 2 + shiftY, g, size);
g.setColor(c);
}
示例6: drawContainer
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
public static void drawContainer(int x, int y, int width, int height, boolean doubled, boolean wood, boolean shadow, Graphics2D g) {
if (shadow) drawShadow(x - 10, y - 10, width + 20, height + 20, g);
Image image = GameFrame.getImage(wood ? "gui/wood.png" : "gui/paper.png");
Shape oldClip = g.getClip();
g.setClip(x, y, width, height);
for (int i = x; i < x + width; i += 512) {
for (int j = y; j < y + height; j += 512) {
g.drawImage(image, i, j, GameFrame.w);
}
}
g.setClip(oldClip);
drawOutline(x, y, width, height, doubled, g);
}
示例7: drawProgressBar
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
/**
* @param percent 0 - 1
*/
public static void drawProgressBar(int x, int y, int width, float percent, String color, Graphics2D g) {
Image filling = GameFrame.getImage("gui/bar/Bar-" + color + ".png");
Image base = GameFrame.getImage("gui/bar/BarBase.png");
drawImage(base, x, y, 6, 23, 0, 0, 6, 23, g);
drawImage(base, x + width - 6, y, 6, 23, 7, 0, 6, 23, g);
for (int i = x + 6; i < x + width - 6; i++)
drawImage(base, i, y, 1, 23, 6, 0, 1, 23, g);
int fillWidth = (int) ((width - 12) * percent);
if (percent > 0) drawImage(filling, x, y, 6, 23, 0, 0, 6, 23, g);
if (percent == 1) drawImage(filling, x + width - 6, y, 6, 23, 7, 0, 6, 23, g);
for (int i = x + 6; i < x + 6 + fillWidth; i++)
drawImage(filling, i, y, 1, 23, 6, 0, 1, 23, g);
}
示例8: init
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void init() {
TextButton cnc = new TextButton(GameFrame.getWidth() / 2 - TextButton.WIDTH, (GameFrame.getHeight() - height) / 2 + height - 15 - TextButton.HEIGHT, "Abbruch");
if (eventNo != null) cnc.addClickEvent(eventNo);
cnc.addClickEvent(new ClickEvent() {
@Override
public void trigger() {
GameFrame.currentFrame.removeLayer(Confirm.this);
}
});
components.add(cnc);
TextButton ok = new TextButton(GameFrame.getWidth() / 2, (GameFrame.getHeight() - height) / 2 + height - 15 - TextButton.HEIGHT, "Ok");
if (eventYes != null) ok.addClickEvent(eventYes);
ok.addClickEvent(new ClickEvent() {
@Override
public void trigger() {
GameFrame.currentFrame.removeLayer(Confirm.this);
}
});
components.add(ok);
}
示例9: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
drawModality(g);
Helper.drawContainer(GameFrame.getWidth() / 2 - 310, Game.getHeight() / 2 - 125, 620, 250, true, false, g);
Helper.drawHorizontallyCenteredString("Bezahlung", Game.getWidth(), Game.getHeight() / 2 - 75, g, 40);
Helper.drawHorizontallyCenteredString("Das Bauen deiner Waffe kostet", Game.getWidth(), Game.getHeight() / 2 - 50, g, 20);
Color c = g.getColor();
if (Game.money >= costs) g.setColor(Color.darkGray);
else g.setColor(Color.decode("#660a0a"));
Helper.drawHorizontallyCenteredString(costs == 0 ? "Nichts" : costs + "$", Game.getWidth(), Game.getHeight() / 2 + 20, g, 80);
g.setColor(c);
drawComponents(g);
}
示例10: drawTooltip
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void drawTooltip(int x, int y, Graphics2D g) {
int width = g.getFontMetrics(g.getFont().deriveFont(30f)).stringWidth(r.getName()) + 30;
int height = 64;
int x1 = x;
int y1 = y;
if (x1 + width > GameFrame.getWidth()) x1 -= (x1 + width) - GameFrame.getWidth();
if (y1 + height > GameFrame.getHeight()) y1 -= (y1 + height) - GameFrame.getHeight();
Helper.drawShadow(x1, y1, width, height, g);
Helper.drawString(r.getName(), x1 + 15, y1 + 40, g, 30);
}
示例11: drawBuildingStage
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
public static void drawBuildingStage(int x, int y, Building b, Graphics2D g) {
BufferedImage tile = GameFrame.getImage("world/buildingStage.png");
int width = b.bw * 32;
int height = b.bh * 32;
int size = 32;
Helper.drawImage(tile, x, y, size, size, 0, 0, size, size, g); // lt
Helper.drawImage(tile, x + width - size, y, size, size, size * 2, 0, size, size, g); // rt
Helper.drawImage(tile, x, y + height - size, size, size, 0, size * 2, size, size, g); // lb
Helper.drawImage(tile, x + width - size, y + height - size, size, size, size * 2, size * 2, size, size, g); // rb
for (int i = size; i <= width - size * 2; i += size)
Helper.drawImage(tile, x + i, y, size, size, size, 0, size, size, g);// t
for (int i = size; i <= width - size * 2; i += size)
Helper.drawImage(tile, x + i, y + height - size, size, size, size, size * 2, size, size, g); // b
for (int i = size; i <= height - size * 2; i += size)
Helper.drawImage(tile, x, y + i, size, size, 0, size, size, size, g); // l
for (int i = size; i <= height - size * 2; i += size)
Helper.drawImage(tile, x + width - size, y + i, size, size, size * 2, size, size, size, g); // r
for (int i = size; i <= width - size * 2; i += size)
for (int j = size; j <= height - size * 2; j += size)
Helper.drawImage(tile, x + i, y + j, size, size, size, size, size, size, g); // m
}
示例12: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
Image img = GameFrame.getImage("gui/gui.png");
if (horizontal) {
Helper.drawImage2(img, x, y, 7, height, 794, 72, 7, 20, g);
Helper.drawImage2(img, x + width - 7, y, 7, height, 994, 72, 7, 20, g);
for (int i = 0; i < (width - 14) / 193; i++)
Helper.drawImage2(img, x + 7 + i * 193, y, 193, height, 801, 72, 193, 20, g);
Helper.drawImage2(img, x + 7 + (width - 14) / 193 * 193, y, (width - 14) % 193, height, 801, 72, (width - 14) % 193, 20, g);
if (enabled) Helper.drawImage2(img, (int) (x + sliderPos - 5), y - (38 - height) / 2, 20, 35, 889, 16, 25, 44, g);
} else {
AffineTransform old = g.getTransform();
AffineTransform at = g.getTransform();
at.rotate(Math.toRadians(90), x + HEIGHT / 2, y + HEIGHT / 2);
g.setTransform(at);
Helper.drawImage2(img, x, y, 7, width, 794, 72, 7, 20, g);
Helper.drawImage2(img, x + height - 7, y, 7, width, 994, 72, 7, 20, g);
for (int i = 0; i < (height - 14) / 193; i++)
Helper.drawImage2(img, x + 7 + i * 193, y, 193, width, 801, 72, 193, 20, g);
Helper.drawImage2(img, x + 7 + (height - 14) / 193 * 193, y, (height - 14) % 193, width, 801, 72, (height - 14) % 193, 20, g);
if (enabled) Helper.drawImage2(img, (int) (x + sliderPos - 5), y - (38 - width) / 2, 20, 35, 889, 16, 25, 44, g);
g.setTransform(old);
}
String displayString = ((title != null) ? title + ": " : "") + ((integerMode) ? (value) + "" : value);
if (customTitles.containsKey(value)) displayString = customTitles.get(value);
Helper.drawHorizontallyCenteredString(displayString, x, width, y - 5, g, 30);
}
示例13: draw
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void draw(Graphics2D g) {
int tx = 138;
if (state == 2) tx = 183;
if (!enabled) tx = 228;
Helper.drawImage(GameFrame.getImage("gui/gui.png"), x, y, width, height, tx, selected ? 47 : 3, WIDTH, HEIGHT, g);
}
示例14: drawComponents
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
protected void drawComponents(Graphics2D g) {
Component hovered = null;
for (Component c : components) {
c.draw(g);
if (c.state == 2) hovered = c;
}
if (hovered != null) hovered.drawTooltip(GameFrame.currentFrame.mouse.x, GameFrame.currentFrame.mouse.y, g);
}
示例15: drawTooltip
import de.dakror.gamesetup.GameFrame; //导入依赖的package包/类
@Override
public void drawTooltip(int x, int y, Graphics2D g) {
if (tooltip != null) {
int width = g.getFontMetrics(g.getFont().deriveFont(30f)).stringWidth(tooltip) + 30;
int height = 64;
int x1 = x;
int y1 = y;
if (x1 + width > GameFrame.getWidth()) x1 -= (x1 + width) - GameFrame.getWidth();
if (y1 + height > GameFrame.getHeight()) y1 -= (y1 + height) - GameFrame.getHeight();
Helper.drawShadow(x1, y1, g.getFontMetrics(g.getFont().deriveFont(30f)).stringWidth(tooltip) + 30, height, g);
Helper.drawString(tooltip, x1 + 15, y1 + 40, g, 30);
}
}