Skip to content

Commit

Permalink
Fix Python 3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
progval committed Apr 3, 2013
1 parent 92723e7 commit a595b40
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit a595b40

Please sign in to comment.