예제 #1
0
#!/usr/bin/env python2
from FlexiSurface import FlexiSurface
import pygame
import time

f = FlexiSurface(window_width=1920, window_height=1200)
img = pygame.image.load("../step1.gif").convert()

f.set_loading_screen()
time.sleep(5)
예제 #2
0
decoder = json.JSONDecoder()
encoder = json.JSONEncoder()


def write(data):
    sys.stdout.write(encoder.encode(data) + "\n")
    sys.stdout.flush()


def read():
    return decoder.decode(sys.stdin.readline())


write({"request": "config"})
conf = (read())["config"]
surface = FlexiSurface(conf["window_width"], conf["window_height"],
                       conf["fullscreen"])
surface.set_loading_screen()
write({"request": "games"})
games = (read())["games"]

fcntl.fcntl(sys.stdin, fcntl.F_SETFL, os.O_NONBLOCK)  # set stdin nonblocking
#time.sleep(1)
menu = Menu(surface, games)
write({"status": "ready"})
try:
    while 1:
        reply = menu.run_once()
        if reply != None:
            write(reply)
        try:
            json_obj = read()
예제 #3
0
def read():
    return decoder.decode(sys.stdin.readline())

title = sys.argv[1]
hs_file = sys.argv[2]
count = 0
args = sys.argv[3:]
for i in range(len(args)):
    args[i] = int(args[i])
    if args[i] > 0:
        count += 1

write({"request":"config"})
conf = read()["config"]
surface = FlexiSurface(conf["window_width"], conf["window_height"], conf["fullscreen"])
surface.set_loading_screen()

try:
    hiscores = json.load(open(hs_file))["scores"]
except:
    hiscores = []

hiscores.sort(key=lambda x: x[0], reverse=True)
font = pygame.font.Font("../libs/PressStart2P.ttf", 16)

def render_text(name, pos, done):
    w_sum = 0
    h_max = 0
    for t in name:
        w, h = font.size(t)