import pygame from engine import * from engine.event import * from breakout_graphics import * from breakout_highscore import * ##from breakout_ingame import * import breakout_ingame ##from breakout_ingame import * <- VARFÖR FUNGERAR INTE DET HÄR?!?!?!?!?!?!?! class breakout_gameover(model.abstract_gamestate): def __init__(self, highscore): pygame.font.init() self.highscore = highscore misc.save(highscore, "highscore.lst") ## self.textlines = [] ## Draws a bunch of given lines of text. def draw_textlines(self, textlines, screen, pos): x,y = pos for line in textlines: misc.draw_text(line, 15, (0,0,0), screen, (x,y)) y += 20 ## Generates lines to draw from the current highscore list. def draw_highscore(self, screen, pos): text = [] scores = self.highscore.get(10) for highscore in scores: text.append(str(highscore.score)+" - "+\ highscore.name) self.draw_textlines(text, screen, pos) ## Calls everything that we want to draw. def draw(self, screen): misc.draw_text("Game over, dude!", 40, (0,0,0), screen, (150,100)) misc.draw_text("Highscore:", 20, (0,0,0), screen, (220, 190)) self.draw_highscore(screen, (220,220)) def key_pressed(self, key): if key == pygame.locals.K_SPACE: state = breakout_ingame.breakout_ingame() #state = breakout_ingame() state.set_highscore(self.highscore) self.set_state(state)