remove flicker

main
Plaza521 2022-10-26 22:40:18 +03:00 committed by GitHub
parent 8db1c30e5b
commit 5aec5156ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -1,5 +1,19 @@
from settings import * from settings import *
import os from sys import platform
if platform == "win32":
from ctypes import *
STD_OUTPUT_HANDLE = -11
STDHANDLE = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
class COORDSET(Structure):
_fields_ = [("X", c_long), ("Y", c_long)]
def _set_cursor_position(x: int, y: int) -> None:
windll.kernel32.SetConsoleCursorPosition(STDHANDLE, COORDSET(x, y))
else:
def _set_cursor_position(x: int, y: int) -> None:
print(f"\033[{x};{y}H")
class Frame: class Frame:
@ -26,7 +40,7 @@ class Frame:
self.matrix[y + line][x + column] = value self.matrix[y + line][x + column] = value
def show(self) -> None: def show(self) -> None:
os.system("clear||cls") _set_cursor_position(0, 0)
out_string = f"{'' * (self.width * 2)}\n" out_string = f"{'' * (self.width * 2)}\n"

View File

@ -3,6 +3,7 @@ from settings import *
from player import Player from player import Player
import keyboard as kb import keyboard as kb
from out import Out from out import Out
from os import system
class Game: class Game:
@ -27,6 +28,7 @@ class Game:
pass pass
def play(self) -> None: def play(self) -> None:
system("clear||cls")
while self.running: while self.running:
try: try: