Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrected "float division" bug, updated README.

  • Loading branch information...
commit 90ecf35ecc3fc96e484633dc05f779936f9f2fde 1 parent aed6cbd
@frontierpsycho authored
Showing with 9 additions and 13 deletions.
  1. +0 −7 README.md
  2. +9 −6 graphics_helpers.py
View
7 README.md
@@ -3,10 +3,3 @@ torpedoalley
============
A simple implementation of Torpedo Alley, the arcade game.
-
-TODO
-====
-
-- Testing
-- Level progression (?)
-- Correct "float division by zero" in torpedo launching
View
15 graphics_helpers.py
@@ -5,12 +5,15 @@ def circle_center_from_bbox(radius, bbox):
return center
def deltas_for_speed(speed, tx, ty):
- tan = ty/tx
+ if tx == 0:
+ return 0, math.copysign(speed, ty)
+ else:
+ tan = ty/tx
- dx = speed/math.sqrt(tan**2 + 1)
- dy = tan*dx
+ dx = speed/math.sqrt(tan**2 + 1)
+ dy = tan*dx
- dx = math.copysign(dx, tx)
- dy = math.copysign(dy, ty)
+ dx = math.copysign(dx, tx)
+ dy = math.copysign(dy, ty)
- return dx, dy
+ return dx, dy
Please sign in to comment.
Something went wrong with that request. Please try again.