Skip to content

Commit

Permalink
Moved, added and improved Font sprites
Browse files Browse the repository at this point in the history
Changes:
* Moved the font sprites to "icons.png"
* Added support chars for cp437
* Now you can set the style of the bossbar

Bug fixes
- Fixed a bug that erroneously displayed the corresponding armor icon in the player's Hud
  • Loading branch information
TheBigEye committed Jun 12, 2022
1 parent 5ae4e1c commit 5d32b0a
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 27 deletions.
13 changes: 8 additions & 5 deletions src/main/java/minicraft/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Objects;
import java.util.Random;
import javax.imageio.ImageIO;
import minicraft.core.io.Settings;
import minicraft.entity.furniture.Bed;
import minicraft.entity.mob.Player;
import minicraft.entity.mob.boss.AirWizard;
Expand Down Expand Up @@ -223,7 +224,7 @@ private static void renderLevel() {
// Brightens all
int brightnessMultiplier = player.potioneffects.containsKey(PotionType.Light) ? 12 : 8;
level.renderLight(lightScreen, xScroll, yScroll, brightnessMultiplier); // Finds (and renders) all the light from objects (like the player, lanterns, and lava).
screen.Blind(lightScreen, currentLevel, xScroll, yScroll);
screen.darkness(lightScreen, currentLevel, xScroll, yScroll);
}
}

Expand Down Expand Up @@ -266,7 +267,7 @@ private static void renderGui() {
}

if (isMode("creative") || ac >= 10000) {
Font.drawTransparentBackground(" x" + "Ω", screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
Font.drawTransparentBackground(" x" + "", screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
} else {
Font.drawTransparentBackground(" x" + ac, screen, 184 - player.activeItem.arrAdjusted, Screen.h - 24);
}
Expand Down Expand Up @@ -492,9 +493,11 @@ else if (Updater.scoreTime >= 3600) {
renderRain(); // last layer
// AirWizard bossbar
if (currentLevel == 4 && isMode("survival")) {
if (!AirWizard.beaten) renderBossbar(AirWizard.length, "Air wizard");
else if (!AirWizardPhase2.beaten) renderBossbar(AirWizardPhase2.length, "Phase II");
else if (!AirWizardPhase3.beaten) renderBossbar(AirWizardPhase3.length, "Phase III");
if (Settings.get("bossbar").equals("On screen")) {
if (!AirWizard.beaten) renderBossbar(AirWizard.length, "Air wizard");
else if (!AirWizardPhase2.beaten) renderBossbar(AirWizardPhase2.length, "Phase II");
else if (!AirWizardPhase3.beaten) renderBossbar(AirWizardPhase3.length, "Phase III");
}
}
renderDebugInfo(); // top layer
}
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/minicraft/entity/mob/boss/AirWizard.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import minicraft.core.Game;
import minicraft.core.Updater;
import minicraft.core.io.Settings;
import minicraft.core.io.Sound;
import minicraft.entity.Direction;
import minicraft.entity.Entity;
Expand Down Expand Up @@ -183,10 +184,17 @@ public void render(Screen screen) {
}

int textwidth = Font.textWidth(h);
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);

//Font.drawBar(screen, (x - Screen.w / 12 + 4), y - 24, length / 4, "testificate");
// Bossbar on the the Air wizard
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 4), y - 24, length / 4, "testificate");
}

// Bossbar percent
if (Settings.get("bossbar").equals("Percent")) {
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);
}
}

@Override
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/minicraft/entity/mob/boss/AirWizardPhase2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import minicraft.core.Game;
import minicraft.core.Updater;
import minicraft.core.io.Settings;
import minicraft.core.io.Sound;
import minicraft.entity.Direction;
import minicraft.entity.Entity;
Expand Down Expand Up @@ -206,8 +207,17 @@ public void render(Screen screen) {
}

int textwidth = Font.textWidth(h);
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);

// Bossbar on the the Air wizard phase 2
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 4), y - 24, length / 4, "testificate");
}

// Bossbar percent
if (Settings.get("bossbar").equals("Percent")) {
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);
}
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/minicraft/entity/mob/boss/AirWizardPhase3.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,16 @@ public void render(Screen screen) {
}

int textwidth = Font.textWidth(h);
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);
// Bossbar on the the Air wizard phase 3
if (Settings.get("bossbar").equals("On entity")) {
Font.drawBar(screen, (x - Screen.w / 12 + 4), y - 24, length / 4, "testificate");
}

// Bossbar percent
if (Settings.get("bossbar").equals("Percent")) {
Font.draw(h, screen, (x - textwidth / 2) + 1, y - 17, textcol2);
Font.draw(h, screen, (x - textwidth / 2), y - 18, textcol);
}
}

@Override
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/minicraft/gfx/Font.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
import minicraft.core.io.Localization;

