Created
July 24, 2023 15:32
-
-
Save syxanash/4ac65b8d6cb817fb3aafae0c6e85a36a to your computer and use it in GitHub Desktop.
DVD bouncing logo for Thumby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import thumby | |
import random | |
bitmap0 = bytearray([0,0,0,247,247,247,7,7,15,31,127,255,247,15,127,252,240,0,0,240,252,63,63,247,247,247,7,7,7,15,30,62,252,240,0,0, | |
0,0,0,63,63,63,56,56,56,60,30,31,7,0,0,0,7,126,252,127,7,0,0,63,63,63,56,56,56,60,30,30,7,3,0,0, | |
16,56,56,124,124,124,254,254,254,254,255,255,255,239,239,199,199,199,199,199,199,239,239,255,255,255,254,254,254,254,254,254,124,56,56,16, | |
0,0,12,16,32,16,12,0,0,0,0,61,1,1,1,1,1,61,37,25,1,1,1,1,1,61,44,36,0,0,0,24,36,36,24,0]) | |
sprite_width = 36 | |
sprite_height = 30 | |
dvdSprite = thumby.Sprite(sprite_width, sprite_height, bitmap0) | |
thumby.display.setFPS(30) | |
x_direction_forward = True | |
y_direction_forward = True | |
while(1): | |
thumby.display.fill(0) | |
if x_direction_forward: | |
dvdSprite.x = dvdSprite.x + 1 | |
else: | |
dvdSprite.x = dvdSprite.x - 1 | |
if y_direction_forward: | |
dvdSprite.y = dvdSprite.y + 1 | |
else: | |
dvdSprite.y = dvdSprite.y - 1 | |
if (dvdSprite.x + sprite_width) >= thumby.display.width and x_direction_forward: | |
x_direction_forward = False | |
thumby.display.brightness(random.randint(10,127)) | |
elif dvdSprite.x <= 0 and not x_direction_forward: | |
x_direction_forward = True | |
thumby.display.brightness(random.randint(10,127)) | |
if (dvdSprite.y + sprite_height) >= thumby.display.height and y_direction_forward: | |
y_direction_forward = False | |
thumby.display.brightness(random.randint(10,127)) | |
elif dvdSprite.y <= 0 and not y_direction_forward: | |
y_direction_forward = True | |
thumby.display.brightness(random.randint(10,127)) | |
thumby.display.drawSprite(dvdSprite) | |
thumby.display.update() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://hachyderm.io/@syx/110769784381595992