Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions chapter10/src/assets/characters/characters.ron
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down Expand Up @@ -46,7 +47,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down Expand Up @@ -78,7 +80,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down Expand Up @@ -110,7 +113,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down Expand Up @@ -142,7 +146,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down Expand Up @@ -174,7 +179,8 @@
animations: {
Walk: (
start_row: 8,
frame_count: 9,
start_column: 1,
frame_count: 8,
frame_time: 0.1,
directional: true,
),
Expand Down
6 changes: 3 additions & 3 deletions chapter10/src/characters/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub struct AnimationClip {
}

impl AnimationClip {
pub fn new(row: usize, frame_count: usize, atlas_columns: usize) -> Self {
let first = row * atlas_columns;
pub fn new(row: usize, column_offset: usize, frame_count: usize, atlas_columns: usize) -> Self {
let first = (row * atlas_columns) + column_offset;
Self {
first,
last: first + frame_count - 1,
Expand Down Expand Up @@ -67,7 +67,7 @@ impl AnimationController {
def.start_row
};

Some(AnimationClip::new(row, def.frame_count, config.atlas_columns))
Some(AnimationClip::new(row, def.start_column, def.frame_count, config.atlas_columns))
}
}

Expand Down
2 changes: 2 additions & 0 deletions chapter10/src/characters/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub enum AnimationType {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AnimationDefinition {
pub start_row: usize,
#[serde(default)]
pub start_column: usize,
pub frame_count: usize,
pub frame_time: f32,
pub directional: bool, // true = 4 rows (one per direction), false = 1 row
Expand Down