Permalink
Browse files

added method to move sprite step by step

  • Loading branch information...
1 parent 03755cd commit 8899787b0ce25297b7aee999a15ad2876d1aa1a6 @andrewsmedina committed Aug 26, 2011
Showing with 12 additions and 0 deletions.
  1. +4 −0 physics/sprite.py
  2. +8 −0 tests/test_sprite.py
View
4 physics/sprite.py
@@ -3,3 +3,7 @@ class Sprite(object):
def __init__(self, x, y):
self.x = x
self.y = y
+
+ def step(self, x_velocity=0, y_velocity=0):
+ self.x += x_velocity
+ self.y += y_velocity
View
8 tests/test_sprite.py
@@ -13,3 +13,11 @@ def test_sprite_should_have_x_attribute(self):
def test_sprite_should_have_y_attribute(self):
self.assertEqual(15, self.sprite.y)
+
+ def test_step_should_increment_x_sprite_position(self):
+ self.sprite.step(x_velocity=1)
+ self.assertEqual(11, self.sprite.x)
+
+ def test_step_should_increment_y_sprite_position(self):
+ self.sprite.step(y_velocity=1)
+ self.assertEqual(16, self.sprite.y)

0 comments on commit 8899787

Please sign in to comment.