0

Iprove tall-grass looking. Draw the sprite in the correct angle, and draw it at a random offset (as done in game).

This commit is contained in:
Alejandro Aguilera
2011-06-08 12:01:38 +02:00
parent bc51e6745f
commit 71d8da5f83
2 changed files with 16 additions and 3 deletions

View File

@@ -125,12 +125,18 @@ rendermode_normal_occluded(void *data, RenderState *state) {
static void
rendermode_normal_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
RenderModeNormal *self = (RenderModeNormal *)data;
int randx = 0,randy = 0;
/* first, check to see if we should use biome-compatible src, mask */
if (self->biome_data) {
if (state->block == 18) {
src = mask = self->leaf_texture;
} else if (state->block == 31) {
/* add a random offset to the postion of the tall grass to make it more wild */
randx = rand() % 6 + 1 - 3;
randy = rand() % 6 + 1 - 3;
state->imgx = state->imgx + randx;
state->imgy = state->imgy + randy;
unsigned char data = getArrayByte3D(state->blockdata_expanded, state->x, state->y, state->z);
if (data == 1) {
src = mask = self->tall_grass_texture;

View File

@@ -236,7 +236,8 @@ def _build_block(top, side, blockID=None):
"""
img = Image.new("RGBA", (24,24), (38,92,255,0))
original_texture = top.copy()
top = transform_image(top, blockID)
if not side:
@@ -256,8 +257,15 @@ def _build_block(top, side, blockID=None):
otherside = ImageEnhance.Brightness(otherside).enhance(0.8)
otherside.putalpha(othersidealpha)
## special case for tall-grass, fern and dead shrub, they are the only sprite-blocks
## that have the sprites in the diagonal of the block
if blockID in (31,32):
front = original_texture.resize((14,11), Image.ANTIALIAS)
composite.alpha_over(img, front, (5,9))
return img
## special case for non-block things
if blockID in (31,32,37,38,6,39,40,83,30): ## tall grass, dead shrubs, flowers, sapling, mushrooms, reeds, web
if blockID in (37,38,6,39,40,83,30): ## flowers, sapling, mushrooms, reeds, web
#
# instead of pasting these blocks at the cube edges, place them in the middle:
# and omit the top
@@ -265,7 +273,6 @@ def _build_block(top, side, blockID=None):
composite.alpha_over(img, otherside, (6,3), otherside)
return img
if blockID in (81,): # cacti!
composite.alpha_over(img, side, (1,6), side)
composite.alpha_over(img, otherside, (11,6), otherside)