Control: tags -1 + patch Hi,
the attached patch ports solarwolf to Python 3. Kind regards, Reiner
diff --git a/debian/control b/debian/control index 43843c0..3cd495f 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,13 @@ Source: solarwolf Section: games Priority: optional Maintainer: Josselin Mouette <j...@debian.org> -Build-Depends-Indep: python-all, dh-python +Build-Depends-Indep: python3, dh-python Build-Depends: debhelper (>= 10) Standards-Version: 3.7.2 Package: solarwolf Architecture: all -Depends: python-pygame (>= 1.5.6), ${misc:Depends}, ${python:Depends} +Depends: python3-pygame (>= 1.5.6), ${misc:Depends}, ${python3:Depends} Description: Collect the boxes and don't become mad Solarwolf is an action/arcade game written entirely in Python, featuring amazing graphics and cool music. diff --git a/debian/rules b/debian/rules index 1bdb3e2..e684204 100755 --- a/debian/rules +++ b/debian/rules @@ -41,7 +41,7 @@ binary-indep: build install dh_installchangelogs dh_compress dh_fixperms - dh_python2 + dh_python3 dh_installdeb dh_gencontrol dh_md5sums diff --git a/solarwolf.py b/solarwolf.py index 98d4207..66428ec 100755 --- a/solarwolf.py +++ b/solarwolf.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Solarwolf, created by Pete Shinners. """ @@ -39,8 +39,8 @@ def main(): import game if game.DEBUG >= 2: import pychecker.checker - print 'Pychecker Enabled' - except ImportError, m: + print('Pychecker Enabled') + except ImportError as m: pass #run game and protect from exceptions @@ -48,14 +48,14 @@ def main(): import main, pygame main.main(sys.argv) except KeyboardInterrupt: - print 'Keyboard Interrupt (Control-C)...' + print('Keyboard Interrupt (Control-C)...') except: #must wait on any threading if game.thread: game.threadstop = 1 while game.thread: pygame.time.wait(10) - print 'waiting on thread...' + print('waiting on thread...') exception_handler() if game.DEBUG: raise diff --git a/code/game.py b/code/game.py index 5af66c2..2fd8177 100644 --- a/code/game.py +++ b/code/game.py @@ -2,7 +2,7 @@ import os from pygame.rect import Rect -from cStringIO import StringIO +from io import StringIO @@ -105,7 +105,7 @@ def make_dataname(filename): home = os.environ['HOME'] fullhome = os.path.join(home, '.solarwolf') if not os.path.isdir(fullhome): - try: os.mkdir(fullhome, 0755) + try: os.mkdir(fullhome, 0o755) except OSError: fullhome = home filename = os.path.join(fullhome, filename) else: diff --git a/code/gamehelp.py b/code/gamehelp.py index 3db27d8..e55b42b 100644 --- a/code/gamehelp.py +++ b/code/gamehelp.py @@ -128,7 +128,7 @@ QuickHelp = { def help(helpname, helppos): - if not game.player.help.has_key(helpname): + if helpname not in game.player.help: game.player.help[helpname] = 1 if game.help == 0: game.handler = GameHelp(game.handler, helpname, helppos) @@ -179,7 +179,7 @@ class GameHelp: def drawhelp(self, name, pos): - if Help.has_key(name): + if name in Help: text = Help[name] lines = text.splitlines() for x in range(1, len(lines)): @@ -193,7 +193,7 @@ class GameHelp: self.img = fonts[0].textbox((255, 240, 200), text, 260, (50, 100, 50), 30) r = self.img.get_rect() - titleimg, titlepos = fonts[1].text((255, 240, 200), title, (r.width/2, 10)) + titleimg, titlepos = fonts[1].text((255, 240, 200), title, (r.width//2, 10)) self.img.blit(titleimg, titlepos) r.topleft = pos r = r.clamp(game.arena) diff --git a/code/gamename.py b/code/gamename.py index 4611e01..d48f9d7 100644 --- a/code/gamename.py +++ b/code/gamename.py @@ -13,7 +13,7 @@ import gamecreds import gamenews -charset = string.uppercase + '-.' +charset = string.ascii_uppercase + '-.' fontlookup = {} fontimages = [] images = [] @@ -35,8 +35,8 @@ def load_game_resources(): xsize, ysize = 70, 80 step = 0 for letter in charset + '<>': - pos = xoffset+xsize*(step%10), yoffset+ysize*(step/10) - if extraimgs.has_key(letter): + pos = xoffset+xsize*(step%10), yoffset+ysize*(step//10) + if letter in extraimgs: img = img2 = extraimgs[letter] r = img.get_rect() r.center = pos diff --git a/code/gamenews.py b/code/gamenews.py index 456dc18..867c3c7 100644 --- a/code/gamenews.py +++ b/code/gamenews.py @@ -32,7 +32,7 @@ def load_game_resources(): images.append((img, r)) img = gfx.load('download.png') - downimgs = gfx.animstrip(img, img.get_width()/2) + downimgs = gfx.animstrip(img, img.get_width()//2) for i in ('downerror', 'newversion', 'downok'): img = gfx.load(i+'.gif') downimgs.append(img) @@ -302,7 +302,7 @@ class GameNews: if self.downcur == 3: img = self.downimgs[2] else: - self.downcur = (self.clocks / 8) % 2 + 1 + self.downcur = (self.clocks // 8) % 2 + 1 img = self.downimgs[self.downcur-1] return img, img.get_rect().move(self.downloadpos) diff --git a/code/gamepause.py b/code/gamepause.py index f127901..f3eac98 100644 --- a/code/gamepause.py +++ b/code/gamepause.py @@ -30,7 +30,7 @@ class GamePause(gamehelp.GameHelp): self.img = fonts[0].textbox((255, 240, 200), text, 200, (50, 100, 50), 50) r = self.img.get_rect() - titleimg, titlepos = fonts[1].text((255, 240, 200), title, (r.width/2, 10)) + titleimg, titlepos = fonts[1].text((255, 240, 200), title, (r.width//2, 10)) self.img.blit(titleimg, titlepos) r.topleft = pos r = r.clamp(game.arena) diff --git a/code/gamepref.py b/code/gamepref.py index 7d474ef..df1ca1c 100644 --- a/code/gamepref.py +++ b/code/gamepref.py @@ -39,7 +39,7 @@ def save_prefs(): val = getattr(game, p) f.write("%s = %d\n" % (p, int(val))) f.close() - except (IOError, OSError), msg: + except (IOError, OSError) as msg: #print 'ERROR SAVING PREFS FILE' pass diff --git a/code/gamesetup.py b/code/gamesetup.py index 414f727..ea3e842 100644 --- a/code/gamesetup.py +++ b/code/gamesetup.py @@ -80,13 +80,13 @@ class GameSetup: def moveto(self, pos): if self.shipdir == SHIPUP: - self.shippos = pos[0] - (self.images[0][1].width / 2), pos[1] + self.shippos = pos[0] - (self.images[0][1].width // 2), pos[1] elif self.shipdir == SHIPDOWN: - self.shippos = pos[0] - (self.images[0][1].width / 2), pos[1] - self.images[0][1].height + self.shippos = pos[0] - (self.images[0][1].width // 2), pos[1] - self.images[0][1].height elif self.shipdir == SHIPRIGHT: - self.shippos = pos[0] - self.images[0][1].width, pos[1] - (self.images[0][1].height / 2) + self.shippos = pos[0] - self.images[0][1].width, pos[1] - (self.images[0][1].height // 2) else: - self.shippos == pos[0], pos[1] - (self.images[0][1].height / 2) + self.shippos == pos[0], pos[1] - (self.images[0][1].height // 2) def displayevent(self, i): if i.normalized != None: @@ -152,7 +152,7 @@ class GameSetup: def selectall(self): snd.play('select_choose') self.clearactionlist() - if not input.translations.has_key(NOEVENT): + if NOEVENT not in input.translations: input.translations[NOEVENT] = {} input.translations[NOEVENT][KEYDOWN] = input.actions_order[self.currentaction] input.translations[NOEVENT][JOYBUTTONDOWN] = input.actions_order[self.currentaction] @@ -205,13 +205,13 @@ class GameSetup: if currentcontrol < len(self.display[input.actions_order[self.currentaction]]): self.currentcontrol = currentcontrol elif i.translated == input.LEFT: - self.currentcontrol = (self.currentcontrol - 1) % 6 + 6 * (self.currentcontrol / 6) + self.currentcontrol = (self.currentcontrol - 1) % 6 + 6 * (self.currentcontrol // 6) if self.currentcontrol >= len(self.display[input.actions_order[self.currentaction]]): self.currentcontrol = len(self.display[input.actions_order[self.currentaction]]) - 1 elif i.translated == input.RIGHT: - self.currentcontrol = (self.currentcontrol + 1) % 6 + 6 * (self.currentcontrol / 6) + self.currentcontrol = (self.currentcontrol + 1) % 6 + 6 * (self.currentcontrol // 6) if self.currentcontrol >= len(self.display[input.actions_order[self.currentaction]]): - self.currentcontrol = 6 * (self.currentcontrol / 6) + self.currentcontrol = 6 * (self.currentcontrol // 6) snd.play('select_move') self.moveto(self.targetcontrol()) pass @@ -257,7 +257,7 @@ class GameSetup: global textfontheight for l in range(16): x = 90 + 100 * (l % 6) - y = 36 + 22 * (l / 6) + y = 36 + 22 * (l // 6) w = 100 h = textfontheight r = pygame.Rect(x, y, w, h) diff --git a/code/gfx.py b/code/gfx.py index cbe322f..7eb9a6a 100644 --- a/code/gfx.py +++ b/code/gfx.py @@ -32,8 +32,8 @@ def initialize(size, fullscreen): if surface.get_bytesize() == 1: loadpalette() - except pygame.error, msg: - raise pygame.error, 'Cannot Initialize Graphics' + except pygame.error as msg: + raise pygame.error('Cannot Initialize Graphics') starobj = stars.Stars() diff --git a/code/input.py b/code/input.py index f18dae2..a6184dd 100644 --- a/code/input.py +++ b/code/input.py @@ -158,16 +158,16 @@ def exclusive(list, i): global exclusivedict thislist = str(list) if i.translated in list: - if not exclusivedict.has_key(thislist): + if thislist not in exclusivedict: exclusivedict[thislist] = {} table = exclusivedict[thislist] if i.release: - if not table.has_key(i.translated): + if i.translated not in table: table[i.translated] = 0 else: table[i.translated] -= 1 else: - if not table.has_key(i.translated): + if i.translated not in table: table[i.translated] = 1 else: table[i.translated] += 1 @@ -207,11 +207,11 @@ def translate(event): dir = os.environ.get('HOME', '.') file = 'solarwolf%02d.bmp' % ScreenshotNum fullname = os.path.join(dir, file) - print 'Screenshot:', fullname + print('Screenshot: {}'.format(fullname)) try: pygame.image.save(pygame.display.get_surface(), fullname) except: - print ' Screenshot FAILED' + print(' Screenshot FAILED') ScreenshotNum += 1 elif event.key not in (K_NUMLOCK, K_CAPSLOCK): normalized = event.key @@ -306,12 +306,12 @@ def input_text(type, normalized): else: direction = "+" value = AXISMORE - axis = str( (normalized - value) / 2 ) + axis = str( (normalized - value) // 2 ) return 'Axis' + axis + direction elif type == JOYHATMOTION: value = HATSTART + normalized % 4 direction = hat_direction_text[value] - hat = str( (normalized - value) / 4 ) + hat = str( (normalized - value) // 4 ) return 'Hat' + hat + direction elif type == NOEVENT: return "*AllElse*" @@ -321,7 +321,7 @@ def getdisplay(): display = {} for type, table in translations.items(): for normalized, action in table.items(): - if not display.has_key(action): + if action not in display: display[action] = [] if type != NOEVENT: display[action].append((type, normalized)) @@ -343,7 +343,7 @@ def setdisplay(display): for l in range(len(display[a])): type = display[a][l][0] normalized = display[a][l][1] - if not translations.has_key(type): + if type not in translations: translations[type] = {} if type != NOEVENT: translations[type][normalized] = a @@ -374,7 +374,7 @@ def save_translations(): p = pickle.Pickler(f, 1) p.dump(translations) f.close() - except (IOError, OSError), msg: + except (IOError, OSError) as msg: import messagebox messagebox.error("Error Saving Control Data", "There was an error saving the control data.\nCurrent player controls have been lost.\n\n%s"%msg) diff --git a/code/levels.py b/code/levels.py index 58dcff9..b51bc5e 100644 --- a/code/levels.py +++ b/code/levels.py @@ -40,14 +40,14 @@ def makelevel(level): "returns (list, startcenter) level number" if not initialized: init() lev = Levels[level%len(Levels)] - touches = level/len(Levels) + 1 + touches = level//len(Levels) + 1 passes = (level>len(Levels) and 2) or 1 boxlist = [] size = 58, 58 corner = 106, 106 startpos = corner[0]+236, corner[1]+182 pos = [corner[0], corner[1]] - numboxes = level/2 + numboxes = level//2 for row in lev[2:]: cells = list(row) if touches == 2: @@ -74,14 +74,14 @@ def preview(level): "returns (list, startcenter) level number" if not initialized: init() lev = Levels[level%len(Levels)] - touches = level/len(Levels) + 1 + touches = level//len(Levels) + 1 passes = (level>len(Levels) and 2) or 1 boxlist = [] size = 5, 5 corner = 5, 5 startpos = corner[0]+236, corner[1]+182 pos = [corner[0], corner[1]] - numboxes = level/2 + numboxes = level//2 img = pygame.Surface((52, 42)) img.fill((20, 20, 30)) pygame.draw.rect(img, (255, 255, 255), (0,0,51,41), 2) diff --git a/code/main.py b/code/main.py index 6f3ba12..d7f8366 100644 --- a/code/main.py +++ b/code/main.py @@ -17,8 +17,8 @@ def main(args): try: gamemain(args) except KeyboardInterrupt: - print 'Keyboard Interrupt...' - print 'Exiting' + print('Keyboard Interrupt...') + print('Exiting') def gamemain(args): @@ -42,7 +42,7 @@ def gamemain(args): input.init() if not txt.initialize(): - raise pygame.error, "Pygame Font Module Unable to Initialize" + raise pygame.error("Pygame Font Module Unable to Initialize") #create the starting game handler from gameinit import GameInit diff --git a/code/mysysfont.py b/code/mysysfont.py index 27a980f..426fede 100644 --- a/code/mysysfont.py +++ b/code/mysysfont.py @@ -35,7 +35,7 @@ def _simplename(name): #insert a font and style into the font dictionary def _addfont(name, bold, italic, font, fontdict): - if not fontdict.has_key(name): + if name not in fontdict: fontdict[name] = {} fontdict[name][bold, italic] = font @@ -175,14 +175,14 @@ def create_aliases(): found = None fname = None for name in set: - if Sysfonts.has_key(name): + if name in Sysfonts: found = Sysfonts[name] fname = name break if not found: continue for name in set: - if not Sysfonts.has_key(name): + if name not in Sysfonts: Sysalias[name] = found diff --git a/code/objbox.py b/code/objbox.py index 71f39f6..402335a 100644 --- a/code/objbox.py +++ b/code/objbox.py @@ -30,7 +30,7 @@ def load_game_resources(): rboximages = gfx.animstrip(imgs) pal = [min(g+60,255) for (r,g,b) in origpal] - imgs.set_palette(zip(pal,pal,pal)) + imgs.set_palette(list(zip(pal,pal,pal))) wboximages = gfx.animstrip(imgs) popimages = gfx.animstrip(gfx.load('popbox.png')) diff --git a/code/objpopshot.py b/code/objpopshot.py index d4af237..b8bac45 100644 --- a/code/objpopshot.py +++ b/code/objpopshot.py @@ -29,7 +29,7 @@ class PopShot: gfx.dirty(r) def draw(self, gfx): - img = images[self.clocks/3] + img = images[self.clocks//3] r = gfx.surface.blit(img, self.rect) gfx.dirty(r) diff --git a/code/objpowerup.py b/code/objpowerup.py index 71cdc4e..d8cf99f 100644 --- a/code/objpowerup.py +++ b/code/objpowerup.py @@ -196,6 +196,6 @@ Effects = [ExtraLevelTime, PopShots, Shield, def newpowerup(levelnum): - choices = Effects[:2+(levelnum/8)] + choices = Effects[:2+(levelnum//8)] effect = random.choice(choices) return Powerup(effect) diff --git a/code/objsmoke.py b/code/objsmoke.py index e858d52..9ddba9c 100644 --- a/code/objsmoke.py +++ b/code/objsmoke.py @@ -40,7 +40,7 @@ class Smoke: gfx.dirty(r.inflate(1, 2)) def draw(self, gfx): - frame = min(self.clocks / 5, 3) + frame = min(self.clocks // 5, 3) img = images[frame] r = gfx.surface.blit(img, self.rect) gfx.dirty(r.inflate(1, 2)) diff --git a/code/objwarp.py b/code/objwarp.py index da9ab42..fbe9ac7 100644 --- a/code/objwarp.py +++ b/code/objwarp.py @@ -43,7 +43,7 @@ class Warp: gfx.dirty(r) def draw(self, gfx): - frame = min(int(self.clocks/CLOCK_MULTIPLIER), len(self.images)-1) + frame = min(int(self.clocks//CLOCK_MULTIPLIER), len(self.images)-1) img = images[frame] r = gfx.surface.blit(img, self.rect) gfx.dirty2(r, self.lastrect) diff --git a/code/players.py b/code/players.py index 696d9f6..43dc7e9 100644 --- a/code/players.py +++ b/code/players.py @@ -12,7 +12,7 @@ winners = [] def new_guid(): - return str(random.randint(0, sys.maxint-1)) + return str(random.randint(0, sys.maxsize-1)) def make_winner(player): player.winner = 1 @@ -94,7 +94,7 @@ def save_players(): p = pickle.Pickler(f, 1) p.dump(allplayers) f.close() - except (IOError, OSError), msg: + except (IOError, OSError) as msg: import messagebox messagebox.error("Error Saving Player Data", "There was an error saving the player data.\nCurrent player data has been lost.\n\n%s"%msg) diff --git a/code/snd.py b/code/snd.py index b5af532..dd926af 100644 --- a/code/snd.py +++ b/code/snd.py @@ -28,7 +28,7 @@ def preload(*names): sound_cache[name] = None return for name in names: - if not sound_cache.has_key(name): + if name not in sound_cache: fullname = os.path.join('data', 'audio', name+'.wav') #file = game.get_resource(name+'.wav') try: sound = mixer.Sound(fullname) @@ -37,7 +37,7 @@ def preload(*names): def fetch(name): - if not sound_cache.has_key(name): + if name not in sound_cache: preload(name) return sound_cache[name] diff --git a/code/stars.py b/code/stars.py index 3f34fbd..f1a0d8a 100644 --- a/code/stars.py +++ b/code/stars.py @@ -17,7 +17,7 @@ class Stars: speed = -val, val rect = Rect(randint(0, scrwide), randint(0, scrhigh), 1, 1) stars.append([rect, speed, color]) - half = self.maxstars / 2 + half = self.maxstars // 2 self.stars = stars[:half], stars[half:] self.numstars = 50 self.dead = 0 @@ -31,7 +31,7 @@ class Stars: change = int((fps - 35.0) * 1.8) change = min(change, 12) #limit how quickly they can be added numstars = self.numstars + change - numstars = max(min(numstars, self.maxstars/2), 0) + numstars = max(min(numstars, self.maxstars//2), 0) if numstars < self.numstars: DIRTY, BGD = gfx.dirty, self.last_background for rect, vel, col in self.stars[self.odd][numstars:self.numstars]: diff --git a/code/txt.py b/code/txt.py index fb31f84..0939d7f 100644 --- a/code/txt.py +++ b/code/txt.py @@ -21,7 +21,7 @@ def initialize(): class Font: def __init__(self, name, size, bold=0, italic=0): val = name, size - if FontPool.has_key(val): + if val in FontPool: font = FontPool[val] else: font = SysFont(name, size, bold, italic)
signature.asc
Description: PGP signature