rendering works in pure ECS. This is actually pretty sweet. broke compu rendering though

This commit is contained in:
2020-09-17 23:55:21 -07:00
parent 76c75c349b
commit 34b5d7b3d0
11 changed files with 429 additions and 213 deletions

View File

@@ -6,26 +6,12 @@ use crate::util::vertex::{VertexTypeContainer, TextureVertex3D, Vertex3D};
use winit::event::{DeviceEvent, MouseButton, ElementState, Event, WindowEvent};
use crate::util::tr_event::{TrEvent, TrWindowEvent, TrUIEvent};
pub struct Geometry {
pos_x: f32,
pos_y: f32,
size_x: f32,
size_y: f32,
rotation: f32,
depth: f32,
}
pub struct Velocity {
vel_x: f32,
vel_y: f32,
vel_r: f32,
}
///
#[derive(Debug, Clone)]
pub struct Sprite {
texture_handle: Arc<CanvasTextureHandle>,
geometry: Geometry,
velocity: Velocity,
}
/// Container class which implements drawable.
@@ -78,19 +64,7 @@ impl Sprite {
pub fn new(texture_handle: Arc<CanvasTextureHandle>) -> Sprite {
Sprite {
texture_handle: texture_handle.clone(),
geometry: Geometry {
pos_x: 0.0,
pos_y: 0.0,
size_x: 0.0,
size_y: 0.0,
rotation: 0.0,
depth: 0.0
},
velocity: Velocity {
vel_x: 0.0,
vel_y: 0.0,
vel_r: 0.0
}
}
}
}
@@ -112,25 +86,25 @@ impl Drawable for Sprite {
self.texture_handle.clone())
]
}
fn update<T>(&self, delta_time: f32) -> Vec<TrUIEvent<T>> {
Vec::new()
}
fn notify<Y, T>(&self, tr_event: Vec<TrEvent<Y>>, ui_events: Vec<TrUIEvent<T>>) -> Vec<TrUIEvent<T>> {
match tr_event {
TrEvent::WindowEvent { event: TrWindowEvent::MouseInput { device_id, state, button, modifiers }, .. } => {
match button {
MouseButton::Left => {
if *state == ElementState::Pressed {
}
}
_ => {}
}
}
_ => {}
}
Vec::new()
}
//
// fn update<T>(&self, delta_time: f32) -> Vec<TrUIEvent<T>> {
// Vec::new()
// }
//
// fn notify<Y, T>(&self, tr_event: Vec<TrEvent<Y>>, ui_events: Vec<TrUIEvent<T>>) -> Vec<TrUIEvent<T>> {
// match tr_event {
// TrEvent::WindowEvent { event: TrWindowEvent::MouseInput { device_id, state, button, modifiers }, .. } => {
// match button {
// MouseButton::Left => {
// if *state == ElementState::Pressed {
//
// }
// }
// _ => {}
// }
// }
// _ => {}
// }
// Vec::new()
// }
}