Skip to content

Commit

Permalink
Fix parameter order of calls to GuiGraphics.blit
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Oct 22, 2024
1 parent d2d472b commit 4ac68b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float tickDelta
}

public void blitSprite(GuiGraphics graphics, Vector2i uv, int x, int y, int width, int height) {
graphics.blit(RenderType::guiTextured, MINESWEEPER_ATLAS, topLeftX + x, topLeftY + y, width, height, uv.x, uv.y, width, height, MINESWEEPER_ATLAS_WIDTH, MINESWEEPER_ATLAS_HEIGHT);
graphics.blit(RenderType::guiTextured, MINESWEEPER_ATLAS, topLeftX + x, topLeftY + y, uv.x, uv.y, width, height, MINESWEEPER_ATLAS_WIDTH, MINESWEEPER_ATLAS_HEIGHT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class SnakeGameScreen extends Screen {

private static final Random random = new Random();

private static final int BOARD_SIZE = 289;
private static final int MAX_X = 16;
private static final int MAX_Y = 16;

Expand Down Expand Up @@ -84,14 +85,14 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
@Override
public void renderBackground(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
super.renderBackground(graphics, mouseX, mouseY, delta);
int startX = (this.width - 289) / 2;
int startY = (this.height - 289) / 2;
int startX = (this.width - BOARD_SIZE) / 2;
int startY = (this.height - BOARD_SIZE) / 2;

graphics.drawString(minecraft.font, this.title, startX, startY - 10, 0xff_ffffff);
MutableComponent score = Component.translatable("snakeGame.score", this.snake.size());
graphics.drawCenteredString(minecraft.font, score, this.width / 2, startY - 10, 0xff_ffffff);

graphics.blit(RenderType::guiTextured, GRID_TEXTURE, startX, startY, 0, 0, 289, 289, 289, 289);
graphics.blit(RenderType::guiTextured, GRID_TEXTURE, startX, startY, 0, 0, BOARD_SIZE, BOARD_SIZE, BOARD_SIZE, BOARD_SIZE);
int scaleX = MAX_X + 1;
int scaleY = MAX_Y + 1;
graphics.fill(startX + this.apple.x() * scaleX, startY + this.apple.y() * scaleY, startX + this.apple.x() * scaleX + scaleX, startY + this.apple.y() * scaleY + scaleY, 0xff_f52559);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void renderBackground(GuiGraphics guiGraphics, int mouseX, int mouseY, fl
guiGraphics.drawString(this.font, this.title, startX, startY - 20, 0xff_ffffff);
guiGraphics.drawString(this.font, Component.translatable("ticTacToeGame.playingWith", this.game.yourMarks.name), startX, startY - 10, 0xff_ffffff);

guiGraphics.blit(RenderType::guiTextured, GRID_TEXTURE, startX, startY, GRID_SIZE, GRID_SIZE, 0, 0, GRID_SIZE_TEXTURE, GRID_SIZE_TEXTURE, GRID_SIZE_TEXTURE, GRID_SIZE_TEXTURE);
guiGraphics.blit(RenderType::guiTextured, GRID_TEXTURE, startX, startY, 0, 0, GRID_SIZE, GRID_SIZE, GRID_SIZE_TEXTURE, GRID_SIZE_TEXTURE);
TicTacToeGame.Mark[][] board = this.game.board;

for (byte x = 0; x < 3; x++) {
Expand Down

0 comments on commit 4ac68b8

Please sign in to comment.