What a Night Mare

This commit is contained in:
shenjack 2023-03-28 18:03:34 +08:00
parent 2d2d56807c
commit 619341b196
2 changed files with 7 additions and 3 deletions

View File

@ -63,10 +63,7 @@ pub mod python_class {
data: Vector2::new(x, y), data: Vector2::new(x, y),
}; };
} }
}
#[pymethods]
impl PyVector2 {
fn __add__(&self, other: &Self) -> Self { fn __add__(&self, other: &Self) -> Self {
return Self { return Self {
data: self.data + other.data, data: self.data + other.data,

View File

@ -13,12 +13,14 @@ use pyo3::prelude::*;
/// See the module documentation for usage. /// See the module documentation for usage.
#[pyclass(name = "Sprite_rs", subclass)] #[pyclass(name = "Sprite_rs", subclass)]
#[pyo3(text_signature = "(img, x=0.0, y=0.0, z=0.0, \ #[pyo3(text_signature = "(img, x=0.0, y=0.0, z=0.0, \
blend_src=770, blend_dest=771, \
batch=None, group=None, \ batch=None, group=None, \
subpixel=False, program=None)")] subpixel=False, program=None)")]
pub struct Sprite { pub struct Sprite {
// render // render
pub subpixel: bool, pub subpixel: bool,
pub batch: Py<PyAny>, pub batch: Py<PyAny>,
pub group: Option<Py<PyAny>>,
pub user_group: Option<Py<PyAny>>, pub user_group: Option<Py<PyAny>>,
pub group_class: Py<PyAny>, pub group_class: Py<PyAny>,
// view // view
@ -76,6 +78,8 @@ impl Sprite {
x: f64, x: f64,
y: f64, y: f64,
z: f64, z: f64,
blend_src: u32, // default 770 (GL_SRC_ALPHA)
blend_dest: u32, // default 771 (GL_ONE_MINUS_SRC_ALPHA)
batch_: &PyAny, batch_: &PyAny,
group: &PyAny, group: &PyAny,
subpixel: bool, subpixel: bool,
@ -154,10 +158,13 @@ impl Sprite {
} else { } else {
batch = batch_; batch = batch_;
} }
// 385
let group = sprite_group_class.call1((texture, blend_src, blend_dest, program, group));
Sprite { Sprite {
subpixel, subpixel,
batch: batch.into(), batch: batch.into(),
group: Some(group.into()),
user_group: Some(group.into()), user_group: Some(group.into()),
group_class: group.into(), group_class: group.into(),
x, x,