kitao / pyxel

A retro game engine for Python
MIT License
14.67k stars 824 forks source link

Don't start when I ask for #517

Closed Taaniyu closed 8 months ago

Taaniyu commented 8 months ago

I have a full code and it worked before but for no reason it just stop working and everytime I try to run the code it didn't whitout a single error message just like it finished "Process finished with exit code 0" (I use Pycharm)

My code :

import pyxel

class Caractere:
    def __init__(self) -> None:
        self.x = 0
        self.y = pyxel.height - 16 ##for futur vertical movement
        self.speed = 2
        self.movement = False
        self.direction = 1  ##right : 1 , left : -1

    def update(self):
        self.movement = False
        if pyxel.btn(pyxel.KEY_D):  ##move to the right
            self.x = min(self.x + self.speed, pyxel.width)
            self.movement = True
            self.direction = 1
        if pyxel.btn(pyxel.KEY_Q):  ##move to the left
            self.x = max(self.x - self.speed, 0)
            self.movement = True
            self.direction = -1

    def draw(self):
        if self.movement == False:
            if pyxel.frame_count % 30 > 15:
                pyxel.blt(self.x, self.y, 0, 0, 0, self.direction * 16, 16, 0)
            else:
                pyxel.blt(self.x, self.y, 0, 16, 0, self.direction * 16, 16, 0)
        else:
            pyxel.blt(self.x, self.y, 0, 32, 0, self.direction * 16, 16, 0)

class App:
    def __init__(self):
        pyxel.init(1080, 600, title="First pyxel", fps=30)
        pyxel.load("jump.pyxres")
        self.caractere = Caractere()
        pyxel.run(self.update, self.draw)

    def update(self):
        self.caractere.update()

    def draw(self):
        pyxel.cls(12)
        pyxel.blt(pyxel.width // 2 - 8, pyxel.height - 25, 0, 0, 16, 48, 16, 0)  ##dessin montagned