Author: Reiner Herrmann <reiner@reiner-h.de> Description: Port to Python 3 Bug-Debian: https://bugs.debian.org/912498 --- a/freealchemist.py +++ b/freealchemist.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # FreeAlchemist (by Dak [dak.linux@gmail.com]) """ Copyright (C) 2008 Dak @@ -83,7 +83,7 @@ def newGame(self): - print "[*] New Game" + print("[*] New Game") self.lim = 3 self.over = False @@ -97,9 +97,9 @@ # Riempie la griglia self.grid = [] - for x in xrange(size_x): + for x in range(size_x): line = [] - for y in xrange(size_y): + for y in range(size_y): line.append(0) self.grid.append(line) @@ -109,7 +109,7 @@ self.nextblock = [[random.randint(1,self.lim),random.randint(1,self.lim)],[0,0]] self.blockpos = 0 - for x in xrange(2): + for x in range(2): line = [0,0] self.blockgrid.append(line) @@ -132,13 +132,13 @@ def updateGame(self): # Controlla se ci son spazi vuoti da riempire md = False - for x in xrange(len(self.grid)-1,-1,-1): - for y in xrange(0, len(self.grid[0])): + for x in range(len(self.grid)-1,-1,-1): + for y in range(0, len(self.grid[0])): s = 0 - for a in xrange(len(self.grid)): s += self.grid[a][y] + for a in range(len(self.grid)): s += self.grid[a][y] if self.grid[x][y] == 0 and s > 0: - for a in xrange(x, 0, -1): + for a in range(x, 0, -1): if self.grid[a-1][y] != 0: self.grid[a][y] = self.grid[a-1][y] self.grid[a-1][y] = 0 @@ -147,8 +147,8 @@ # Controlliamo se possiamo far esplodere qualcosa :P if not self.mov: - for x in xrange(0,len(self.grid)): - for y in xrange(0,len(self.grid[0])): + for x in range(0,len(self.grid)): + for y in range(0,len(self.grid[0])): # La pressa if self.grid[x][y] == 15 and x == len(self.grid)-2: self.grid[len(self.grid)-2][y] = 0 @@ -235,10 +235,10 @@ # Renderizza il punteggio text = self.font.render(str(self.points), 1, (255, 255, 255)) - self.screen.blit(text, (15,50)) + self.screen.blit(text, (15,50)) - text = self.font.render(str(int(self.time)/60)+" min", 1, (255, 255, 255)) - self.screen.blit(text, (15,25)) + text = self.font.render(str(int(self.time)//60)+" min", 1, (255, 255, 255)) + self.screen.blit(text, (15,25)) @@ -255,8 +255,8 @@ # Renderizza tutta la griglia - for x in xrange(len(self.grid)): - for y in xrange(len(self.grid[0])): + for x in range(len(self.grid)): + for y in range(len(self.grid[0])): if self.grid[x][y] != 0: self.screen.blit(self.p[self.grid[x][y]-1], ((106+y*40),(25+x*40))) @@ -264,7 +264,7 @@ #pygame.time.delay(100) def exitGame(self): - print "[*] Exit" + print("[*] Exit") sys.exit() @@ -334,11 +334,11 @@ self.blockgrid[0][0] = -1 if event.key == K_PAUSE or event.key == K_ESCAPE or event.key == K_p: - print "[*] Pause" + print("[*] Pause") pause = 1 self.screen.blit(self.gameover, (0, 0)) - self.screen.blit(pygame.font.Font(None, 36).render("Pause", 1, (255, 255, 255)), (20,20)) + self.screen.blit(pygame.font.Font(None, 36).render("Pause", 1, (255, 255, 255)), (20,20)) self.screen.blit(pygame.font.Font(None, 24).render("Press any key", 1, (255, 255, 255)), (416-120,400-20)) pygame.display.update() @@ -360,11 +360,11 @@ def start(self): # Presentazione iniziale intro = 0 - print "[*] FreeAlchemist" + print("[*] FreeAlchemist") self.screen.blit(self.background, (0, 0)) self.screen.blit(self.gameover, (0, 0)) - self.screen.blit(pygame.font.Font(None, 36).render(__program__+" "+__version__, 1, (255, 255, 255)), (20,20)) + self.screen.blit(pygame.font.Font(None, 36).render(__program__+" "+__version__, 1, (255, 255, 255)), (20,20)) self.screen.blit(self.p[0], (40, 50)) self.screen.blit(self.p[1], (88, 50)) @@ -384,8 +384,8 @@ self.screen.blit(pygame.font.Font(None, 24).render("Press any key", 1, (255, 255, 255)), (416-120,400-20)) - self.screen.blit(pygame.font.Font(None, 22).render("Coded by "+__author__+" under "+__license__+" license", 1, (255, 255, 255)), (48,220)) - self.screen.blit(pygame.font.Font(None, 22).render("http://inventati.org/dak "+__email__, 1, (255, 255, 255)), (48,240)) + self.screen.blit(pygame.font.Font(None, 22).render("Coded by "+__author__+" under "+__license__+" license", 1, (255, 255, 255)), (48,220)) + self.screen.blit(pygame.font.Font(None, 22).render("http://inventati.org/dak "+__email__, 1, (255, 255, 255)), (48,240)) pygame.display.update() @@ -420,10 +420,10 @@ # Finito il gioco, visualizza il punteggio e attende restart = 0 - print "[*] Game Over" + print("[*] Game Over") self.screen.blit(self.gameover, (0, 0)) - self.screen.blit(pygame.font.Font(None, 36).render("Game Over!", 1, (255, 255, 255)), (20,20)) + self.screen.blit(pygame.font.Font(None, 36).render("Game Over!", 1, (255, 255, 255)), (20,20)) self.screen.blit(pygame.font.Font(None, 24).render("Press any key", 1, (255, 255, 255)), (416-120,400-20)) pygame.display.update()