|
|
|
app.py
# Pyxel Studio
import pyxel
class Personnage:
def __init__(self):
self.en_mouvement = False
self.vitesse_reculer = 2
self.vitesse = 2
self.valeur_saut = 7
self.x = 0
self.y = 85
self.saut= False
self.chute=False
self.hauteur_max=60
self.au_sol=True
def update(self):
self.au_sol
self.en_mouvement = False
if pyxel.btn(pyxel.KEY_RIGHT):
self.x = self.x + self.vitesse
self.en_mouvement = True
if pyxel.btn(pyxel.KEY_LEFT):
self.x = self.x - self.vitesse_reculer
self.en_mouvement = True
self.saut=False
if self.y==85:
self.au_sol=True
if self.y<85:
self.au_sol=False
if pyxel.btn(pyxel.KEY_UP)and self.au_sol==True:
self.y=self.y-self.valeur_saut
self.saut=True
if self.y<=self.hauteur_max:
self.saut=False
if self.saut==False and self.y<85:
self.y=self.y+self.valeur_saut
def draw(self):
if self.en_mouvement:
if pyxel.frame_count % 20 > 10 :
pyxel.blt(self.x, self.y, 0, 48, 0, 15, 15)
else :
pyxel.blt(self.x, self.y, 0, 36, 16, 12, 15)
else :
pyxel.blt(self.x, self.y, 0, 32, 0, 15, 15)
class App:
def __init__(self):
pyxel.init(100, 100, title="test")
pyxel.load("res.pyxres")
self.personnage = Personnage()
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
self.personnage.update()
def draw(self):
pyxel.cls(1)
pyxel.text(50, 41, "lucas et eva",9)
self.personnage.draw()
App() Create an account to manage your projects and publish them on the playground.
Layout
Packages
If your project uses packages, list them bellow (names separated by commas). Packages that can be added are only packages built in Pyodide.
Example: numpy,pandas Project Name
Documentation
LICENSE
Choose a license:
Public link
Share this link so people can discover your project / game.
Public link: www.pyxelstudio.net/wcsqeu6b
File to execute with the public link
PYXEL DOCUMENTATION
|