Skip to content

Commit

Permalink
Fixed trig calc in Asteroid starting velocity to match map coordinate…
Browse files Browse the repository at this point in the history
… system.
  • Loading branch information
brandonmkunkel committed Mar 9, 2021
1 parent 715b8ea commit c1fadf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.1.4] - 09 - March 2021

- Fixed trig calc in Asteroid starting velocity to match map coordinate system.

## [1.1.3] - 09 - March 2021

- Enabled specification of starting position/angle/lives of the ShipSprite
Expand Down
2 changes: 1 addition & 1 deletion src/fuzzy_asteroids/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.3"
__version__ = "1.1.4"
10 changes: 5 additions & 5 deletions src/fuzzy_asteroids/sprites.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def __init__(self, frequency: float, starting_angle: float, starting_position: T
self.bullet_speed = 800

# Set the starting state
self.change_y = math.cos(math.radians(starting_angle)) * self.bullet_speed / self.frequency
self.change_x = -math.sin(math.radians(starting_angle)) * self.bullet_speed / self.frequency
self.change_y = math.cos(math.radians(starting_angle)) * self.bullet_speed / self.frequency
self.angle = math.degrees(math.atan2(self.change_y, self.change_x))

self.center_x, self.center_y = starting_position
Expand Down Expand Up @@ -289,12 +289,12 @@ def __init__(self, frequency: float, position: Tuple[float, float] = None,
self.max_speed = 60.0 * speed_scaler

# Use options angle and speed arguments
starting_angle = angle if angle else random.random()*360.0 - 180.0
starting_speed = speed if speed else random.random()*self.max_speed - self.max_speed/2.0
starting_angle = angle if angle is not None else random.random()*360.0 - 180.0
starting_speed = speed if speed is not None else random.random()*self.max_speed - self.max_speed/2.0

# Set constant starting velocity based on starting angle and speed
self.change_x = starting_speed * math.cos(math.radians(starting_angle)) / self.frequency
self.change_y = starting_speed * math.sin(math.radians(starting_angle)) / self.frequency
self.change_x = starting_speed * math.sin(math.radians(starting_angle)) / self.frequency
self.change_y = starting_speed * math.cos(math.radians(starting_angle)) / self.frequency

# Use parent position as starting point if this asteroid is starting form a parent
# Otherwise use the position given
Expand Down

0 comments on commit c1fadf3

Please sign in to comment.