omnitrix-app/functions.py

35 lines
1 KiB
Python
Raw Normal View History

2021-04-28 00:07:15 -04:00
from aliens import *
from PIL import ImageTk, Image
2021-05-03 19:25:36 -04:00
from boombox import BoomBox
2021-04-30 01:53:48 -04:00
counter = 0
2021-05-02 00:23:48 -04:00
# determans which image is shown
2021-04-30 01:53:48 -04:00
2021-05-03 17:30:47 -04:00
def alien_select(index, omnitrix_button):
BoomBox("res/sound_switch.mp3").play()
2021-04-27 22:40:29 -04:00
global counter
2021-05-03 17:30:47 -04:00
counter += index
path = image_display(abs(counter))
img = ImageTk.PhotoImage(Image.open(path))
omnitrix_button.configure(image=img)
2021-05-03 17:30:47 -04:00
omnitrix_button.image = img # keep a reference
# controls how much up or down the list you go
2021-04-27 22:40:29 -04:00
def button_press():
2021-05-03 19:25:36 -04:00
BoomBox("res/sound_transformation.mp3").play()
2021-05-02 00:23:48 -04:00
# whenever the "middle_button" button is pressed play sound effect
2021-05-01 19:11:47 -04:00
2021-05-01 23:58:10 -04:00
def start():
2021-05-03 19:25:36 -04:00
BoomBox("res/sound_startup.mp3").play()
2021-05-02 00:23:48 -04:00
# when program first starts up, plays sound effect
def image_display(index):
alien = alien_table(index)
if(alien == 0):
global counter
counter = 0
return "res/Omnitrix.png"
else:
image_location = "res/" + alien + ".png"
return image_location
2021-05-03 19:25:36 -04:00
# if the next alien does not exists, resets counter, else returns image location