Skip to content

Commit

Permalink
Fix disappearing planets in network games (they turned into BHs)
Browse files Browse the repository at this point in the history
  • Loading branch information
HAL20000 committed May 8, 2019
1 parent 9bfed6e commit 15b3f41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/bin/slingshot
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,9 @@ class Game:
result.add(Planet(result, self.background))
else:
for p in planetlist:
if p[0] > Settings.MAX_PLANETS:
# Numbers above Settings.MAX_PLANETS are
if p[0] > Settings.NUM_PLANET_SPRITES:
# Numbers above
# Settings.NUM_PLANET_SPRITES are
# allocated to blackholes.
result.add(Blackhole(None, self.background, p[0], p[1], p[2], p[3]))
else:
Expand Down
5 changes: 3 additions & 2 deletions src/slingshot/planet.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, planets, background, n=None, radius=None, mass=None, pos=None
unique = False
while not unique:
unique = True
self.n = randint(1, 8)
self.n = randint(1, Settings.NUM_PLANET_SPRITES)
for p in planets:
if self.n == p.get_n():
unique = False
Expand Down Expand Up @@ -143,7 +143,8 @@ def __init__(self, planets, background, n=None, radius=None, mass=None, pos=None
unique = False
while not unique:
unique = True
self.n = randint(Settings.MAX_PLANETS + 1, Settings.MAX_PLANETS + Settings.MAX_BLACKHOLES + 1)
self.n = randint(Settings.NUM_PLANET_SPRITES +
1, Settings.NUM_PLANET_SPRITES + Settings.MAX_BLACKHOLES + 1)
for p in planets:
if self.n == p.get_n():
unique = False
Expand Down
6 changes: 5 additions & 1 deletion src/slingshot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

class Settings:

VERSION = '0.9'
VERSION = '0.9r1'

g = 120 # gravity
MAXPOWER = 350
Expand All @@ -52,6 +52,10 @@ class Settings:
MAX_FLIGHT = 750

MAX_PLANETS = 4
# MAX_PLANTES_SPRITES is the number of planet sprites, hence the maximal
# number for any Planet.n and we can identify BHs by haveing an n >
# NUM_PLANET_SPRITES
NUM_PLANET_SPRITES = 8
MAX_BLACKHOLES = 0

HITSCORE = 1500
Expand Down

0 comments on commit 15b3f41

Please sign in to comment.