This looks better
This commit is contained in:
parent
5262c7b896
commit
4fa4fc2b55
4
DR.py
4
DR.py
@ -49,14 +49,12 @@ def main() -> None:
|
||||
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')
|
||||
from libs.pyglet_rs import get_version_str
|
||||
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/']
|
||||
|
@ -11,9 +11,9 @@ pyglet_rs is a python library that patches pyglet to use rust to make it faster!
|
||||
**This Folder may be move to an individual repo. here is just a temp location**
|
||||
|
||||
## requirements
|
||||
- python `3.8+`
|
||||
- pyglet `2.0+`
|
||||
- pyo3 `0.18.1`
|
||||
- `python 3.8+`
|
||||
- `pyglet 2.0+`
|
||||
- `rustc 1.68.1+`
|
||||
- no more
|
||||
|
||||
## status
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* -------------------------------
|
||||
* Difficult Rocket
|
||||
* Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
||||
* All rights reserved
|
||||
* -------------------------------
|
||||
*/
|
||||
|
||||
|
||||
pub mod python_class {
|
||||
use pyo3::prelude::*;
|
||||
|
||||
use crate::math::matrix::{Matrix3, Matrix4};
|
||||
use crate::math::vector::{Vector2, Vector3, Vector4};
|
||||
|
||||
#[pyclass(name = "Vector2")]
|
||||
pub struct PyVector2 {
|
||||
pub data: Vector2,
|
||||
}
|
||||
|
||||
#[pyclass(name = "Vector3")]
|
||||
pub struct PyVector3 {
|
||||
pub data: Vector3,
|
||||
}
|
||||
|
||||
#[pyclass(name = "Vector4")]
|
||||
pub struct PyVector4 {
|
||||
pub data: Vector4,
|
||||
}
|
||||
|
||||
#[pyclass(name = "Matrix3")]
|
||||
pub struct PyMatrix3 {
|
||||
pub data: Matrix3,
|
||||
}
|
||||
|
||||
#[pyclass(name = "Matrix4")]
|
||||
pub struct PyMatrix4 {
|
||||
pub data: Matrix4,
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub trait PyCalc {
|
||||
fn __add__(&self, other: &Self) -> Self;
|
||||
fn __sub__(&self, other: &Self) -> Self;
|
||||
fn __mul__(&self, other: &Self) -> Self;
|
||||
fn __truediv__(&self, other: &Self) -> Self;
|
||||
fn __floordiv__(&self, other: &Self) -> Self;
|
||||
fn __abs__(&self) -> f64;
|
||||
fn __neg__(&self) -> Self;
|
||||
fn __round__(&self, ndigits: Option<i64>) -> Self;
|
||||
fn __radd__(&self, other: &PyAny) -> Self;
|
||||
fn __eq__(&self, other: &Self) -> bool;
|
||||
fn __ne__(&self, other: &Self) -> bool;
|
||||
}
|
||||
|
||||
/// 这是一个用来自动给 impl xxx for xxx 的块去掉 trait 部分的宏
|
||||
/// 用于在为 pyclass 实现
|
||||
|
||||
#[pymethods]
|
||||
impl PyVector2 {
|
||||
#[new]
|
||||
fn py_new(x: f64, y: f64) -> Self {
|
||||
return Self {
|
||||
data: Vector2::new(x, y),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl PyVector2 {
|
||||
fn __add__(&self, other: &Self) -> Self {
|
||||
return Self {
|
||||
data: self.data + other.data,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user