def __init__(self):
     self.__window = Window()
     globals()['Window'] = self.__window
     self.__scene = SceneManager()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 2
0
 def __init__(self):
     self.text = Text("data/text.json")
     pyxel.init(256, 192, caption="narrative")
     pyxel.run(self.update, self.draw)
        msg = ""
        if self.paused:
            msg = 'PAUSED'

        if msg:
            x = (WIDTH - len(msg) * pyxel.FONT_WIDTH) / 2
            pyxel.text(round(x), HEIGHT // 2, msg, pyxel.COLOR_RED)

    def handle_hit_player(self, sender):
        self.state = GameState.GAMEPLAY

    def handle_hit_target(self, sender):
        self.state = GameState.GAMEPLAY

    def update(self):

        if (pyxel.btnp(pyxel.KEY_P)):
            self.paused = False if self.paused else True
        if not self.paused:
            self.space.step(1 / 30, 2)
        self.player.update()
        self.camera.follow(self.player.position, tol=self.CAMERA_TOL)


#=================================================

pyxel.init(WIDTH, HEIGHT)
pyxel.mouse(True)
game = Game()
pyxel.run(game.update, game.draw)
Ejemplo n.º 4
0
import pyxel
from pyxelext.line import poly


def update():
    pass


def draw():
    pyxel.cls(0)
    start_x = 128
    poly((start_x, 122), (start_x + 10, 125), (start_x + 20, 120),
         (start_x + 50, 155),
         col=pyxel.frame_count % 16)


if __name__ == '__main__':
    pyxel.init(256, 256, scale=2, fps=60)
    pyxel.run(update, draw)
Ejemplo n.º 5
0
    def __init__(self):
        pyxel.init(self.WIDTH, self.HEIGHT, caption="Noise")
        pyxel.mouse(True)

        self.keys_name = {
            pyxel.GAMEPAD_1_A: "A",
            pyxel.GAMEPAD_1_B: "B",
            pyxel.GAMEPAD_1_DOWN: "DOWN",
            pyxel.GAMEPAD_1_LEFT: "LEFT",
            pyxel.GAMEPAD_1_LEFT_SHOULDER: "LEFT_SHOULDER",
            pyxel.GAMEPAD_1_RIGHT: "RIGHT",
            pyxel.GAMEPAD_1_RIGHT_SHOULDER: "RIGHT_SHOULDER",
            pyxel.GAMEPAD_1_SELECT: "SELECT",
            pyxel.GAMEPAD_1_START: "START",
            pyxel.GAMEPAD_1_UP: "UP",
            pyxel.GAMEPAD_1_X: "X",
            pyxel.GAMEPAD_1_Y: "Y",
            pyxel.GAMEPAD_2_A: "A",
            pyxel.GAMEPAD_2_B: "B",
            pyxel.GAMEPAD_2_DOWN: "DOWN",
            pyxel.GAMEPAD_2_LEFT: "LEFT",
            pyxel.GAMEPAD_2_LEFT_SHOULDER: "LEFT_SHOULDER",
            pyxel.GAMEPAD_2_RIGHT: "RIGHT",
            pyxel.GAMEPAD_2_RIGHT_SHOULDER: "RIGHT_SHOULDER",
            pyxel.GAMEPAD_2_SELECT: "SELECT",
            pyxel.GAMEPAD_2_START: "START",
            pyxel.GAMEPAD_2_UP: "UP",
            pyxel.GAMEPAD_2_X: "X",
            pyxel.GAMEPAD_2_Y: "Y",
        }

        self.pressed_keys = {
            pyxel.GAMEPAD_1_A: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_B: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_DOWN: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_LEFT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_LEFT_SHOULDER: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_RIGHT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_RIGHT_SHOULDER: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_SELECT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_START: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_UP: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_X: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_1_Y: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_A: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_B: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_DOWN: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_LEFT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_LEFT_SHOULDER: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_RIGHT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_RIGHT_SHOULDER: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_SELECT: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_START: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_UP: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_X: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
            pyxel.GAMEPAD_2_Y: {
                STATE.CURRENT: False,
                STATE.EVER: False
            },
        }

        pyxel.run(self.update, self.draw)
Ejemplo n.º 6
0
 def __init__(self):
     pyxel.init(WIDTH, HEIGHT, caption=TITLE)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 7
0
 def __init__(self):
     pyxel.init(WIDTH, HEIGHT)
     pyxel.load('mychara.pyxres')
     self.myChara = Chara.MyChara()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 8
0
 def __init__(self):
     pyxel.init(160, 120)
     self.engine = Engine(pyxel.width, pyxel.height)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 9
0
    def __init__(self, resource_file):
        resource_file = os.path.join(os.getcwd(), resource_file)
        root, ext = os.path.splitext(resource_file)
        if ext != ".pyxel":
            resource_file += ".pyxel"

        pyxel.init(APP_WIDTH,
                   APP_HEIGHT,
                   caption="Pyxel Editor - {}".format(resource_file))

        try:
            pyxel.load(resource_file)
        except FileNotFoundError:
            pass

        super().__init__(None, 0, 0, pyxel.width, pyxel.height)

        self._resource_file = resource_file
        self._editor_list = [
            ImageEditor(self),
            TileMapEditor(self),
            SoundEditor(self),
            MusicEditor(self),
        ]
        self._edit_count = 0
        self._editor_button = RadioButton(self, 1, 1, 3, EDITOR_IMAGE_X,
                                          EDITOR_IMAGE_Y, 4, 0)
        self._undo_button = ImageButton(self, 48, 1, 3, EDITOR_IMAGE_X + 36,
                                        EDITOR_IMAGE_Y)
        self._redo_button = ImageButton(self, 57, 1, 3, EDITOR_IMAGE_X + 45,
                                        EDITOR_IMAGE_Y)
        self._save_button = ImageButton(self,
                                        75,
                                        1,
                                        3,
                                        EDITOR_IMAGE_X + 54,
                                        EDITOR_IMAGE_Y,
                                        is_enabled=False)
        self.help_message = ""

        self._editor_button.add_event_handler(
            "change", lambda value: self.set_editor(value))
        self.add_event_handler("update", self.__on_update)
        self.add_event_handler("draw", self.__on_draw)
        self._undo_button.add_event_handler("press", self.__on_undo_press)
        self._redo_button.add_event_handler("press", self.__on_redo_press)
        self._save_button.add_event_handler("press", self.__on_save_press)
        self._editor_button.add_event_handler(
            "mouse_hover", self.__editor_button_on_mouse_hover)
        self._undo_button.add_event_handler("mouse_hover",
                                            self.__undo_button_on_mouse_hover)
        self._redo_button.add_event_handler("mouse_hover",
                                            self.__redo_button_on_mouse_hover)
        self._save_button.add_event_handler("mouse_hover",
                                            self.__save_button_on_mouse_hover)

        self.set_editor(0)

        image_file = os.path.join(os.path.dirname(__file__), "assets",
                                  "editor_160x160.png")
        pyxel.image(3, system=True).load(EDITOR_IMAGE_X, EDITOR_IMAGE_Y,
                                         image_file)

        pyxel.mouse(True)

        pyxel.run(self.update_widgets, self.draw_widgets)
Ejemplo n.º 10
0
    def __init__(self):
        pyxel.init(200, 150, caption="Pixel Sound API")

        pyxel.image(0).set(
            0,
            0,
            [
                "00011000",
                "00010100",
                "00010010",
                "00010010",
                "00010100",
                "00010000",
                "01110000",
                "01100000",
            ],
        )

        pyxel.sound(0).set(
            "e2e2c2g1 g1g1c2e2 d2d2d2g2 g2g2rr"
            "c2c2a1e1 e1e1a1c2 b1b1b1e2 e2e2rr",
            "p",
            "6",
            "vffn fnff vffs vfnn",
            25,
        )

        pyxel.sound(1).set(
            "r a1b1c2 b1b1c2d2 g2g2g2g2 c2c2d2e2"
            "f2f2f2e2 f2e2d2c2 d2d2d2d2 g2g2r r ",
            "s",
            "6",
            "nnff vfff vvvv vfff svff vfff vvvv svnn",
            25,
        )

        pyxel.sound(2).set(
            "c1g1c1g1 c1g1c1g1 b0g1b0g1 b0g1b0g1"
            "a0e1a0e1 a0e1a0e1 g0d1g0d1 g0d1g0d1",
            "t",
            "7",
            "n",
            25,
        )

        pyxel.sound(3).set(
            "f0c1f0c1 g0d1g0d1 c1g1c1g1 a0e1a0e1"
            "f0c1f0c1 f0c1f0c1 g0d1g0d1 g0d1g0d1",
            "t",
            "7",
            "n",
            25,
        )

        pyxel.sound(4).set("f0ra4r f0ra4r f0ra4r f0f0a4r", "n",
                           "6622 6622 6622 6422", "f", 25)

        self.is_playing = [True] * 3

        self.play_music(True, True, True)

        pyxel.run(self.update, self.draw)
Ejemplo n.º 11
0
 def __init__(self):
     self.player = Player(5,5)
     pyxel.init(256, 256, caption="SABAKU DE WARS")
     pyxel.load("Tile.pyxres")
     pyxel.run(self.update, self.draw)
Ejemplo n.º 12
0
 def __init__(self):
     pyxel.init(255, 255)
     pyxel.cls(1)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 13
0
    def __init__(self):
        ########################################################################
        #                         INITIALIZATION                               #
        ########################################################################

        #                        initialize player                             #

        self.player = Player(WIDTH / 2 - 10, 200, PLAYER_LIFE)

        #                   initialize player's bullet                         #

        self.p_bullet0 = Player_Bullet(self.player.x + 10, self.player.y,
                                       PLAYER_DAMAGE, PLAYER_SPEED_X,
                                       PLAYER_SPEED_Y, PLAYER_WIDTH,
                                       PLAYER_HEIGHT)
        self.p_bullet1 = Player_Bullet(self.player.x + 10,
                                       self.player.y - DISTANCE, PLAYER_DAMAGE,
                                       PLAYER_SPEED_X, PLAYER_SPEED_Y,
                                       PLAYER_WIDTH, PLAYER_HEIGHT)
        self.p_bullet2 = Player_Bullet(self.player.x + 10,
                                       self.player.y - DISTANCE * 2,
                                       PLAYER_DAMAGE, PLAYER_SPEED_X,
                                       PLAYER_SPEED_Y, PLAYER_WIDTH,
                                       PLAYER_HEIGHT)
        self.left_p_bullet0 = Player_Bullet(self.player.x, self.player.y + 13,
                                            PLAYER_DAMAGE, PLAYER_SPEED_X,
                                            PLAYER_SPEED_Y, PLAYER_WIDTH,
                                            PLAYER_HEIGHT)
        self.right_p_bullet0 = Player_Bullet(self.player.x + 19,
                                             self.player.y + 13, PLAYER_DAMAGE,
                                             PLAYER_SPEED_X, PLAYER_SPEED_Y,
                                             PLAYER_WIDTH, PLAYER_HEIGHT)
        self.left_p_bullet1 = Player_Bullet(self.player.x,
                                            self.player.y + 13 - DISTANCE,
                                            PLAYER_DAMAGE, PLAYER_SPEED_X,
                                            PLAYER_SPEED_Y, PLAYER_WIDTH,
                                            PLAYER_HEIGHT)
        self.right_p_bullet1 = Player_Bullet(self.player.x + 19,
                                             self.player.y + 13 - DISTANCE,
                                             PLAYER_DAMAGE, PLAYER_SPEED_X,
                                             PLAYER_SPEED_Y, PLAYER_WIDTH,
                                             PLAYER_HEIGHT)
        self.left_p_bullet2 = Player_Bullet(self.player.x,
                                            self.player.y + 13 - DISTANCE * 2,
                                            PLAYER_DAMAGE, PLAYER_SPEED_X,
                                            PLAYER_SPEED_Y, PLAYER_WIDTH,
                                            PLAYER_HEIGHT)
        self.right_p_bullet2 = Player_Bullet(self.player.x + 19,
                                             self.player.y + 13 - DISTANCE * 2,
                                             PLAYER_DAMAGE, PLAYER_SPEED_X,
                                             PLAYER_SPEED_Y, PLAYER_WIDTH,
                                             PLAYER_HEIGHT)

        #                         initialize gift                              #

        self.gift_x = randint(0, WIDTH - 7)
        self.gift_y = 0
        self.gift = Gift(self.gift_x, self.gift_y)

        #                         initialize boss                              #

        self.Trump = Boss(TRUMP_LIFE, TRUMP_WIDTH, TRUMP_HEIGHT)
        self.head = Head(HEAD_LIFE, HEAD_WIDTH, HEAD_HEIGHT)

        #                         initialize enemy                             #

        self.enemy_speed = randint(1, 3)
        self.enemy0_x = randint(0, 41)
        self.enemy1_x = randint(51, 102)
        self.enemy2_x = randint(112, 155)
        self.enemy3_x = randint(0, 41)
        self.enemy4_x = randint(51, 102)
        self.enemy5_x = randint(112, 155)
        self.enemy0 = Enemy(self.enemy0_x, ENEMY_Y, round(uniform(1, 3), 1))
        self.enemy1 = Enemy(self.enemy1_x, ENEMY_Y, round(uniform(1, 3), 1))
        self.enemy2 = Enemy(self.enemy2_x, ENEMY_Y, round(uniform(1, 3), 1))
        self.enemy3 = Enemy(self.enemy3_x, ENEMY_Y, round(uniform(1, 3), 1))
        self.enemy4 = Enemy(self.enemy4_x, ENEMY_Y, round(uniform(1, 3), 1))
        self.enemy5 = Enemy(self.enemy5_x, ENEMY_Y, round(uniform(1, 3), 1))

        #                      initialize enemy bullet                         #

        self.smart_bullet0 = Smart_Bullet(self.enemy0.x + 10,
                                          self.enemy0.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)
        self.smart_bullet1 = Smart_Bullet(self.enemy1.x + 10,
                                          self.enemy1.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)
        self.smart_bullet2 = Smart_Bullet(self.enemy2.x + 10,
                                          self.enemy2.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)
        self.smart_bullet3 = Smart_Bullet(self.enemy3.x + 10,
                                          self.enemy3.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)
        self.smart_bullet4 = Smart_Bullet(self.enemy4.x + 10,
                                          self.enemy4.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)
        self.smart_bullet5 = Smart_Bullet(self.enemy5.x + 10,
                                          self.enemy5.y + 20, ENEMY_SMT_DAMAGE,
                                          ENEMY_SMT_SPEED, ENEMY_SMT_WIDTH,
                                          ENEMY_SMT_HEIGHT)

        #                     initialize Trump's bullet                        #

        self.boss_bullet0 = Boss_Bullet(self.Trump.x + 30, self.Trump.y + 30,
                                        40, -2.56, 1.56, 5, 5)
        self.boss_bullet1 = Boss_Bullet(self.Trump.x + 30, self.Trump.y + 30,
                                        40, -1.56, 2.56, 5, 5)
        self.boss_bullet2 = Boss_Bullet(self.Trump.x + 30, self.Trump.y + 30,
                                        40, 0, 3, 5, 5)
        self.boss_bullet3 = Boss_Bullet(self.Trump.x + 30, self.Trump.y + 30,
                                        40, 1.56, 2.56, 5, 5)
        self.boss_bullet4 = Boss_Bullet(self.Trump.x + 30, self.Trump.y + 30,
                                        40, 2.56, 1.56, 5, 5)

        #                   initialize Trump's smart bullet                    #

        self.boss_smart_bullet = Boss_Smart_Bullet(
            self.Trump.x + 30, self.Trump.y + 30, BOSS_SMT_DAMAGE,
            BOSS_SMT_SPEED, BOSS_SMT_WIDTH, BOSS_SMT_HEIGHT)

        #                     initialize head's bullet                         #

        self.head_bullet0 = Head_Bullet(self.head.x + 15, self.head.y + 15, 25,
                                        0, 5.5, 5, 5)
        self.head_bullet1 = Head_Bullet(self.head.x + 15, self.head.y + 15, 25,
                                        0, 5.5, 5, 5)
        self.head_bullet2 = Head_Bullet(self.head.x + 15, self.head.y + 15, 25,
                                        0, 5.5, 5, 5)
        self.head_bullet3 = Head_Bullet(self.head.x + 15, self.head.y + 15, 25,
                                        0, 5.5, 5, 5)
        self.head_bullet4 = Head_Bullet(self.head.x + 15, self.head.y + 15, 25,
                                        0, 5.5, 5, 5)

        ########################################################################
        #                        system information                            #
        ########################################################################

        self.state = 0  # 0: start page
        # 1: playing
        # 1: death page
        pp.init(WIDTH, HEIGHT, caption='Shoot Game', scale=3, fps=35)
        self.bgm = Bgm()
        self.bgm.landpage_music()
        pp.image(0).load(0, 0, "asset/space.png")
        pp.image(1).load(0, 0, "asset/elements.png")
        pp.run(self.update, self.draw)
Ejemplo n.º 14
0
    def __init__(self):
        pyxel.init(160, 120)
        pyxel.cls(0)

        # Give run the update/draw callbacks
        pyxel.run(self.update, self.draw)
Ejemplo n.º 15
0
 def __init__(self):
     pyxel.init(240, 180, caption='Pyxel')
     pyxel.run(self.update, self.draw)
Ejemplo n.º 16
0
 def run(self):
     pyxel.run(self.update, self.draw)
 def __init__(self):
     self.window = Window()
     Resource()
     self.pc = PlayerCharacter()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 18
0
 def __init__(self):
     pyxel.init(255, 255, caption='pyxel game')
     self.OneBit = OneBit()
     self.hero = Hero()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 19
0
 def __init__(self):
     pyxel.init(256, 256, caption="Global Game jame")
     self.player = Player(2, 2)
     self.camera = Camera(self.player)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 20
0
 def __init__(self):
     pyxel.init(120, 220, fps=60)
     pyxel.image(0).load(0, 0, 'block.png')
     self.reset()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 21
0
 def __init__(self, x, y, caption, fps):
     print(f"App(x = {x}, y = {y}, caption = {caption}, fps = {fps})")
     self.x = int(x / 2)
     self.y = int(y / 2)
     pyxel.init(x, y, caption=caption, fps=fps)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 22
0
 def __init__(self):
     pyxel.init(SCREEN_WIDTH, SCREEN_HEIGHT, title="Hello Pyxel")
     # update and draw()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 23
0
 def __init__(self):
     pyxel.init(100, 80)
     self.rect = Rect([pyxel.width / 2, pyxel.height / 2], [10, 10])
     self.circle = Circle([0, 0], 3)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 24
0
 def __init__(self):
     self.window = Window()
     Resource()
     self.pc = PlayerCharacter()
     print('DEFAULT_FPS:', pyxel.DEFAULT_FPS)
     pyxel.run(self.update, self.draw)
Ejemplo n.º 25
0
    def __init__(self, resource_file):
        resource_file = os.path.join(os.getcwd(), resource_file)
        root, ext = os.path.splitext(resource_file)
        if ext != RESOURCE_FILE_EXTENSION and ext != ".pyxel":
            resource_file += RESOURCE_FILE_EXTENSION

        pyxel.init(
            APP_WIDTH, APP_HEIGHT, caption="Pyxel Editor - {}".format(resource_file)
        )
        pyxel.mouse(True)

        if os.path.exists(resource_file):
            pyxel.load(resource_file)

        if ext == ".pyxel":
            resource_file = root + RESOURCE_FILE_EXTENSION

        super().__init__(None, 0, 0, pyxel.width, pyxel.height)

        self._resource_file = resource_file
        self._editor_list = [
            ImageEditor(self),
            TileMapEditor(self),
            SoundEditor(self),
            MusicEditor(self),
        ]
        self._editor_button = RadioButton(
            self, 1, 1, 3, EDITOR_IMAGE_X, EDITOR_IMAGE_Y, 4, 0
        )
        self._undo_button = ImageButton(
            self, 48, 1, 3, EDITOR_IMAGE_X + 36, EDITOR_IMAGE_Y
        )
        self._redo_button = ImageButton(
            self, 57, 1, 3, EDITOR_IMAGE_X + 45, EDITOR_IMAGE_Y
        )
        self._save_button = ImageButton(
            self, 75, 1, 3, EDITOR_IMAGE_X + 54, EDITOR_IMAGE_Y
        )
        self.help_message = ""

        self._editor_button.add_event_handler(
            "change", lambda value: self._set_editor(value)
        )
        self.add_event_handler("update", self.__on_update)
        self.add_event_handler("draw", self.__on_draw)
        self._undo_button.add_event_handler("press", self.__on_undo_button_press)
        self._undo_button.add_event_handler("repeat", self.__on_undo_button_press)
        self._redo_button.add_event_handler("press", self.__on_redo_button_press)
        self._redo_button.add_event_handler("repeat", self.__on_redo_button_press)
        self._save_button.add_event_handler("press", self.__on_save_button_press)
        self._editor_button.add_event_handler(
            "mouse_hover", self.__on_editor_button_mouse_hover
        )
        self._undo_button.add_event_handler(
            "mouse_hover", self.__on_undo_button_mouse_hover
        )
        self._redo_button.add_event_handler(
            "mouse_hover", self.__on_redo_button_mouse_hover
        )
        self._save_button.add_event_handler(
            "mouse_hover", self.__on_save_button_mouse_hover
        )

        image_file = os.path.join(
            os.path.dirname(__file__), "assets", EDITOR_IMAGE_NAME
        )
        pyxel.image(3, system=True).load(EDITOR_IMAGE_X, EDITOR_IMAGE_Y, image_file)

        self._set_editor(0)

        pyxel.run(self.update_widgets, self.draw_widgets)
Ejemplo n.º 26
0
if __name__ == "__main__":
    px.init(512, 512)
    px.load("thing.pyxres")

    angle = 0
    def update():
        global angle
        angle += 0.1

    def draw():
        global angle
        px.cls(7)

        points = np.array([[100,90],
    [90,97],
    [94,108],
    [106,108],
    [110,97]]) * 0.5 + 400

        mid = np.mean(points)
        t = points - mid

        p = np.array([t[:, 0] * np.cos(angle) - t[:, 1] * np.sin(angle) + mid, t[:, 0] * np.sin(angle) + t[:, 1] * np.cos(angle) + mid])
        print(p)
        print(p.T)
        

        drawPolygon(p.T)

    px.run(update, draw)
Ejemplo n.º 27
0
 def __init__(self):
     pyxel.init(240, 136, caption="WhatAmI", fps=60, scale=4)
     pyxel.load("whatami.pyxel")
     self.reset()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 28
0
 def __init__(self):
     pyxel.init(160, 120)
     self.begin()
     pyxel.run(self.update, self.draw)
Ejemplo n.º 29
0
    def __init__(self):
        # Initialize a window. Max size is 256x256 pixels.
        pyxel.init(255, 255)

        self.x = 10
        self.y = 10
        pyxel.mouse(True)

        # co-ordinates
        p = 128, 50

        l = 98, 60
        r = 158, 60

        ll = 68, 80
        lr = 108, 80

        rl = 148, 80
        rr = 188, 80

        lll = 58, 100
        llr = 78, 100

        lrl = 98, 100
        lrr = 118, 100

        rll = 138, 100
        rlr = 158, 100

        rrl = 178, 100
        rrr = 198, 100
        # parent
        self.n1 = Circle(p[0], p[1], 7, LO[0] + 1, LO[0])

        # layer2
        self.n2 = Circle(l[0], l[1], 7, LO[1] + 1, LO[1])
        self.n3 = Circle(r[0], r[1], 7, LO[2] + 1, LO[2])
        # layer 3
        self.n4 = Circle(ll[0], ll[1], 7, LO[3] + 1, LO[3])
        self.n5 = Circle(lr[0], lr[1], 7, LO[4] + 1, LO[4])

        self.n6 = Circle(rl[0], rl[1], 7, LO[5] + 1, LO[5])
        self.n7 = Circle(rr[0], rr[1], 7, LO[6] + 1, LO[6])
        # layer 4
        self.n8 = Circle(lll[0], lll[1], 7, LO[7] + 1, LO[7])
        self.n9 = Circle(llr[0], llr[1], 7, LO[8] + 1, LO[8])

        self.n10 = Circle(lrl[0], lrl[1], 7, LO[9] + 1, LO[9])
        self.n11 = Circle(lrr[0], lrr[1], 7, LO[10] + 1, LO[10])

        self.n12 = Circle(rll[0], rll[1], 7, LO[11] + 1, LO[11])
        self.n13 = Circle(rlr[0], rlr[1], 7, LO[12] + 1, LO[12])

        self.n14 = Circle(rrl[0], rrl[1], 7, LO[13] + 1, LO[13])
        self.n15 = Circle(rrr[0], rrr[1], 7, LO[14] + 1, LO[14])

        self.minButton = Circle(94, 158, 20, 8, 0)
        self.maxButton = Circle(164, 158, 20, 8, 0)

        # Clear the screen with color 0 (black). Max color is 15.
        pyxel.cls(0)

        pyxel.run(self.update, self.draw)
Ejemplo n.º 30
0
 def __init__(self):
     pyxel.init(255, 81, caption='Pyxel Color Palette')
     pyxel.run(self.update, self.draw)