top of page
  • Writer's pictureThe Arithmancer

Controlling Animations in Python

Updated: Oct 21, 2019

To play animations, remember that we have rotated the screen by 90 degrees for the mirror. Make sure that any animations you use are also rotated 90 degrees.


I have used two animations for my talking mirror. One is a ghostified animation of my sister which works well for Harry Potter as it is Moaning Mirtle-esque. (You can make your own using Photoshop)


[Insert Myriam animation]

(If enough people ask, I might put up a tutorial on how I did this)


or for Lord of the Rings fans, I like Eerie Eyes from AtmosFX. My favourite is the Dragon eyes or the Fiery Eyes as they remind me of Sauron.


My dad and I also set up the mirror so that if asked "Mirror Mirror on the Wall", you get this awesome animation from NightFrights




Installation

import os
import pygame

Python:

Another important point is that one first has to cover the screen in black so that none of the pi background is visible. This can be done with the following code:



def SetUpScreen(debug):
    screen = pygame.display.set_mode((1000, 700), pygame.RESIZABLE) 
    if debug==0:
         screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
         pygame.mouse.set_visible(0)
    return screen
 



Next is a function that calls and plays the animation:


def playFile(filename):
    AnimCommand="omxplayer /home/pi/Videos/" 
    os.system(AnimCommand+filename) 
 
 

def SetUpScreen(debug):
    screen = pygame.display.set_mode((1000, 700), pygame.RESIZABLE) 
    if debug==0:
         screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
         pygame.mouse.set_visible(0)
    return screen
 
 
 
 
 
 
 
 

Python:


58 views0 comments

Recent Posts

See All

Comentarios


bottom of page