Skip to content

Commit

Permalink
done map saving/loading and scale to appropriate screen size
Browse files Browse the repository at this point in the history
  • Loading branch information
Maskime committed Sep 8, 2018
1 parent 3c06e94 commit 18a06af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions widgets/PaintWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,13 @@ def load(self, filename):
map_width, map_height = map_definition['dimensions']
fsand_width, fsand_height = float(sand_width), float(sand_height)
fmap_width, fmap_height = float(map_width), float(map_height)
sand_surface = sand_width * sand_height
map_surface = map_width * map_height
if sand_surface > map_surface:
width_ratio = fsand_width / fmap_width
height_ratio = fsand_height / fmap_height
else:
width_ratio = fmap_width / fsand_width
height_ratio = fmap_height / fsand_height
'''
If the sand box size is bigger than the map, then we need to scale up
otherwise we need to scale down
scale factor :
'''
width_ratio = fsand_width / fmap_width
height_ratio = fsand_height / fmap_height

print("Ratio to be applied [{}, {}]".format(width_ratio, height_ratio))

Expand Down
2 changes: 1 addition & 1 deletion widgets/StatsWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def __init__(self, **kwargs):
def update_stats(self, steps, destination, distance):
self.steps_count.text = str(steps)
self.destination.text = destination
self.distance.text = str(distance)
self.distance.text = str("{0:.2f}".format(distance))

0 comments on commit 18a06af

Please sign in to comment.