Skip to content

Commit

Permalink
Updates to better support Python 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Vincent Craven committed May 18, 2016
1 parent 046f5c5 commit 1bd5d5f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
5 changes: 4 additions & 1 deletion arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ class Window(pyglet.window.Window):
>>> window.close()
"""
def __init__(self, width, height, title='Arcade Window'):
super().__init__(width=width, height=height, caption=title)
# This is nicer, but Python 3.x only
# super().__init__(width=width, height=height, caption=title)
pyglet.window.Window.__init__(self, width=width, height=height, caption=title)

self.set_update_rate(1/80)
# set_viewport(0, self.width, 0, self.height)

Expand Down
3 changes: 1 addition & 2 deletions arcade/draw_commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import sys
import math
import ctypes
Expand All @@ -7,7 +8,6 @@
import pyglet.gl as GL
import pyglet.gl.glu as GLU


class Texture():
"""
Class that represents a texture.
Expand Down Expand Up @@ -229,7 +229,6 @@ def trim_image(image):
"""
Returns an image with extra whitespace cropped out.
>>> from __future__ import print_function
>>> name = "doc/source/examples/images/playerShip1_orange.png"
>>> source_image = PIL.Image.open(name)
>>> cropped_image = trim_image(source_image)
Expand Down
5 changes: 3 additions & 2 deletions arcade/geometry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import math


Expand Down Expand Up @@ -65,8 +66,8 @@ def rotate(x, y, cx, cy, angle):
Rotate a point around a center.
>>> x, y = rotate(1, 1, 0, 0, 90)
>>> print(round(x), round(y))
-1 1
>>> print("x = {:.1f}, y = {:.1f}".format(x, y))
x = -1.0, y = 1.0
"""
tempX = x - cx
tempY = y - cy
Expand Down
25 changes: 13 additions & 12 deletions arcade/sprite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from .draw_commands import *
from .geometry import *

Expand Down Expand Up @@ -356,13 +357,13 @@ def _get_bottom(self):
>>> import arcade
>>> arcade.open_window("Sprite Example", 800, 600)
>>> scale = 1
>>> scale = 1.0
>>> ship_sprite = \
arcade.Sprite("doc/source/examples/images/playerShip1_orange.png", scale)
>>> ship_sprite.center_y = 0
>>> ship_sprite.center_y = 0.0
>>> print(ship_sprite.bottom)
-37.5
>>> ship_sprite.bottom = 1
>>> ship_sprite.bottom = 1.0
>>> print(ship_sprite.bottom)
1.0
>>> arcade.quick_run(0.25)
Expand All @@ -389,13 +390,13 @@ def _get_top(self):
>>> import arcade
>>> arcade.open_window("Sprite Example", 800, 600)
>>> scale = 1
>>> scale = 1.0
>>> ship_sprite = \
arcade.Sprite("doc/source/examples/images/playerShip1_orange.png", scale)
>>> ship_sprite.center_y = 0
>>> ship_sprite.center_y = 0.0
>>> print(ship_sprite.top)
37.5
>>> ship_sprite.top = 1
>>> ship_sprite.top = 1.0
>>> print(ship_sprite.top)
1.0
>>> arcade.quick_run(0.25)
Expand Down Expand Up @@ -453,13 +454,13 @@ def _get_left(self):
>>> import arcade
>>> arcade.open_window("Sprite Example", 800, 600)
>>> scale = 1
>>> scale = 1.0
>>> ship_sprite = \
arcade.Sprite("doc/source/examples/images/playerShip1_orange.png", scale)
>>> ship_sprite.center_x = 0
>>> ship_sprite.center_x = 0.0
>>> print(ship_sprite.left)
-49.5
>>> ship_sprite.left = 1
>>> ship_sprite.left = 1.0
>>> print(ship_sprite.left)
1.0
>>> arcade.quick_run(0.25)
Expand Down Expand Up @@ -487,13 +488,13 @@ def _get_right(self):
>>> import arcade
>>> arcade.open_window("Sprite Example", 800, 600)
>>> scale = 1
>>> scale = 1.0
>>> ship_sprite = \
arcade.Sprite("doc/source/examples/images/playerShip1_orange.png", scale)
>>> ship_sprite.center_x = 0
>>> ship_sprite.center_x = 0.0
>>> print(ship_sprite.right)
49.5
>>> ship_sprite.right = 1
>>> ship_sprite.right = 1.0
>>> print(ship_sprite.right)
1.0
>>> arcade.quick_run(0.25)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/preprocess_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def list_classes(filename, output_file):


def main():
output_file = open("quick_index.rst", "w")
output_file = open("doc/source/quick_index.rst", "w")

output_file.write(".. _quick-index:\n\n")

Expand Down

0 comments on commit 1bd5d5f

Please sign in to comment.