Toggle Navigation
Hatchery
Eggs
Mario Bross animation
main.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
main.py
raw
Content
import display import math import utime mario1 = [0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0xffcc66, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0xffcc66, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0x4f4f4f, 0x4f4f4f, 0x4f4f4f, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0x336699, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0x336699, 0xcc0000, 0xcc0000, 0x336699, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x336699, 0x336699, 0x336699, 0x336699, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xcc0000, 0x336699, 0xffff33, 0x336699, 0x336699, 0xffff33, 0x336699, 0xcc0000, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000] mario2 = [0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0xffcc66, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0xffcc66, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0x4f4f4f, 0x4f4f4f, 0x4f4f4f, 0x4f4f4f, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0xffcc66, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x336699, 0x336699, 0xcc0000, 0xcc0000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xcc0000, 0xcc0000, 0xcc0000, 0xcc0000, 0x336699, 0x336699, 0x336699, 0xcc0000, 0xcc0000, 0xcc0000, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0x000000, 0xffffff, 0xffffff, 0xffffff, 0x000000, 0xcc0000, 0xcc0000, 0x336699, 0xffff33, 0x336699, 0x336699, 0x336699, 0xcc0000, 0xcc0000, 0xffffff, 0xffffff, 0x000000, 0x000000, 0xffffff, 0xffffff, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x333333, 0x333333, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x336699, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x336699, 0x336699, 0x336699, 0x000000, 0x000000, 0x000000, 0x336699, 0x336699, 0x336699, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x663300, 0x663300, 0x663300, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000] def print_sprite(pic, pic_x, pic_y, multiplier, offset_x, offset_y): with display.open() as disp: disp.clear() for r_y in range(pic_y*multiplier): for r_x in range(pic_x*multiplier): if (r_x + offset_x < 160) and (r_x + offset_x > 0) and (r_y + offset_y < 80) and (r_y + offset_y > 0): disp.pixel(x=offset_x +r_x, y=offset_y + r_y, col=((pic[pic_y*math.floor(r_y/multiplier) + math.floor(r_x/multiplier)] & 0xFF0000) >> 16, (pic[pic_y*math.floor(r_y/multiplier) + math.floor(r_x/ multiplier)] & 0x00FF00) >> 8 , pic[pic_y*math.floor(r_y/multiplier) + math.floor(r_x/multiplier)] & 0x0000FF)) disp.update() disp.close() while(True): for x in range(-17*4, 300, 20): print_sprite(mario1, 17, 17, 4, offset_y=0, offset_x=x) utime.sleep_us(5) print_sprite(mario2, 17, 17, 4, offset_y=0, offset_x=x) utime.sleep_us(5)