satoshinm / NetCraft

Web-based fork of fogleman/Craft ⛺
https://satoshinm.github.io/NetCraft/
MIT License
57 stars 13 forks source link

Add block break animation texture. Closes GH-106 #115

Closed satoshinm closed 7 years ago

satoshinm commented 7 years ago

https://github.com/satoshinm/NetCraft/issues/106

screen shot 2017-05-11 at 8 40 46 pm
satoshinm commented 7 years ago

There is already code to write "signs" = text on any block face, reusing it the block completion percentage is visible:

screen shot 2017-05-10 at 9 53 24 pm

but this really ought to be a custom break animation texture, not text.

satoshinm commented 7 years ago

Perhaps easier, what about basing it on the wireframe code (draws around the targeted block), but change to render textured faces, the textures being the block break animation?

satoshinm commented 7 years ago

Rendering a textured cube over the mining target block works well, added what I call render_cover() (since it covers the block) to do this, now the only complication is getting the right block break textures and ensuring they are transparent so the original block texture underneath shows through.


gen_cube_buffer() takes w, the block type, passes to make_cube in cube.c, this indexes into item.c blocks[][] which is an array of arrays of texture indices per block. The faces are in a different order than I expected, see https://github.com/satoshinm/NetCraft/issues/116 - but won't matter for block break animation since all the faces could be the same. Call make_cube_faces with given texture indices instead of make_cube?

satoshinm commented 7 years ago

Now all that's left to do is the ten block break textures. But Paintbrush rewrites the magenta background somehow:

texture

looks the same, but after resaving without changing anything, Craft doesn't recognize it as the magenta it uses for transparent:

screen shot 2017-05-11 at 8 24 16 pm

need a better image editor. Preview doesn't mangle the colors, but it also has limited editing abilities.