Skip to content

Commit

Permalink
Refactor texel generator code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nixinova committed Jul 21, 2024
1 parent bbe354c commit ae09618
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/com/nixinova/graphics/BlocksRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,14 @@ private void generateRenderedTexel(int pixel, PxCoord screenPos, BlockCoord bloc
int startY = (int) screenPos.y;
double zIndex = screenPos.z;

for (int x = 0; x < TEXEL_SIZE; x++) {
for (int y = 0; y < TEXEL_SIZE; y++) {
int screenX = startX + x - Texture.SIZE;
int screenY = startY + y - Texture.SIZE;

// Ensure pixel is within screen bounds
if (isValidPosition(screenX, screenY)) {
int brightAmount = (int) (Options.gamma * 10 * (Options.renderDistance - zIndex / 10));
int fogAppliedPixel = applyFog(pixel, brightAmount);
this.savePixel(screenX, screenY, fogAppliedPixel, zIndex);
}
// Apply fog to pixel
int brightAmount = (int) (Options.gamma * 10 * (Options.renderDistance - zIndex / 10));
int fogAppliedPixel = applyFog(pixel, brightAmount);

// Generate texel of given size and save o screen image
for (int x = startX; x < startX + TEXEL_SIZE && x < super.width; x++) {
for (int y = startY; y < startY + TEXEL_SIZE && y < super.height; y++) {
this.savePixel(x, y, fogAppliedPixel, zIndex);
}
}
}
Expand Down

0 comments on commit ae09618

Please sign in to comment.