Countdown to Christmas Makes Challenge 2017 – Day 11

Animated Rudolph Pixel Art

Programed in Python for the Raspberry Pi version of Minecraft

Cool little pixel art animation project programmed in Python for the Raspberry Pi version of Minecraft.

Python Code

# 17x20 Pixel Art Rudolph
# by @KariLawler (Twitter), 11/Dec/17, v1.0
from mcpi.minecraft import Minecraft
import time
mc = Minecraft.create()

# no block = -1, white = 0, orange = 1, magenta = 2, light blue = 3,
# yellow = 4, lime = 5, pink = 6, grey = 7, light grey = 8,
# cyan = 9, purple = 10, blue = 11, brown = 12, green = 13, red = 14, black = 15

frame1 = [
	[-1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1],
	[15, 15, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 15, 15],
	[-1, 15, 15, 15, 15, -1, -1, -1, -1, -1, -1, -1, 15, 15, 15, 15, -1],
	[-1, -1, -1, 15, 15, -1, -1, -1, -1, -1, -1, -1, 15, 15, -1, -1, -1],
	[-1, -1, -1, -1, 15, 15, -1, -1, -1, -1, -1, 15, 15, -1, -1, -1, -1],
	[-1, -1, -1, -1, 15, 15, 12, 12, 12, 12, 12, 15, 15, -1, -1, -1, -1],
	[-1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1, -1],
	[12, 12, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, 12, 12],
	[ 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  1],
	[-1,  1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  1, -1],
	[-1, -1, 12,  0, 15, 12, 12, 14, 14, 14, 12, 12, 15,  0, 12, -1, -1],
	[-1, -1, 12, 15, 15, 12, 14, 14,  0,  0, 14, 12, 15, 15, 12, -1, -1],
	[-1, -1, -1, 12, 12, 12, 14, 14, 14, 14, 14, 12, 12, 12, -1, -1, -1],
	[-1, -1, 12, 12, 12, 12, 12, 14, 14, 14, 12, 12, 12, 12, 12, -1, -1],
	[-1, 12, 12, 12, 12,  1,  1,  1, 15,  1,  1,  1, 12, 12, 12, 12, -1],
	[-1, 12, 12, 12,  1,  1,  1,  1, 15,  1,  1,  1,  1, 12, 12, 12, -1],
	[-1, 12, 12, 12,  1,  1,  1, 15, 15, 15,  1,  1,  1, 12, 12, 12, -1],
	[-1, 12, 12, 12, 12,  1,  1,  1,  1,  1,  1,  1, 12, 12, 12, 12, -1],
	[-1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1],
	[-1, -1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1, -1, -1]
]

frame2 = [
	[-1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1],
	[15, 15, -1, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, 15, 15],
	[-1, 15, 15, 15, 15, -1, -1, -1, -1, -1, -1, -1, 15, 15, 15, 15, -1],
	[-1, -1, -1, 15, 15, -1, -1, -1, -1, -1, -1, -1, 15, 15, -1, -1, -1],
	[-1, -1, -1, -1, 15, 15, -1, -1, -1, -1, -1, 15, 15, -1, -1, -1, -1],
	[-1, -1, -1, -1, 15, 15, 12, 12, 12, 12, 12, 15, 15, -1, -1, -1, -1],
	[-1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1, -1],
	[12, 12, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, 12, 12],
	[ 1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  1],
	[-1,  1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,  1, -1],
	[-1, -1, 12,  0, 15, 12, 12,  6,  6,  6, 12, 12, 15,  0, 12, -1, -1],
	[-1, -1, 12, 15, 15, 12,  6,  6,  0,  0,  6, 12, 15, 15, 12, -1, -1],
	[-1, -1, -1, 12, 12, 12,  6,  6,  6,  6,  6, 12, 12, 12, -1, -1, -1],
	[-1, -1, 12, 12, 12, 12, 12,  6,  6,  6, 12, 12, 12, 12, 12, -1, -1],
	[-1, 12, 12, 12, 12,  1,  1,  1, 15,  1,  1,  1, 12, 12, 12, 12, -1],
	[-1, 12, 12, 12,  1,  1,  1,  1, 15,  1,  1,  1,  1, 12, 12, 12, -1],
	[-1, 12, 12, 12,  1,  1,  1, 15, 15, 15,  1,  1,  1, 12, 12, 12, -1],
	[-1, 12, 12, 12, 12,  1,  1,  1,  1,  1,  1,  1, 12, 12, 12, 12, -1],
	[-1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1],
	[-1, -1, -1, -1, 12, 12, 12, 12, 12, 12, 12, 12, 12, -1, -1, -1, -1]
]

# animate function
def animate(x, y, z, frame):
	pixel_y = y + len(frame) - 1
	pixel_z = z - 6
	for row in frame:
		pixel_x = x
		for pixel in row:
			if pixel > -1:
				mc.setBlock(pixel_x, pixel_y, pixel_z, 35, pixel) # block 35 = wool
			pixel_x += 1
		pixel_y -= 1
	time.sleep(0.500) # pause time between frames in milliseconds

# get players current coordinates
player_x, player_y, player_z = mc.player.getPos()

# animation loop
while True:
	animate(player_x, player_y, player_z, frame1)
	animate(player_x, player_y, player_z, frame2)

One Comment

Leave a Reply