1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//! Graphics module
//!
//! Each entity in the game has a graphics companion object in
//! [`entities`](self::entities), which knows how to render a given
//! object. Different game screens and UI elements can be found in
//! [`ui`](self::ui).
pub mod entities;
pub mod ui;
mod vector2;
pub use vector2::*;
use crate::state::ClientState;
use ggez::{Context, GameResult};
use std::ops::{Add, Mul, Sub};
/// A utility module to include everything required to implement a
/// graphics entity
pub(self) mod prelude {
pub use ggez::{
event::EventHandler,
graphics::{self, DrawMode, DrawParam, Drawable, Mesh},
Context, GameResult,
};
pub use mint::Point2;
pub use super::Renderer;
pub use crate::state::ClientState;
}
/// A rendering trait which is given graphics context, and game state
pub trait Renderer {
fn update(&mut self, _state: &mut ClientState, _ctx: &mut Context) -> GameResult<()>;
fn draw(&self, _state: &ClientState, _ctx: &mut Context) -> GameResult<()>;
}
|