Hirdetés
- Micro Four Thirds
- Házi barkács, gányolás, tákolás, megdöbbentő gépek!
- Milyen notebookot vegyek?
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Melyik hordozható audiolejátszót (DAP, MP3, stb.) vegyem?
- Vezeték nélküli fejhallgatók
- AMD Navi Radeon™ RX 9xxx sorozat
- Bambu Lab 3D nyomtatók
- Windows 11: miért nem vált mindenki?
- Autóhifi
Új hozzászólás Aktív témák
-
válasz
magortaltos
#3312
üzenetére
Itt van non-blocking módban is:
from os import system
from sys import platform
from pynput import keyboard
from pynput.keyboard import Key
from time import sleep
def print_at_x(y, x, text):
print(f"\033[{y};{x}H{text}")
def print_at_w(r, c, s):
h = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
windll.kernel32.SetConsoleCursorPosition(h, COORD(c, r))
prev_codepage = windll.kernel32.GetConsoleOutputCP()
windll.kernel32.SetConsoleOutputCP(65001)
c = s.encode("UTF-8")
windll.kernel32.WriteConsoleA(h, c_char_p(c), len(c), None, None)
windll.kernel32.SetConsoleOutputCP(prev_codepage)
def on_press(key):
global dx, dy, run
if key == keyboard.Key.esc:
run = False
return run
elif key == Key.up:
dx, dy = 0, -1
elif key == Key.left:
dx, dy = -1, 0
elif key == Key.down:
dx, dy = 0, 1
elif key == Key.right:
dx, dy = 1, 0
else:
return
if platform == "linux" or platform == "linux2":
# linux
system('clear')
print_at = print_at_x
elif platform == "darwin":
# MacOS, talán működik itt is
system('clear')
print_at = print_at_x
elif platform == "win32":
# Windows...
from ctypes import *
class COORD(Structure):
pass
STD_OUTPUT_HANDLE = -11
COORD._fields_ = [("X", c_short), ("Y", c_short)]
system('cls')
print_at = print_at_w
print_at(3, 15, 'Próbálj bent maradni a négyzetben!')
for n in range(5,50):
print_at(5, n, '*')
print_at(20, n, '*')
for n in range(5,20):
print_at(n, 5, '*')
print_at(n, 50, '*')
x, y = 25, 7
dx, dy = 0, 0
run = True
print_at(y, x, 'O')
listener = keyboard.Listener(on_press=on_press, suppress=True)
listener.start()
while run:
print_at(y, x, ' ')
x, y = x + dx, y + dy
print_at(y, x, 'O')
if not (5 < x < 50) or not (5 < y < 20):
run = False
sleep(0.1)
print_at(20, 55, 'A játéknak vége !')
Új hozzászólás Aktív témák
- Lenovo Legion Go Z1 Extreme 512/16GB
- ASRock P4i65PE Socket 478 Retro alaplap
- Lenovo ThinkPad T14 Gen 2, i5-1145G7 CPU, 16GB DDR4, 512GB SSD, AAM SZÁMLA, 1ÉV GARANCIA!
- Dell Latitude 5490 FHD, i5-8350U, 8GB DDR4,256GB SSD, AAM SZÁMLA(Vállalkozásoknak is!), 1ÉV GARANCIA
- Dell Latitude 7490 FHD, TOUCH, i5-8350U, 8GB DDR4, 256GB SSD, AAM SZÁMLA, 1ÉV GARANCIA!
- BESZÁMÍTÁS! Gigabyte Z390 i7 9700KF 16GB DDR4 512GB SSD GTX 1070 Ti 8GB Cooler MasterCM 690 III 550W
- Azonnali készpénzes Intel i3 i5 i7 i9 12/13/14 gen processzor felvásárlás személyesen / csomagküldés
- Nvidia Quadro P400/ P620/ P1000/ T400/ T1000 - Low profile (LP) + RTX A2000 6/12Gb
- GYÖNYÖRŰ iPhone 14 Pro Max 256GB Space Black -1 ÉV GARANCIA -Kártyafüggetlen, MS4031
- Új Lenovo 16 Ideapad Pro 5 OLED 2.8K 120Hz Ryzen AI 5 340 4.8Ghz 24GB 1TB Radeon 840M Win11 Garancia
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

