Search code examples
javaanimationbufferedimage

How does notch do animation in MiniCraft?


I looked through the source code of notch's 48 hour game Minicraft trying to find out how he does animation. By animation I mean like walking animations with different images. I looked through the code for about 30 minutes and I couldn't find anything to do with image animation.

Could someone please help me because I really want to know how he does it because it will definitely be helpful for me in the future.

Link to source: https://s3.amazonaws.com/ld48/ld22/minicraft_source.zip


Solution

  • He is reading the resource image where he drew all the animation frames in a grid, he is cutting each frame and puts it in one bitmap array, resulting in an array of animation frames, and then according to the direction and type of animation he needs to do, he is just looping through the frames in the array and rendering the according frame on the canvas.