Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to horizontally scroll entries #5

Merged
merged 14 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions src/client/java/minicraft/core/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private static void renderLevel() {
for (int y = 0; y < 28; y++)
for (int x = 0; x < 48; x++) {
// Creates the background for the sky (and dungeon) level:
screen.render(x * 8 - ((xScroll / 4) & 7), y * 8 - ((yScroll / 4) & 7), 0, 0, 0, cloud);
screen.render(null, x * 8 - ((xScroll / 4) & 7), y * 8 - ((yScroll / 4) & 7), 0, 0, 0, cloud);
}
}

Expand All @@ -227,7 +227,7 @@ private static void renderGui() {
// This draws the black square where the selected item would be if you were holding it
if (!isMode("minicraft.settings.mode.creative") || player.activeItem != null) {
for (int x = 10; x < 26; x++) {
screen.render(x * 8, Screen.h - 8, 5, 2, 0, hudSheet);
screen.render(null, x * 8, Screen.h - 8, 5, 2, 0, hudSheet);
}
}

Expand All @@ -243,11 +243,11 @@ private static void renderGui() {
int ac = player.getInventory().count(Items.arrowItem);
// "^" is an infinite symbol.
if (isMode("minicraft.settings.mode.creative") || ac >= 10000)
Font.drawBackground(" x" + "^", screen, 84, Screen.h - 16);
Font.drawBackground(null, " x" + "^", screen, 84, Screen.h - 16);
else
Font.drawBackground(" x" + ac, screen, 84, Screen.h - 16);
Font.drawBackground(null, " x" + ac, screen, 84, Screen.h - 16);
// Displays the arrow icon
screen.render(10 * 8 + 4, Screen.h - 16, 4, 1, 0, hudSheet);
screen.render(null, 10 * 8 + 4, Screen.h - 16, 4, 1, 0, hudSheet);
}
}

