monkeyspank/monkeyspank
2019-12-05 20:00:26 -05:00

113 lines
3.7 KiB
Python
Executable File

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from libstormgames.libstormgames import *
# Initial variable settings
mode = "menu"
sounds = initialize_gui("Monkey Spank")
pygame.event.set_allowed(pygame.KEYDOWN)
pygame.mixer.set_reserved(1)
pygame.mixer.set_reserved(2)
def monkey_taunt():
t = pygame.mixer.Channel(1)
left = 1.0
right = 1.0
taunt = random.randrange(1, 4)
if taunt == 1: right = 0.0
if taunt == 3: left = 0.0
t.play(sounds['monkey-taunt'])
t.set_volume(left, right)
return taunt
def player_action(monkey, reaction):
if monkey != reaction: return True
global spanks
left = 0.7
right = 0.7
if reaction == 1: right = 0.0
if reaction == 3: left = 0.0
p = pygame.mixer.Channel(2)
p.play(sounds['spank-hit'])
p.set_volume(left, right)
spanks += 1
return False
def game(mode):
pygame.mixer.music.pause()
encourage = int(time.time())
lose = False
startTime = time.time()
totalTime = startTime
global spanks
cut_scene(sounds, 'start-game')
taunt = monkey_taunt()
timeOut = time.time()
while lose == False:
if time.time() - timeOut > 1:
lose = True
continue
event = pygame.event.poll()
if event.type == pygame.KEYDOWN:
# Escape is the back/exit key, close the game if not playing, or return to menu if playing.
if event.key == pygame.K_ESCAPE:
if mode != "menu":
mode = "menu"
return mode
elif mode == "menu": exit_game()
elif event.key == pygame.K_LEFT:
lose = player_action(taunt, 1)
if lose == True: continue
taunt = monkey_taunt()
timeOut = time.time()
elif event.key == pygame.K_DOWN:
lose = player_action(taunt, 2)
if lose == True: continue
taunt = monkey_taunt()
timeOut = time.time()
elif event.key == pygame.K_UP:
lose = player_action(taunt, 2)
if lose == True: continue
taunt = monkey_taunt()
timeOut = time.time()
elif event.key == pygame.K_RIGHT:
lose = player_action(taunt, 3)
if lose == True: continue
taunt = monkey_taunt()
timeOut = time.time()
pygame.event.clear()
totalTime = time.time()
if int(time.time()) - encourage == 8:
play_random(sounds, "encourage")
encourage = int(time.time())
pygame.event.pump()
time.sleep(0.001)
pygame.mixer.stop()
time.sleep(0.1)
pygame.event.clear()
play_random(sounds, "lose", interrupt = True)
message = ["You spanked the monkey " + str(spanks) + " "]
if spanks == 1: message[0] += "time."
if spanks != 1: message[0] += "times."
message.append("Your total time was " + str(round(totalTime - startTime, 2)) + " seconds.")
try:
message.append("You averaged " + str(round((totalTime - startTime) / spanks, 2)) + " monkey spanks per second.")
except:
message.append("You averaged 0.00 monkey spanks per second.")
time.sleep(0.1)
display_text(message)
return "menu"
# Game starts at main menu
mode = game_menu("start game", "instructions", "donate", "credits", "learn sounds", "exit_game")
while mode != "exit_game":
spanks = 0
if mode == "menu": mode = game_menu("start game", "instructions", "donate", "credits", "learn sounds", "exit_game")
if mode == "start game": mode = game(mode)
if mode == "learn sounds": mode = learn_sounds(sounds)
time.sleep(0.001)