#!/usr/bin/env python #-*- coding:utf-8 -*- import os,sys import pygame import txtlib from pygame.locals import * from constants import * class HighScore(): def loadscores(self): items = [] file = open('score.dat','r') for line in file.readlines(): temp = line.split('\t') items.append((int(temp[1].strip()), (temp[0]))) file.close() return items def numeric_compare(self, x, y): if x[0]>y[0]: return 1 elif x[0]==y[0]: if x[2] 90: newstuffs = 65 return chr(newstuffs) def MoveCharDown(self, char): newstuffs = ord(char) - 1 if newstuffs < 65: newstuffs = 90 return chr(newstuffs) def __init__(self): self.thefont = pygame.font.Font(os.path.join('fonts', 'ice_sticks.ttf'), 18) self.titlefont = pygame.font.Font(os.path.join('fonts', 'ice_sticks.ttf'), 35) self.scores = self.loadscores() def mainHighScores(self): screen = pygame.display.set_mode(screen_size) items = self.loadscores() self.savescores(items) sal = "" for score, name in items[:5]: sal += name + "\t" + str(score) + "\n" print sal text = txtlib.Text((screen_size[0]-200,screen_size[1]-200), './fonts/ice_sticks.ttf') text.text = '''Esquiador \nPuntajes mas altos:\n''' + sal text.add_style(0, 600, txtlib.SIZE, (screen_size[0]*25)/800) text.update() screen.blit(text.area, (100, 100)) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == pygame.QUIT: exit(0) if event.type == KEYDOWN: if event.key == K_ESCAPE: return