My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/games/rstnode/rst-client/src/graphics/entities/mod.rs

43 lines
946 B

//! Game entity rendering
//!
//! Generally the naming convention should be: `{type}Rndr`
//! (`Renderer`, but shorter).
use super::prelude::*;
use rst_core::data::Node;
use std::sync::Arc;
/// A set of universal X/Y coordinates
pub struct Coordinates(pub f32, pub f32);
impl<'a> From<&'a Coordinates> for Point2<f32> {
fn from(c: &'a Coordinates) -> Self {
Point2 { x: c.0, y: c.1 }
}
}
pub struct NodeRndr {
pub loc: Coordinates,
pub inner: Arc<Node>,
}
impl EventHandler for NodeRndr {
fn update(&mut self, _: &mut Context) -> GameResult<()> {
Ok(())
}
fn draw(&mut self, ctx: &mut Context) -> GameResult<()> {
let circ = Mesh::new_circle(
ctx,
DrawMode::fill(),
Point2::from(&self.loc),
128.0,
0.1,
graphics::WHITE,
).unwrap();
circ.draw(ctx, DrawParam::new()).unwrap();
Ok(())
}
}