Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added method to move sprite step by step

  • Loading branch information...
commit 8899787b0ce25297b7aee999a15ad2876d1aa1a6 1 parent 03755cd
@andrewsmedina authored
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)
Please sign in to comment.
Something went wrong with that request. Please try again.