working on animaiton
This commit is contained in:
parent
12ed150a17
commit
c0ad24029a
@ -48,9 +48,9 @@ impl FrameAnimationWrapper {
|
||||
}
|
||||
|
||||
/// Draw the next frame to the screen at `position`
|
||||
pub fn draw(&mut self, handle: &mut RaylibDrawHandle, position: Vector2) {
|
||||
pub fn draw(&mut self, handle: &mut RaylibDrawHandle, position: Vector2, rotation: f32) {
|
||||
let frame_id = self.get_current_frame_id(handle);
|
||||
self.draw_frame(handle, position, frame_id);
|
||||
self.draw_frame(handle, position, rotation, frame_id);
|
||||
}
|
||||
|
||||
/// Draw a specified frame to the screen at `position`
|
||||
@ -58,6 +58,7 @@ impl FrameAnimationWrapper {
|
||||
&mut self,
|
||||
handle: &mut RaylibDrawHandle,
|
||||
position: Vector2,
|
||||
rotation: f32,
|
||||
frame_number: u32,
|
||||
) {
|
||||
// Determine the col number
|
||||
@ -76,7 +77,13 @@ impl FrameAnimationWrapper {
|
||||
height: self.size.y,
|
||||
};
|
||||
|
||||
// Rotation origin
|
||||
let origin = Vector2 {
|
||||
x: self.size.x,
|
||||
y: self.size.y
|
||||
};
|
||||
|
||||
// Render
|
||||
handle.draw_texture_rec(&mut self.sprite_sheet, frame_box, position, Color::WHITE);
|
||||
handle.draw_texture_pro(&mut self.sprite_sheet, frame_box, position, origin, rotation, Color::WHITE);
|
||||
}
|
||||
}
|
||||
|
32
src/lib/wrappers/complexanimation.rs
Normal file
32
src/lib/wrappers/complexanimation.rs
Normal file
@ -0,0 +1,32 @@
|
||||
use std::usize;
|
||||
|
||||
use raylib::prelude::*;
|
||||
|
||||
pub struct FrameRange {
|
||||
pub min: usize,
|
||||
pub max: usize,
|
||||
}
|
||||
|
||||
pub struct ComplexAnimationTool {
|
||||
sprite_sheet: Texture2D,
|
||||
frames_per_second: f32,
|
||||
frame_size: Vector2,
|
||||
sprite_sheet_size_frames: Vector2
|
||||
}
|
||||
|
||||
impl ComplexAnimationTool {
|
||||
pub fn render_loop(&self, context_2d: &mut RaylibMode2D<RaylibDrawHandle>, bounds: Rectangle, rotation: f32, range: &FrameRange) {
|
||||
|
||||
}
|
||||
|
||||
pub fn render_frame(&self, context_2d: &mut RaylibMode2D<RaylibDrawHandle>, bounds: Rectangle, rotation: f32, id: usize) {
|
||||
|
||||
// Convert the ID to an xy
|
||||
let col_id = id % self.sprite_sheet_size_frames.x as usize;
|
||||
let row_id = id / self.sprite_sheet_size_frames.y as usize;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
pub mod audio;
|
||||
pub mod animation;
|
||||
pub mod complexanimation;
|
Reference in New Issue
Block a user