try use pyglet_rs

This commit is contained in:
shenjack 2023-03-25 12:34:02 +08:00
parent a1aa251ce5
commit 29b9c4be59
3 changed files with 31 additions and 0 deletions

10
DR.py
View File

@ -48,6 +48,16 @@ def main() -> None:
from Difficult_Rocket.exception import TestError
from Difficult_Rocket import crash
from Difficult_Rocket import DR_option
try:
from libs.pyglet_rs import Sprite, get_version_str
print('pyglet_rs import success')
print('pyglet_rs available:', get_version_str())
except ImportError as e:
print('pyglet_rs import error')
traceback.print_exc()
print(f"{e=}")
try:
from libs import pyglet # 导入pyglet
pyglet.resource.path = ['/textures/']

View File

@ -0,0 +1,15 @@
# -------------------------------
# Difficult Rocket
# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
# All rights reserved
# -------------------------------
from .lib import *
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pyglet.event import EventDispatcher
class Sprite(EventDispatcher):
...

View File

@ -10,9 +10,15 @@ mod sprite;
use pyo3::prelude::*;
#[pyfunction]
fn get_version_str() -> String {
return "0.1.0".to_string();
}
#[pymodule]
#[pyo3(name = "pyglet_rs")]
fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(get_version_str, m)?)?;
m.add_class::<sprite::Sprite>()?;
Ok(())
}