2023-02-19 06:51:37 +00:00
|
|
|
pub mod raylib_impl;
|
|
|
|
|
2023-02-14 09:55:36 +00:00
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
use crate::faux_quicksilver::{Circle, Color, Rectangle, Transform, Vector};
|
2023-02-13 09:53:04 +00:00
|
|
|
|
|
|
|
pub trait ImageInterface {
|
2023-02-15 06:52:25 +00:00
|
|
|
fn draw(&mut self, x: f32, y: f32, color: Color) -> Result<(), String>;
|
|
|
|
fn draw_sub(&mut self, sub_rect: Rectangle, x: f32, y: f32, color: Color)
|
|
|
|
-> Result<(), String>;
|
|
|
|
fn draw_transform(
|
|
|
|
&mut self,
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
color: Color,
|
|
|
|
transform: Transform,
|
2023-02-19 08:05:30 +00:00
|
|
|
origin: Vector,
|
2023-02-15 06:52:25 +00:00
|
|
|
) -> Result<(), String>;
|
|
|
|
fn draw_sub_transform(
|
|
|
|
&mut self,
|
|
|
|
sub_rect: Rectangle,
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
color: Color,
|
|
|
|
transform: Transform,
|
2023-02-19 08:05:30 +00:00
|
|
|
origin: Vector,
|
2023-02-15 06:52:25 +00:00
|
|
|
) -> Result<(), String>;
|
2023-02-14 09:55:36 +00:00
|
|
|
fn get_w(&self) -> usize;
|
|
|
|
fn get_h(&self) -> usize;
|
|
|
|
fn get_wh_rect(&self) -> Rectangle;
|
2023-02-13 09:53:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait FontInterface {
|
2023-02-16 08:53:03 +00:00
|
|
|
fn draw(&mut self, s: &str, size: u32, x: f32, y: f32, color: Color) -> Result<(), String>;
|
2023-02-13 09:53:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait SoundInterface {
|
2023-02-14 09:55:36 +00:00
|
|
|
fn play(&mut self, vol: f32) -> Result<(), String>;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait MusicInterface {
|
|
|
|
fn play(&mut self, vol: f32) -> Result<(), String>;
|
|
|
|
fn pause(&mut self) -> Result<(), String>;
|
|
|
|
fn stop(&mut self) -> Result<(), String>;
|
2023-02-15 06:52:25 +00:00
|
|
|
fn set_loop(&mut self, loop_enable: bool) -> Result<(), String>;
|
2023-02-19 07:52:52 +00:00
|
|
|
fn update(&mut self) -> Result<(), String>;
|
2023-02-15 06:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait CameraInterface {
|
|
|
|
fn get_view(&self) -> Result<Rectangle, String>;
|
|
|
|
fn get_view_xy(&self) -> Result<(f32, f32), String>;
|
|
|
|
fn set_view(&mut self, rect: Rectangle) -> Result<(), String>;
|
|
|
|
fn set_view_xy(&mut self, x: f32, y: f32) -> Result<(), String>;
|
2023-02-13 09:53:04 +00:00
|
|
|
}
|
|
|
|
|
2023-02-14 09:55:36 +00:00
|
|
|
pub trait GameInterface {
|
2023-02-13 09:53:04 +00:00
|
|
|
fn get_dimensions(&self) -> Result<(f32, f32), String>;
|
2023-02-14 09:55:36 +00:00
|
|
|
fn get_key_pressed(&mut self, key: char) -> Result<bool, String>;
|
|
|
|
fn get_mouse_pressed(&mut self) -> Result<Option<(f32, f32)>, String>;
|
2023-02-16 08:53:03 +00:00
|
|
|
fn get_mouse_down(&mut self) -> Result<Option<(f32, f32)>, String>;
|
|
|
|
fn get_mouse_xy(&self) -> Result<(f32, f32), String>;
|
|
|
|
fn get_mouse_xy_vec(&self) -> Result<Vector, String>;
|
2023-02-15 06:52:25 +00:00
|
|
|
fn get_delta_time(&self) -> f32;
|
2023-02-14 09:55:36 +00:00
|
|
|
fn clear_window(&mut self, color: Color) -> Result<(), String>;
|
|
|
|
fn begin_drawing(&mut self) -> Result<(), String>;
|
|
|
|
fn end_drawing(&mut self) -> Result<(), String>;
|
|
|
|
|
|
|
|
fn draw_circle(&mut self, circle: Circle, color: Color) -> Result<(), String>;
|
|
|
|
fn draw_circle_ex(
|
|
|
|
&mut self,
|
|
|
|
circle: Circle,
|
|
|
|
color: Color,
|
|
|
|
origin: Vector,
|
|
|
|
rot: f32,
|
|
|
|
) -> Result<(), String>;
|
|
|
|
fn draw_circle_transform(
|
|
|
|
&mut self,
|
|
|
|
circle: Circle,
|
|
|
|
color: Color,
|
|
|
|
transform: Transform,
|
2023-02-19 08:05:30 +00:00
|
|
|
origin: Vector,
|
2023-02-14 09:55:36 +00:00
|
|
|
) -> Result<(), String>;
|
|
|
|
fn draw_rect(&mut self, rect: Rectangle, color: Color) -> Result<(), String>;
|
|
|
|
fn draw_rect_ex(
|
|
|
|
&mut self,
|
|
|
|
rect: Rectangle,
|
|
|
|
color: Color,
|
|
|
|
origin: Vector,
|
|
|
|
rot: f32,
|
|
|
|
) -> Result<(), String>;
|
|
|
|
fn draw_rect_transform(
|
|
|
|
&mut self,
|
|
|
|
rect: Rectangle,
|
|
|
|
color: Color,
|
|
|
|
transform: Transform,
|
2023-02-19 08:05:30 +00:00
|
|
|
origin: Vector,
|
2023-02-14 09:55:36 +00:00
|
|
|
) -> Result<(), String>;
|
|
|
|
|
|
|
|
fn load_image(&mut self, path: &Path) -> Result<Box<dyn ImageInterface>, String>;
|
|
|
|
fn load_font(&mut self, path: &Path) -> Result<Box<dyn FontInterface>, String>;
|
|
|
|
fn load_sound(&mut self, path: &Path) -> Result<Box<dyn SoundInterface>, String>;
|
|
|
|
fn load_music(&mut self, path: &Path) -> Result<Box<dyn MusicInterface>, String>;
|
2023-02-15 06:52:25 +00:00
|
|
|
|
|
|
|
fn get_camera(&mut self) -> Result<Box<dyn CameraInterface>, String>;
|
|
|
|
fn get_default_camera(&mut self) -> Result<Box<dyn CameraInterface>, String>;
|
|
|
|
fn set_camera(&mut self, camera: &Box<dyn CameraInterface>) -> Result<(), String>;
|
2023-02-13 09:53:04 +00:00
|
|
|
}
|