public
Created

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
From f902f1ebd72d14a2ccaa0c2b831ecbc46888620b Mon Sep 17 00:00:00 2001
From: Bjoern Walk <bwalk@kph.uni-mainz.de>
Date: Fri, 29 Mar 2013 22:08:24 +0100
Subject: [PATCH] python3 compatibility
 
---
main.py | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
 
diff --git a/main.py b/main.py
index d1f9d03..d55bd3f 100644
--- a/main.py
+++ b/main.py
@@ -64,7 +64,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 = int(x / SECTOR_SIZE), int(y / SECTOR_SIZE), int(z / SECTOR_SIZE)
return (x, 0, z)
class Model(object):
@@ -81,15 +81,15 @@ class Model(object):
n = 80
s = 1
y = 0
- for x in xrange(-n, n + 1, s):
- for z in xrange(-n, n + 1, s):
+ for x in range(-n, n + 1, s):
+ for z in range(-n, n + 1, s):
self.init_block((x, y - 2, z), GRASS)
self.init_block((x, y - 3, z), STONE)
if x in (-n, n) or z in (-n, n):
- for dy in xrange(-2, 3):
+ for dy in range(-2, 3):
self.init_block((x, y + dy, z), STONE)
o = n - 10
- for _ in xrange(120):
+ for _ in range(120):
a = random.randint(-o, o)
b = random.randint(-o, o)
c = -1
@@ -97,9 +97,9 @@ class Model(object):
s = random.randint(4, 8)
d = 1
t = random.choice([GRASS, SAND, BRICK])
- for y in xrange(c, c + h):
- for x in xrange(a - s, a + s + 1):
- for z in xrange(b - s, b + s + 1):
+ for y in range(c, c + h):
+ for x in range(a - s, a + s + 1):
+ for z in range(b - s, b + s + 1):
if (x - a) ** 2 + (z - b) ** 2 > (s + 1) ** 2:
continue
if (x - 0) ** 2 + (z - 0) ** 2 < 5 ** 2:
@@ -111,7 +111,7 @@ class Model(object):
x, y, z = position
dx, dy, dz = vector
previous = None
- for _ in xrange(max_distance * m):
+ for _ in range(max_distance * m):
key = normalize((x, y, z))
if key != previous and key in self.world:
return key, previous
@@ -205,9 +205,9 @@ class Model(object):
before_set = set()
after_set = set()
pad = 4
- for dx in xrange(-pad, pad + 1):
+ for dx in range(-pad, pad + 1):
for dy in [0]: # xrange(-pad, pad + 1):
- for dz in xrange(-pad, pad + 1):
+ for dz in range(-pad, pad + 1):
if dx ** 2 + dy ** 2 + dz ** 2 > (pad + 1) ** 2:
continue
if before:
@@ -294,7 +294,7 @@ class Window(pyglet.window.Window):
self.sector = sector
m = 8
dt = min(dt, 0.2)
- for _ in xrange(m):
+ for _ in range(m):
self._update(dt / m)
def _update(self, dt):
# walking
@@ -316,13 +316,13 @@ class Window(pyglet.window.Window):
p = list(position)
np = normalize(position)
for face in FACES: # check all surrounding blocks
- for i in xrange(3): # check each dimension independently
+ for i in range(3): # check each dimension independently
if not face[i]:
continue
d = (p[i] - np[i]) * face[i]
if d < pad:
continue
- for dy in xrange(height): # check each height
+ for dy in range(height): # check each height
op = list(np)
op[1] -= dy
op[i] += face[i]
@@ -392,7 +392,7 @@ class Window(pyglet.window.Window):
# reticle
if self.reticle:
self.reticle.delete()
- x, y = self.width / 2, self.height / 2
+ x, y = int(self.width / 2), int(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))
--
1.8.2

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.