Skip to content

Commit 0bebc06

Browse files
Force calculation results to ints
1 parent 7ab9d47 commit 0bebc06

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

adafruit_pyoa.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,42 +135,42 @@ def load_game(self, game_directory):
135135
button_width = 120
136136
button_height = 40
137137
if self._display.height < 200:
138-
button_y /= 2
138+
button_y //= 2
139139
button_y += 10
140-
button_width /= 2
141-
button_height /= 2
142-
btn_right /= 2
143-
btn_mid /= 2
140+
button_width //= 2
141+
button_height //= 2
142+
btn_right //= 2
143+
btn_mid //= 2
144144
elif self._display.height > 250:
145-
button_y *= 0.75
145+
button_y = (button_y * 3) // 4
146146
button_y -= 20
147-
button_width *= 0.75
148-
button_height *= 0.75
149-
btn_right *= 0.75
150-
btn_mid *= 0.75
147+
button_width = (button_width * 3) // 4
148+
button_height = (button_height * 3) // 4
149+
btn_right = (btn_right * 3) // 4
150+
btn_mid = (btn_right * 3) // 4
151151
self._left_button = Button(
152-
x=int(btn_left),
153-
y=int(button_y),
154-
width=int(button_width),
155-
height=int(button_height),
152+
x=btn_left,
153+
y=button_y,
154+
width=button_width,
155+
height=button_height,
156156
label="Left",
157157
label_font=self._text_font,
158158
style=Button.SHADOWROUNDRECT,
159159
)
160160
self._right_button = Button(
161-
x=int(btn_right),
162-
y=int(button_y),
163-
width=int(button_width),
164-
height=int(button_height),
161+
x=btn_right,
162+
y=button_y,
163+
width=button_width,
164+
height=button_height,
165165
label="Right",
166166
label_font=self._text_font,
167167
style=Button.SHADOWROUNDRECT,
168168
)
169169
self._middle_button = Button(
170-
x=int(btn_mid),
171-
y=int(button_y),
172-
width=int(button_width),
173-
height=int(button_height),
170+
x=btn_mid,
171+
y=button_y,
172+
width=button_width,
173+
height=button_height,
174174
label="Middle",
175175
label_font=self._text_font,
176176
style=Button.SHADOWROUNDRECT,
@@ -432,8 +432,7 @@ def backlight_fade(self, to_light):
432432
"""Adjust the TFT backlight. Fade from one value to another"""
433433
from_light = self._display.brightness
434434
from_light = int(from_light * 100)
435-
to_light = max(0, min(1.0, to_light))
436-
to_light = int(to_light * 100)
435+
to_light = max(0, min(100, to_light * 100))
437436
delta = 1
438437
if from_light > to_light:
439438
delta = -1

0 commit comments

Comments
 (0)