From a595b40b80865cfcd866bf0f305d58f3fee0a1e9 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 3 Apr 2013 18:57:12 +0200 Subject: [PATCH] Fix Python 3 compatibility. --- main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 411ab78a..da4acaf4 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,17 @@ +from __future__ import division + from pyglet.gl import * from pyglet.window import key +import sys import math import random import time SECTOR_SIZE = 16 +if sys.version_info[0] >= 3: + xrange = range + def cube_vertices(x, y, z, n): return [ x-n,y+n,z-n, x-n,y+n,z+n, x+n,y+n,z+n, x+n,y+n,z-n, # top @@ -63,7 +69,7 @@ def normalize(position): def sectorize(position): x, y, z = normalize(position) - x, y, z = x / SECTOR_SIZE, y / SECTOR_SIZE, z / SECTOR_SIZE + x, y, z = x // SECTOR_SIZE, y // SECTOR_SIZE, z // SECTOR_SIZE return (x, 0, z) class Model(object): @@ -399,7 +405,7 @@ def on_resize(self, width, height): # reticle if self.reticle: self.reticle.delete() - x, y = self.width / 2, self.height / 2 + x, y = self.width // 2, self.height // 2 n = 10 self.reticle = pyglet.graphics.vertex_list(4, ('v2i', (x - n, y, x + n, y, x, y - n, x, y + n))