view pytouhou/vm/__init__.py @ 772:7492d384d122 default tip

Rust: Add a Glide renderer (2D only for now) This is an experiment for a Rust renderer, iterating over the Python data using pyo3. It requires --feature=glide to be passed to cargo build, doesn’t support NPOT textures, text rendering, the background, or even msg faces, some of that may come in a future changeset.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 05 Sep 2022 17:53:36 +0200
parents d1f0bb0b7a17
children
line wrap: on
line source

from .anmrunner import ANMRunner
from .msgrunner import MSGRunner
from .eclrunner import ECLMainRunner


class PythonMainRunner:
    def __init__(self, main, game):
        self.main = main
        self.game = game

    def run_iter(self):
        self.main(self.game)


class EnemyRunner:
    def __init__(self, enemy, game, sub):
        self.enemy = enemy
        self.game = game
        self.sub = sub

    def run_iteration(self):
        self.sub(self.enemy, self.game)


def spawn_enemy(game, sub, x=0., y=0., life=1, item=-1, score=0, mirrored=False, random=False):
    instr_type = (2 if mirrored else 0) | (4 if random else 0)
    enemy = game.new_enemy((x, y, 0.), life, instr_type, item, score)
    enemy.process = EnemyRunner(enemy, game, sub)
    enemy.process.run_iteration()