Expand Down Expand Up @@ -365,47 +365,47 @@ private static void renderGui() {
for (int i = 1; i <= 30; i++) {
// Renders your current red default hearts, golden hearts for 20 HP, obsidian hearts for 30 HP, or black hearts for damaged health.
if (i < 11) {
screen.render((i - 1) * 8, Screen.h - 16, 0, 1, 0, hudSheet); // Empty Hearts
screen.render(null, (i - 1) * 8, Screen.h - 16, 0, 1, 0, hudSheet); // Empty Hearts
}
if (i < player.health + 1 && i < 11) {
screen.render((i - 1) * 8, Screen.h - 16, 0, 0, 0, hudSheet); // Red Hearts
screen.render(null, (i - 1) * 8, Screen.h - 16, 0, 0, 0, hudSheet); // Red Hearts
}
if (i < player.health + 1 && i < 21 && i >= 11) {
screen.render((i - 11) * 8, Screen.h - 16, 0, 2, 0, hudSheet); // Yellow Hearts
screen.render(null, (i - 11) * 8, Screen.h - 16, 0, 2, 0, hudSheet); // Yellow Hearts
}
if (i < player.health + 1 && i >= 21) {
screen.render((i - 21) * 8, Screen.h - 16, 0, 3, 0, hudSheet); // Obsidian Hearts
screen.render(null, (i - 21) * 8, Screen.h - 16, 0, 3, 0, hudSheet); // Obsidian Hearts
}
}
for (int i = 0; i < Player.maxStat; i++) {

// Renders armor
int armor = player.armor * Player.maxStat / Player.maxArmor;
if (i <= armor && player.curArmor != null) {
screen.render(i * 8, Screen.h - 24, player.curArmor.sprite);
screen.render(null, i * 8, Screen.h - 24, player.curArmor.sprite);
}

if (player.staminaRechargeDelay > 0) {
// Creates the white/gray blinking effect when you run out of stamina.
if (player.staminaRechargeDelay / 4 % 2 == 0) {
screen.render(i * 8, Screen.h - 8, 1, 2, 0, hudSheet);
screen.render(null, i * 8, Screen.h - 8, 1, 2, 0, hudSheet);
} else {
screen.render(i * 8, Screen.h - 8, 1, 1, 0, hudSheet);
screen.render(null, i * 8, Screen.h - 8, 1, 1, 0, hudSheet);
}
} else {
// Renders your current stamina, and uncharged gray stamina.
if (i < player.stamina) {
screen.render(i * 8, Screen.h - 8, 1, 0, 0, hudSheet);
screen.render(null, i * 8, Screen.h - 8, 1, 0, 0, hudSheet);
} else {
screen.render(i * 8, Screen.h - 8, 1, 1, 0, hudSheet);
screen.render(null, i * 8, Screen.h - 8, 1, 1, 0, hudSheet);
}
}

// Renders hunger
if (i < player.hunger) {
screen.render(i * 8 + (Screen.w - 80), Screen.h - 16, 2, 0, 0, hudSheet);
screen.render(null, i * 8 + (Screen.w - 80), Screen.h - 16, 2, 0, 0, hudSheet);
} else {
screen.render(i * 8 + (Screen.w - 80), Screen.h - 16, 2, 1, 0, hudSheet);
screen.render(null, i * 8 + (Screen.w - 80), Screen.h - 16, 2, 1, 0, hudSheet);
}
}
}
Expand Down Expand Up @@ -440,20 +440,20 @@ public static void renderBossbar(int length, String title) {

MinicraftImage hudSheet = getHudSheet();

screen.render(x + (max_bar_length * 2), y, 0, INACTIVE_BOSSBAR, 1, hudSheet); // left corner
screen.render(null, x + (max_bar_length * 2), y, 0, INACTIVE_BOSSBAR, 1, hudSheet); // left corner

// The middle
for (int bx = 0; bx < max_bar_length; bx++) {
for (int by = 0; by < 1; by++) {
screen.render(x + bx * 2, y + by * 8, 3, INACTIVE_BOSSBAR, 0, hudSheet);
screen.render(null, x + bx * 2, y + by * 8, 3, INACTIVE_BOSSBAR, 0, hudSheet);
}
}

screen.render(x - 5, y, 0, ACTIVE_BOSSBAR, 0, hudSheet); // right corner
screen.render(null, x - 5, y, 0, ACTIVE_BOSSBAR, 0, hudSheet); // right corner

for (int bx = 0; bx < bar_length; bx++) {
for (int by = 0; by < 1; by++) {
screen.render(x + bx * 2, y + by * 8, 3, ACTIVE_BOSSBAR, 0, hudSheet);
screen.render(null, x + bx * 2, y + by * 8, 3, ACTIVE_BOSSBAR, 0, hudSheet);
}
}

Expand Down Expand Up @@ -556,24 +556,24 @@ private static void renderFocusNagger() {
MinicraftImage hudSheet = getHudSheet();

// Renders the four corners of the box
screen.render(xx - 8, yy - 8, 0, 6, 0, hudSheet);
screen.render(xx + w * 8, yy - 8, 0, 6, 1, hudSheet);
screen.render(xx - 8, yy + 8, 0, 6, 2, hudSheet);
screen.render(xx + w * 8, yy + 8, 0, 6, 3, hudSheet);
screen.render(null, xx - 8, yy - 8, 0, 6, 0, hudSheet);
screen.render(null, xx + w * 8, yy - 8, 0, 6, 1, hudSheet);
screen.render(null, xx - 8, yy + 8, 0, 6, 2, hudSheet);
screen.render(null, xx + w * 8, yy + 8, 0, 6, 3, hudSheet);

// Renders each part of the box...
for (int x = 0; x < w; x++) {
screen.render(xx + x * 8, yy - 8, 1, 6, 0, hudSheet); // ...Top part
screen.render(xx + x * 8, yy + 8, 1, 6, 2, hudSheet); // ...Bottom part
screen.render(null, xx + x * 8, yy - 8, 1, 6, 0, hudSheet); // ...Top part
screen.render(null, xx + x * 8, yy + 8, 1, 6, 2, hudSheet); // ...Bottom part
}
for (int y = 0; y < h; y++) {
screen.render(xx - 8, yy + y * 8, 2, 6, 0, hudSheet); // ...Left part
screen.render(xx + w * 8, yy + y * 8, 2, 6, 1, hudSheet); // ...Right part
screen.render(null, xx - 8, yy + y * 8, 2, 6, 0, hudSheet); // ...Left part
screen.render(null, xx + w * 8, yy + y * 8, 2, 6, 1, hudSheet); // ...Right part
}

// The middle
for (int x = 0; x < w; x++) {
screen.render(xx + x * 8, yy, 3, 6, 0, hudSheet);
screen.render(null, xx + x * 8, yy, 3, 6, 0, hudSheet);
}

// Renders the focus nagger text with a flash effect...
Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/entity/Arrow.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,6 @@ public boolean hurt(DamageSource source, Direction attackDir, int damage) {

@Override
public void render(Screen screen) {
screen.render(x - 4, y - 4, sprite);
screen.render(null, x - 4, y - 4, sprite);
}
}
4 changes: 2 additions & 2 deletions src/client/java/minicraft/entity/FireSpark.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public void render(Screen screen) {
int xt = 8;
int yt = 13;

screen.render(x - 4, y - 4 + 2, sprite.getSprite(), randmirror, false, Color.BLACK); // renders the shadow on the ground
screen.render(x - 4, y - 4 - 2, sprite.getSprite(), randmirror, false, Color.RED); // Renders the spark
screen.render(null, x - 4, y - 4 + 2, sprite.getSprite(), randmirror, false, Color.BLACK); // renders the shadow on the ground
screen.render(null, x - 4, y - 4 - 2, sprite.getSprite(), randmirror, false, Color.RED); // Renders the spark
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/client/java/minicraft/entity/ItemEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public void render(Screen screen) {
if (time / 6 % 2 == 0) return;
}

screen.render(x - 4, y - 4, item.sprite.getSprite(), 0, false, Color.get(0, 31)); // Item shadow
screen.render(x - 4, y - 4 - (int) zz, item.sprite); // Item
screen.render(null, x - 4, y - 4, item.sprite.getSprite(), 0, false, Color.get(0, 31)); // Item shadow
screen.render(null, x - 4, y - 4 - (int) zz, item.sprite); // Item
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/client/java/minicraft/entity/Spark.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void render(Screen screen) {
randmirror = random.nextInt(4);
}

screen.render(x - 4, y - 4 + 2, sprite.getSprite(), 0, false, Color.BLACK); // renders the shadow on the ground
screen.render(x - 4, y - 4 - 2, sprite.getSprite(), randmirror, false); // Renders the spark
screen.render(null, x - 4, y - 4 + 2, sprite.getSprite(), 0, false, Color.BLACK); // renders the shadow on the ground
screen.render(null, x - 4, y - 4 - 2, sprite.getSprite(), randmirror, false); // Renders the spark
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/entity/furniture/Furniture.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void tick() {
* Draws the furniture on the screen.
*/
public void render(Screen screen) {
screen.render(x - 8, y - 8, sprite);
screen.render(null, x - 8, y - 8, sprite);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/client/java/minicraft/entity/mob/MobAi.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public void render(Screen screen) {

SpriteLink curSprite = sprites[dir.getDir()][(walkDist >> 3) % sprites[dir.getDir()].length];
if (hurtTime > 0) {
screen.render(xo, yo, curSprite.getSprite(), true);
screen.render(null, xo, yo, curSprite.getSprite(), true);
} else {
screen.render(xo, yo, curSprite.getSprite());
screen.render(null, xo, yo, curSprite.getSprite());
}
}

Expand Down
64 changes: 32 additions & 32 deletions src/client/java/minicraft/entity/mob/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -812,32 +812,32 @@ public void render(Screen screen) {

// animation effect
if (tickTime / 8 % 2 == 0) {
screen.render(xo + 0, yo + 3, 5, 0, 0, hudSheet.get()); // Render the water graphic
screen.render(xo + 8, yo + 3, 5, 0, 1, hudSheet.get()); // Render the mirrored water graphic to the right.
screen.render(null, xo + 0, yo + 3, 5, 0, 0, hudSheet.get()); // Render the water graphic
screen.render(null, xo + 8, yo + 3, 5, 0, 1, hudSheet.get()); // Render the mirrored water graphic to the right.
} else {
screen.render(xo + 0, yo + 3, 5, 1, 0, hudSheet.get());
screen.render(xo + 8, yo + 3, 5, 1, 1, hudSheet.get());
screen.render(null, xo + 0, yo + 3, 5, 1, 0, hudSheet.get());
screen.render(null, xo + 8, yo + 3, 5, 1, 1, hudSheet.get());
}

} else if (level.getTile(x >> 4, y >> 4) == Tiles.get("lava")) {

if (tickTime / 8 % 2 == 0) {
screen.render(xo + 0, yo + 3, 6, 0, 1, hudSheet.get()); // Render the lava graphic
screen.render(xo + 8, yo + 3, 6, 0, 0, hudSheet.get()); // Render the mirrored lava graphic to the right.
screen.render(null, xo + 0, yo + 3, 6, 0, 1, hudSheet.get()); // Render the lava graphic
screen.render(null, xo + 8, yo + 3, 6, 0, 0, hudSheet.get()); // Render the mirrored lava graphic to the right.
} else {
screen.render(xo + 0, yo + 3, 6, 1, 1, hudSheet.get());
screen.render(xo + 8, yo + 3, 6, 1, 0, hudSheet.get());
screen.render(null, xo + 0, yo + 3, 6, 1, 1, hudSheet.get());
screen.render(null, xo + 8, yo + 3, 6, 1, 0, hudSheet.get());
}
}
}

// Renders indicator for what tile the item will be placed on
if (activeItem instanceof TileItem && !isSwimming()) {
Point t = getInteractionTile();
screen.render(t.x * 16, t.y * 16, 3, 2, 0, hudSheet.get());
screen.render(t.x * 16 + 8, t.y * 16, 3, 2, 1, hudSheet.get());
screen.render(t.x * 16, t.y * 16 + 8, 3, 2, 2, hudSheet.get());
screen.render(t.x * 16 + 8, t.y * 16 + 8, 3, 2, 3, hudSheet.get());
screen.render(null, t.x * 16, t.y * 16, 3, 2, 0, hudSheet.get());
screen.render(null, t.x * 16 + 8, t.y * 16, 3, 2, 1, hudSheet.get());
screen.render(null, t.x * 16, t.y * 16 + 8, 3, 2, 2, hudSheet.get());
screen.render(null, t.x * 16 + 8, t.y * 16 + 8, 3, 2, 3, hudSheet.get());
}

// Makes the player white if they have just gotten hurt
Expand All @@ -853,48 +853,48 @@ public void render(Screen screen) {
// This makes falling look really cool.
int spriteToUse = Math.round(onFallDelay / 2f) % carrySprites.length;
curSprite = carrySprites[spriteToUse][(walkDist >> 3) & 1];
screen.render(xo, yo - 4 * onFallDelay, curSprite.setColor(shirtColor));
screen.render(null, xo, yo - 4 * onFallDelay, curSprite.setColor(shirtColor));
} else {
curSprite = spriteSet[dir.getDir()][(walkDist >> 3) & 1]; // Gets the correct sprite to render.
// Render each corner of the sprite
if (isSwimming()) {
Sprite sprite = curSprite.getSprite();
screen.render(xo, yo, sprite.spritePixels[0][0], shirtColor);
screen.render(xo + 8, yo, sprite.spritePixels[0][1], shirtColor);
screen.render(null, xo, yo, sprite.spritePixels[0][0], shirtColor);
screen.render(null, xo + 8, yo, sprite.spritePixels[0][1], shirtColor);
} else { // Don't render the bottom half if swimming.
screen.render(xo, yo - 4 * onFallDelay, curSprite.setColor(shirtColor));
screen.render(null, xo, yo - 4 * onFallDelay, curSprite.setColor(shirtColor));
}
}

// Renders slashes:
if (attackTime > 0) {
switch (dir) {
case UP: // If currently attacking upwards...
screen.render(xo + 0, yo - 4, 3, 0, 0, hudSheet.get()); // Render left half-slash
screen.render(xo + 8, yo - 4, 3, 0, 1, hudSheet.get()); // Render right half-slash (mirror of left).
screen.render(null, xo + 0, yo - 4, 3, 0, 0, hudSheet.get()); // Render left half-slash
screen.render(null, xo + 8, yo - 4, 3, 0, 1, hudSheet.get()); // Render right half-slash (mirror of left).
if (activeItem != null) { // If the player had an item when they last attacked...
screen.render(xo + 4, yo - 4, activeItem.sprite.getSprite(), 1, false); // Then render the icon of the item, mirrored
screen.render(null, xo + 4, yo - 4, activeItem.sprite.getSprite(), 1, false); // Then render the icon of the item, mirrored
}
break;
case LEFT: // Attacking to the left... (Same as above)
screen.render(xo - 4, yo, 4, 0, 1, hudSheet.get());
screen.render(xo - 4, yo + 8, 4, 0, 3, hudSheet.get());
screen.render(null, xo - 4, yo, 4, 0, 1, hudSheet.get());
screen.render(null, xo - 4, yo + 8, 4, 0, 3, hudSheet.get());
if (activeItem != null) {
screen.render(xo - 4, yo + 4, activeItem.sprite.getSprite(), 1, false);
screen.render(null, xo - 4, yo + 4, activeItem.sprite.getSprite(), 1, false);
}
break;
case RIGHT: // Attacking to the right (Same as above)
screen.render(xo + 8 + 4, yo, 4, 0, 0, hudSheet.get());
screen.render(xo + 8 + 4, yo + 8, 4, 0, 2, hudSheet.get());
screen.render(null, xo + 8 + 4, yo, 4, 0, 0, hudSheet.get());
screen.render(null, xo + 8 + 4, yo + 8, 4, 0, 2, hudSheet.get());
if (activeItem != null) {
screen.render(xo + 8 + 4, yo + 4, activeItem.sprite.getSprite());
screen.render(null, xo + 8 + 4, yo + 4, activeItem.sprite.getSprite());
}
break;
case DOWN: // Attacking downwards (Same as above)
screen.render(xo + 0, yo + 8 + 4, 3, 0, 2, hudSheet.get());
screen.render(xo + 8, yo + 8 + 4, 3, 0, 3, hudSheet.get());
screen.render(null, xo + 0, yo + 8 + 4, 3, 0, 2, hudSheet.get());
screen.render(null, xo + 8, yo + 8 + 4, 3, 0, 3, hudSheet.get());
if (activeItem != null) {
screen.render(xo + 4, yo + 8 + 4, activeItem.sprite.getSprite());
screen.render(null, xo + 4, yo + 8 + 4, activeItem.sprite.getSprite());
}
break;
case NONE:
Expand All @@ -906,16 +906,16 @@ public void render(Screen screen) {
if (isFishing && activeItem != null) {
switch (dir) {
case UP:
screen.render(xo + 4, yo - 4, activeItem.sprite.getSprite(), 1, false);
screen.render(null, xo + 4, yo - 4, activeItem.sprite.getSprite(), 1, false);
break;
case LEFT:
screen.render(xo - 4, yo + 4, activeItem.sprite.getSprite(), 1, false);
screen.render(null, xo - 4, yo + 4, activeItem.sprite.getSprite(), 1, false);
break;
case RIGHT:
screen.render(xo + 8 + 4, yo + 4, activeItem.sprite.getSprite());
screen.render(null, xo + 8 + 4, yo + 4, activeItem.sprite.getSprite());
break;
case DOWN:
screen.render(xo + 4, yo + 8 + 4, activeItem.sprite.getSprite());
screen.render(null, xo + 4, yo + 8 + 4, activeItem.sprite.getSprite());
break;
case NONE:
break;
Expand Down
4 changes: 2 additions & 2 deletions src/client/java/minicraft/entity/mob/Sheep.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public void render(Screen screen) {

SpriteLink curSprite = curAnim[dir.getDir()][(walkDist >> 3) % curAnim[dir.getDir()].length];
if (hurtTime > 0) {
screen.render(xo, yo, curSprite.getSprite(), true);
screen.render(null, xo, yo, curSprite.getSprite(), true);
} else {
screen.render(xo, yo, curSprite);
screen.render(null, xo, yo, curSprite);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/java/minicraft/entity/particle/Particle.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void tick() {

@Override
public void render(Screen screen) {
screen.render(x, y, sprite);
screen.render(null, x, y, sprite);
}

@Override
Expand Down
Loading