Pyxel. Чтобы её использовать, надо забить в терминал pip install pyxel. Я просто хочу попробовать эту библиотеку, чтобы сделать маленькую игрушку по типу "змейки", а заодно делюсь с вами кодом) Чуть ниже я покажу как сделать окноimport pyxel #Импортируем Pyxel
#Создаем класс, который будет всё запускать
class App:
def __init__(self):
pyxel.init(160, 120)
pyxel.run(self.update, self.draw) #Говорим, что должен обрабатывать pyxel.run
def update(self): #Делаем обработку закрытия окна
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self): #В будущем сюда можно будет загрузить картинку
pyxel.cls(0)
pyxel.blt(61, 66, 0, 0, 0,38, 16)
App() #Запускаем класс App
#Python
#Pyxel
#СозданиеОкна@PythonPygame
Please open Telegram to view this post
VIEW IN TELEGRAM
5 3 1
pyxel.text. В нем должны быть обязательные четыре аргумента: x, y, 'Сам текст', col. Col - расшифровывается как Color (цвет)import pyxel
class App:
def __init__(self):
pyxel.init(160, 120)
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(0)
pyxel.text(55, 41, "Test", pyxel.frame_count % 16) #Добавляем текст. Первый параметр это X, а второй Y. Дальше пишите, какой у вас текст, и в последнем параметре вы можете поставить на сколько часто будет меняться цвет текста. Чем меньше - тем быстрее.
pyxel.blt(61, 66, 0, 0, 0,38, 16)
App()
#Python
#Pyxel
#ТекстPyxel@PythonPygame
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥2 2 2
import pyxel
class App:
def __init__(self):
pyxel.init(160, 120, title='Test') #Вот здесь добавляем параметр. Он не обязателен
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(0)
pyxel.text(55, 41, "Test", pyxel.frame_count % 16)
pyxel.blt(61, 66, 0, 0, 0,38, 16)
App()
#Python
#Pyxel
#НазваниеОкна@PythonPygame
Please open Telegram to view this post
VIEW IN TELEGRAM
👏3
pyxel.image. В нем мы указываем X, Y и путь к файлуimport pyxel
class App:
def __init__(self):
pyxel.init(160, 120, title='Test')
pyxel.image(0).load(0,0, "hawkfrost.png") #Добавляем картинку
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(0)
pyxel.text(55, 41, "Test", pyxel.frame_count % 16)
pyxel.blt(61, 66, 0, 0, 0,38, 16)
App()
#Python
#Pyxel
#КартинкиPyxel@PythonPygame
Please open Telegram to view this post
VIEW IN TELEGRAM
15 6