import pygame
# Import the android module. If we can't import it, set it to None - this
# lets us test it, and check to see if we want android-specific behavior.
try:
import android
except ImportError:
android = None
def main():
pygame.init()
# Set the screen size.
screen = pygame.display.set_mode((480, 800))
# Map the back button to the escape key.
if android:
android.init()
android.map_key(android.KEYCODE_BACK, pygame.K_ESCAPE)
if android:
yum = android.mixer.Sound("yum.wav")
yum.play
else:
pygame.mixer.init()
yum = pygame.mixer.Sound("yum.wav")
yum.play
while True:
ev = pygame.event.wait()
# Android-specific:
if android:
droid = android.Android()
if android.check_pause():
android.wait_for_resume()
# When the user hits back, ESCAPE is sent. Handle it and end
# the game.
elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_ESCAPE:
break
# This isn't run on Android.
if __name__ == "__main__":
main()