# EG5-12 Snaps get_string function import snaps name = snaps.get_string('Enter your name: ') snaps.display_message('Hello ' + name)
import snaps snaps.display_image('themepark.png') prompt = '''These are the available rides 1: Scenic River Cruise 2: Carnival Carousel 3: Jungle Adventure Water Splash 4: Downhill Mountain Run 5: The Regurgitator Select your ride: ''' ride_number_text = snaps.get_string(prompt, vert='bottom', max_line_length=3) confirm = 'Ride ' + ride_number_text snaps.display_message(confirm)
import snaps import time import random import pygame counter_max = int(input('Max Number of Directions (Min is 2): ')) #min_delay=int(input('Min Delay: ')) #max_delay=int(input('Max Delay: ')) background = 'background.jpg' snaps.setup(width=1280, height=720, title='Shipwreck') snaps.display_image(background) snaps.get_string('To Begin Press ', cursor='ENTER') snaps.display_image(background) pygame.mixer.Sound.play(pygame.mixer.Sound('Pacman_Introduction_Music.wav')) time.sleep(4.5) prev_command = 0 loopy = True tone = pygame.mixer.Sound('A-Tone.wav') bell = pygame.mixer.Sound('Ship_bell.wav') crash = pygame.mixer.Sound('Crash_Large.wav') while loopy: counter = 0 command_num = random.randint(2, counter_max) while counter <= command_num: command = random.randint(1, 6) pygame.mixer.init()
#Based on digital clock from b2cd import time import snaps import pygame cursor_char='_' # Sets up window; requests format snaps.setup(width=850, height=300, title='CLOCK WITH CHIME') time_format=snaps.get_string('24 or 12 hr format: ',cursor='_') flag=isinstance(time_format,str) while flag: try: integer_check=int(time_format) except ValueError: time_format=snaps.get_string('Input must be an integer\n\nTry Again: ') continue if int(time_format) != 12 and int(time_format) !=24: time_format=snaps.get_string('Invalid input\nMust be 12 or 24\n\nTry Again: ') continue flag=False #Loop ensures input is 12 or 24 in integer format sound_var=pygame.mixer.Sound('Sniper_Fire_Reload-Mike_Koenig-1309646991.wav') ding_dong=pygame.mixer.Sound('chime_big_ben_mod.wav') ding_dong.set_volume(0.7) #Creates sound objects for effects; if time_format == '24': while True:
input_validate = True #rloop while initialize_var: while input_validate: c1 = random.randint(0, 255) c2 = random.randint(0, 255) c3 = random.randint(0, 255) length_check = True format_check = True time_input = snaps.get_string( 'Enter timer length as integers. (ss or mm:ss) ', size=40, margin=10, color=(c1, c2, c3), horiz='left', vert='bottom', cursor='_') time_array = str.split(time_input, ':') i = 0 while i < len(time_array): try: int(time_array[i]) int_check = True i = i + 1 except ValueError: int_check = False if int_check == False: snaps.display_message(