public class Font {

private static final int CHAR_SHEET_Y = 2;

// These are all the characters that will be translated to the screen. (The spaces and the UTF8 incoding are important)
private static final String chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ012345" +
"6789.,!?'\"-+=/\\%()<>:;Ω@ÁÉÍÓÚÑ¿¡" +
"ÃÊÇÔÕĞÇÜİÖŞÆØÅŰŐ[]#|{}_&^~$* А" +
" !\"#$%&'()*+,-./0123456789:;<=>?" +
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" +
"`abcdefghijklmnopqrstuvwxyz{|}~∞" +
"ÇÜÉÂÄÀÅÇÊËÈÏÎÌÄÅÉæÆÔÖÒÛÙŸÖÜ¢£¥₧Ƒ" +
"ÁÍÓÚñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐" +
"└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀" +
"αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■А" +
"БВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";

/*
Expand All @@ -29,7 +36,7 @@ public static void draw(String msg, Screen screen, int x, int y, int whiteTint)
int ix = chars.indexOf(msg.charAt(i)); // the current letter in the message loop
if (ix >= 0) {
// if that character's position is larger than or equal to 0, then render the character on the screen.
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + 28 * 32, 0, 3, whiteTint);
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + CHAR_SHEET_Y * 32, 0, 4, whiteTint);
}
}
}
Expand Down Expand Up @@ -75,7 +82,7 @@ public static void drawBackground(String msg, Screen screen, int x, int y, int w
// render the black background
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, 12 + 24 * 32, 0, 3);

screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + 28 * 32, 0, 3, whiteTint);
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + CHAR_SHEET_Y * 32, 0, 4, whiteTint);
}
}
}
Expand All @@ -92,7 +99,7 @@ public static void drawTransparentBackground(String msg, Screen screen, int x, i
// render the black background
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, 13 + 24 * 32, 0, 3);
if (ix >= 0) {
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + 28 * 32, 0, 3, whiteTint);
screen.render(x + i * textWidth(msg.substring(i, i + 1)), y, ix + CHAR_SHEET_Y * 32, 0, 4, whiteTint);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/gfx/Screen.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public void overlay(Screen screen, int currentLevel, int xa, int ya) {
}
}

public void Blind(Screen screen, int currentLevel, int xa, int ya) {
public void darkness(Screen screen, int currentLevel, int xa, int ya) {

double tintFactor = 0;
if (currentLevel >= 3 && currentLevel < 5) {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/minicraft/item/ArmorItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package minicraft.item;

import java.util.ArrayList;

import minicraft.entity.Direction;
import minicraft.entity.mob.Player;
import minicraft.gfx.Sprite;
Expand All @@ -13,13 +12,17 @@ public class ArmorItem extends StackableItem {
protected static ArrayList<Item> getAllInstances() {
ArrayList<Item> items = new ArrayList<>();

/*
* level is considerated the sprite x axis for the amor bar satus, from 1 to 7
*/
items.add(new ArmorItem("Leather Armor", new Sprite(0, 9, 0), .3f, 1));
items.add(new ArmorItem("Snake Armor", new Sprite(1, 9, 0), .4f, 2));
items.add(new ArmorItem("ChainMail Armor", new Sprite(6, 9, 0), .4f, 3));
items.add(new ArmorItem("ChainMail Armor", new Sprite(6, 9, 0), .4f, 7));
items.add(new ArmorItem("Iron Armor", new Sprite(2, 9, 0), .5f, 3));
items.add(new ArmorItem("Gold Armor", new Sprite(3, 9, 0), .7f, 4));
items.add(new ArmorItem("Gem Armor", new Sprite(4, 9, 0), 1f, 5));

// Useless for now...
items.add(new ArmorItem("Prot I Armor", new Sprite(5, 9, 0), .1f, 6));
items.add(new ArmorItem("Prot II Armor", new Sprite(5, 9, 0), .1f, 6));
items.add(new ArmorItem("Prot III Armor", new Sprite(5, 9, 0), .1f, 6));
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/minicraft/item/BoatItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ public BoatItem(String name) {
}

public boolean interactOn(Tile tile, Level level, int xt, int yt, Player player, Direction attackDir) {
if (level.getTile(xt, yt).id == 6) {
if (level.getTile(xt, yt).id == 6) { // if are on water
Boat boat = new Boat();

boat.x = xt * 16 + 8;
boat.y = yt * 16 + 8;
level.add(boat);
if (Game.isMode("creative"))
if (Game.isMode("creative")) {
boat = boat.clone();
else
} else {
placed = true;
}

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/minicraft/screen/TitleDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public TitleDisplay() {
Game.setDisplay(new Display(true, new Menu.Builder(false, 2, RelPos.CENTER,
new SelectEntry("Load World", () -> Game.setDisplay(new WorldSelectDisplay())),
new SelectEntry("New World", () -> Game.setDisplay(new WorldGenDisplay()))
)
.createMenu()
)
.createMenu()
));
} else {
Game.setDisplay(new WorldGenDisplay());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/minicraft/screen/entry/RecipeEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public void render(Screen screen, int x, int y, boolean isSelected) {

@Override
public String toString() {
return super.toString().replace("1 ", "") + (recipe.getAmount() > 1 ? " x" + recipe.getAmount() : "");
return " " + recipe.getProduct().getName() + (recipe.getAmount() > 1 ? " X" + recipe.getAmount() : "");
}
}
Binary file modified src/main/resources/Minicraft_Splash_Screen_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/Minicraft_Splash_Screen_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/Minicraft_Splash_Screen_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/Legacy/entities.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/Legacy/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/Legacy/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/Legacy/items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/Legacy/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/entities.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/items.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/resources/textures/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d32b0a

Please sign in to comment.