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 committed Jun 6, 2020
1 parent 7479cf8 commit 88fadc8
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._width / 900.0

This comment has been minimized.

Copy link
@Saumya-Mishra9129

Saumya-Mishra9129 Jun 6, 2020

Member

In line 94 It should be self._height

This comment has been minimized.

Copy link
@Saumya-Mishra9129

Saumya-Mishra9129 Jun 6, 2020

Member

I tested with the above change suggested by me, It worked . Can you change and make a commit again.

This comment has been minimized.

Copy link
@JuiP

JuiP Jun 6, 2020

Author Member

Oops sorry! That was pretty reckless. Will change it!

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

1 comment on commit 88fadc8

@Saumya-Mishra9129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how ever I am not sure that dividing by 1200 and 900 in line 93 and 94 will be convenient for all screens. Lets watch what @chimosky @srevinsaju suggests.

Please sign in to comment.