Skip to content

Commit

Permalink
Fix the scaling factor for display resolution fix
Browse files Browse the repository at this point in the history
  • Loading branch information
JuiP authored and Saumya-Mishra9129 committed Jun 6, 2020
1 parent 7479cf8 commit 791af63
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def __init__(self, canvas, parent=None, path=None):

self._width = Gdk.Screen.width()
self._height = Gdk.Screen.height()
self._scale = self._width / self._width
self._scale_x = self._width / 1200.0
self._scale_y = self._height / 900.0
self._first_time = True
self._loco_pos = (0, 0)
self._loco_dim = (0, 0)
Expand Down Expand Up @@ -126,10 +127,10 @@ def __init__(self, canvas, parent=None, path=None):
self._backgrounds[-1].hide()

self._panel = Sprite(
self._sprites, int(400 * self._scale), int(400 * self._scale),
self._sprites, int(400 * self._scale_x), int(400 * self._scale_y),
GdkPixbuf.Pixbuf.new_from_file_at_size(
os.path.join(self._path, 'images', 'ventana.png'),
int(720 * self._scale), int(370 * self._scale)))
int(720 * self._scale_x), int(370 * self._scale_y)))
self._panel.type = 'panel'
self._panel.set_label(LABELS[0])
self._panel.set_label_attributes(20)
Expand All @@ -140,17 +141,17 @@ def __init__(self, canvas, parent=None, path=None):
self._loco_cards = []
for loco in self._LOCOS:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
loco, int(150 * self._scale_x), int(208 * self._scale_y))
self._loco_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._loco_cards[-1].type = 'loco'
self._loco_dim = (int(150 * self._scale), int(208 * self._scale))
self._loco_dim = (int(150 * self._scale_x), int(208 * self._scale_y))

self._MEN = glob.glob(
os.path.join(self._path, 'images', 'man*.png'))
self._man_cards = []
for loco in self._MEN:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
loco, int(150 * self._scale_x), int(208 * self._scale_y))
self._man_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._man_cards[-1].type = 'loco'

Expand All @@ -159,7 +160,7 @@ def __init__(self, canvas, parent=None, path=None):
self._taunt_cards = []
for loco in self._TAUNTS:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
loco, int(150 * self._scale_x), int(208 * self._scale_y))
self._taunt_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._taunt_cards[-1].type = 'loco'

Expand All @@ -168,17 +169,17 @@ def __init__(self, canvas, parent=None, path=None):
self._ghost_cards = []
for loco in self._GHOSTS:
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
loco, int(150 * self._scale), int(208 * self._scale))
loco, int(150 * self._scale_x), int(208 * self._scale_y))
self._ghost_cards.append(Sprite(self._sprites, 0, 0, pixbuf))
self._ghost_cards[-1].type = 'loco'

self._sticky_cards = []
self._loco_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
self._LOCOS[0], int(150 * self._scale), int(208 * self._scale))
self._LOCOS[0], int(150 * self._scale_x), int(208 * self._scale_y))
self._man_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
self._MEN[0], int(150 * self._scale), int(208 * self._scale))
self._MEN[0], int(150 * self._scale_x), int(208 * self._scale_y))
self._ghost_pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(
self._GHOSTS[0], int(150 * self._scale), int(208 * self._scale))
self._GHOSTS[0], int(150 * self._scale_x), int(208 * self._scale_y))
for i in range(len(MSGS[1])): # Check re i18n
self._sticky_cards.append(Sprite(self._sprites, 0, 0,
self._loco_pixbuf))
Expand Down

0 comments on commit 791af63

Please sign in to comment.