remove flicker
parent
8db1c30e5b
commit
5aec5156ad
18
frame.py
18
frame.py
|
@ -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"
|
||||||
|
|
||||||
|
|
2
main.py
2
main.py
|
@ -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:
|
||||||
|
|
Loading…
Reference in New Issue