diff --git a/assets/shocked-miguel.ldtk b/assets/shocked-miguel.ldtk index 11d47f3..e27eaeb 100644 --- a/assets/shocked-miguel.ldtk +++ b/assets/shocked-miguel.ldtk @@ -11,7 +11,7 @@ "iid": "ee0ceef0-73f0-11ef-b8f3-3f3814adfda6", "jsonVersion": "1.5.3", "appBuildId": 473703, - "nextUid": 58, + "nextUid": 60, "identifierStyle": "Capitalize", "toc": [], "worldLayout": "LinearHorizontal", @@ -760,7 +760,82 @@ "limitBehavior": "MoveLastOne", "pivotX": 0.5, "pivotY": 1, - "fieldDefs": [] + "fieldDefs": [ + { + "identifier": "animation_timer", + "doc": null, + "__type": "Float", + "uid": 58, + "type": "F_Float", + "isArray": false, + "canBeNull": false, + "arrayMinLength": null, + "arrayMaxLength": null, + "editorDisplayMode": "Hidden", + "editorDisplayScale": 1, + "editorDisplayPos": "Above", + "editorLinkStyle": "StraightArrow", + "editorDisplayColor": null, + "editorAlwaysShow": false, + "editorShowInWorld": true, + "editorCutLongValues": true, + "editorTextSuffix": null, + "editorTextPrefix": null, + "useForSmartColor": false, + "exportToToc": false, + "searchable": false, + "min": null, + "max": null, + "regex": null, + "acceptFileTypes": null, + "defaultOverride": { "id": "V_Float", "params": [0.3] }, + "textLanguageMode": null, + "symmetricalRef": false, + "autoChainRef": true, + "allowOutOfLevelRef": true, + "allowedRefs": "OnlySame", + "allowedRefsEntityUid": null, + "allowedRefTags": [], + "tilesetUid": null + }, + { + "identifier": "animation_indices", + "doc": null, + "__type": "Array", + "uid": 59, + "type": "F_Int", + "isArray": true, + "canBeNull": false, + "arrayMinLength": 2, + "arrayMaxLength": 2, + "editorDisplayMode": "Hidden", + "editorDisplayScale": 1, + "editorDisplayPos": "Above", + "editorLinkStyle": "StraightArrow", + "editorDisplayColor": null, + "editorAlwaysShow": false, + "editorShowInWorld": true, + "editorCutLongValues": true, + "editorTextSuffix": null, + "editorTextPrefix": null, + "useForSmartColor": false, + "exportToToc": false, + "searchable": false, + "min": null, + "max": null, + "regex": null, + "acceptFileTypes": null, + "defaultOverride": { "id": "V_Int", "params": [0] }, + "textLanguageMode": null, + "symmetricalRef": false, + "autoChainRef": true, + "allowOutOfLevelRef": true, + "allowedRefs": "OnlySame", + "allowedRefsEntityUid": null, + "allowedRefTags": [], + "tilesetUid": null + } + ] }, { "identifier": "Goal", @@ -1251,7 +1326,10 @@ "height": 16, "defUid": 14, "px": [40,144], - "fieldInstances": [] + "fieldInstances": [ + { "__identifier": "animation_timer", "__type": "Float", "__value": 0.3, "__tile": null, "defUid": 58, "realEditorValues": [] }, + { "__identifier": "animation_indices", "__type": "Array", "__value": [0,3], "__tile": null, "defUid": 59, "realEditorValues": [ { "id": "V_Int", "params": [0] }, { "id": "V_Int", "params": [3] } ] } + ] }, { "__identifier": "Goal", @@ -2044,7 +2122,10 @@ "height": 16, "defUid": 14, "px": [24,160], - "fieldInstances": [] + "fieldInstances": [ + { "__identifier": "animation_timer", "__type": "Float", "__value": 0.3, "__tile": null, "defUid": 58, "realEditorValues": [] }, + { "__identifier": "animation_indices", "__type": "Array", "__value": [0,3], "__tile": null, "defUid": 59, "realEditorValues": [ { "id": "V_Int", "params": [0] }, { "id": "V_Int", "params": [3] } ] } + ] }, { "__identifier": "Goal", @@ -2916,7 +2997,10 @@ "height": 16, "defUid": 14, "px": [64,176], - "fieldInstances": [] + "fieldInstances": [ + { "__identifier": "animation_timer", "__type": "Float", "__value": 0.3, "__tile": null, "defUid": 58, "realEditorValues": [] }, + { "__identifier": "animation_indices", "__type": "Array", "__value": [0,3], "__tile": null, "defUid": 59, "realEditorValues": [ null, { "id": "V_Int", "params": [3] } ] } + ] }, { "__identifier": "Goal", diff --git a/src/main.rs b/src/main.rs index 58908d4..a25a4de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use animations::ShockingAnimationPlugin; use bevy::prelude::*; use bevy_ecs_ldtk::prelude::*; use bevy_rapier2d::plugin::{NoUserData, RapierConfiguration, RapierPhysicsPlugin, TimestepMode}; @@ -8,6 +9,7 @@ use level_structure::{WallBundle, WallPlugin}; use logging::log_positions; use player::PlayerPlugin; +mod animations; mod camera; mod colliders; mod goal; @@ -45,8 +47,9 @@ fn main() { .register_ldtk_int_cell::(1) .add_systems(Startup, setup) .add_plugins(CameraPlugin) + .add_plugins(ShockingAnimationPlugin) .add_systems(Update, (translate_grid_coords_entities, check_goal)) - .add_systems(Update, log_positions) + // .add_systems(Update, log_positions) .run(); } diff --git a/src/player.rs b/src/player.rs index 5c1ccd5..78a22be 100644 --- a/src/player.rs +++ b/src/player.rs @@ -2,7 +2,11 @@ use bevy::prelude::*; use bevy_ecs_ldtk::prelude::*; use bevy_rapier2d::dynamics::Velocity; -use crate::{colliders::ColliderBundle, ground_detection::GroundDetection}; +use crate::{ + animations::{AnimationIndices, AnimationTimer}, + colliders::ColliderBundle, + ground_detection::GroundDetection, +}; pub struct PlayerPlugin; @@ -35,6 +39,10 @@ struct PlayerBundle { pub ground_detection: GroundDetection, #[from_entity_instance] pub collider_bundle: ColliderBundle, + #[from_entity_instance] + animation_timer: AnimationTimer, + #[from_entity_instance] + animation_indices: AnimationIndices, } fn player_movement( @@ -72,5 +80,4 @@ fn player_movement( velocity.linvel.y = 500.; } } - }