Skip to content

Commit

Permalink
buer
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Nov 23, 2024
1 parent 2c58934 commit 31dbcf6
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 10 deletions.
Binary file added assets/entity/buer.aseprite
Binary file not shown.
Binary file modified assets/image/level.aseprite
Binary file not shown.
3 changes: 3 additions & 0 deletions src/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct GameAssets {
#[asset(path = "entity/eyeball.aseprite")]
pub eyeball: Handle<Aseprite>,

#[asset(path = "entity/buer.aseprite")]
pub buer: Handle<Aseprite>,

#[asset(path = "entity/stone_lantern.aseprite")]
pub stone_lantern: Handle<Aseprite>,

Expand Down
1 change: 1 addition & 0 deletions src/enemy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod basic;
pub mod buer;
pub mod eyeball;
pub mod slime;
80 changes: 80 additions & 0 deletions src/enemy/buer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
use crate::constant::*;
use crate::controller::enemy::Enemy;
use crate::entity::actor::{Actor, ActorFireState, ActorState};
use crate::entity::breakable::{Breakable, BreakableSprite};
use crate::entity::EntityDepth;
use crate::hud::life_bar::{spawn_life_bar, LifeBarResource};
use crate::spell::SpellType;
use crate::states::GameState;
use crate::wand::{Wand, WandType};
use bevy::prelude::*;
use bevy_aseprite_ultra::prelude::*;
use bevy_rapier2d::prelude::*;
use uuid::*;

#[derive(Component)]
pub struct Buer;

pub fn spawn_buer(commands: &mut Commands, aseprite: Handle<Aseprite>, position: Vec2) {
let mut slots = [None; MAX_SPELLS_IN_WAND];
// slots[0] = Some(spell);

commands.spawn((
Name::new("buer"),
StateScoped(GameState::InGame),
Enemy,
Buer,
Actor {
uuid: Uuid::new_v4(),
spell_delay: 0,
mana: 1000,
max_mana: 1000,
life: 15,
max_life: 20,
pointer: Vec2::ZERO,
intensity: 0.0,
move_direction: Vec2::ZERO,
move_force: 0.0,
fire_state: ActorFireState::Idle,
group: ENEMY_GROUP,
filter: ENTITY_GROUP | WALL_GROUP | WITCH_GROUP,
current_wand: 0,
effects: default(),
wands: [
Some(Wand {
wand_type: WandType::CypressWand,
slots,
index: 0,
}),
None,
None,
None,
],
},
ActorState::default(),
EntityDepth,
AsepriteAnimationBundle {
aseprite: aseprite,
animation: Animation::default().with_tag("idle"),
transform: Transform::from_translation(position.extend(0.0)),
..default()
},
(
RigidBody::Dynamic,
Collider::ball(48.0),
GravityScale(0.0),
LockedAxes::ROTATION_LOCKED,
Damping {
linear_damping: 10.0,
angular_damping: 1.0,
},
ExternalForce::default(),
ExternalImpulse::default(),
ActiveEvents::COLLISION_EVENTS,
CollisionGroups::new(
ENEMY_GROUP,
ENTITY_GROUP | WALL_GROUP | WITCH_GROUP | WITCH_BULLET_GROUP | ENEMY_GROUP,
),
),
));
}
2 changes: 1 addition & 1 deletion src/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ pub enum GameEntity {
Routes,
StoneLantern,
Spell,
Wand,
Crate,
Buer,
}

#[derive(Component)]
Expand Down
9 changes: 4 additions & 5 deletions src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::command::GameCommand;
use crate::config::GameConfig;
use crate::constant::*;
use crate::controller::player::Player;
use crate::enemy::buer::spawn_buer;
use crate::enemy::eyeball::spawn_eyeball;
use crate::enemy::slime::spawn_slime;
use crate::entity::book_shelf::spawn_book_shelf;
Expand All @@ -34,7 +35,6 @@ use crate::random::random_select_mut;
use crate::spell::SpellType;
use crate::spell::SPELL_TYPES;
use crate::states::GameState;
use crate::wand::WandType;
use bevy::asset::*;
use bevy::core::FrameCount;
use bevy::prelude::*;
Expand Down Expand Up @@ -424,12 +424,11 @@ fn spawn_entities(mut commands: &mut Commands, assets: &Res<GameAssets>, chunk:
InventoryItem::Spell(SpellType::MagicBolt),
);
}
GameEntity::Wand => {
spawn_dropped_item(
GameEntity::Buer => {
spawn_buer(
&mut commands,
&assets,
assets.buer.clone(),
Vec2::new(tx + TILE_HALF, ty - TILE_HALF),
InventoryItem::Wand(WandType::CypressWand),
);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/level/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,19 @@ pub fn image_to_tilemap(
});
entities.push((GameEntity::Spell, x, y));
}
(0, 255, 0, 255) => {
(102, 57, 49, 255) => {
tiles.push(LevelTileMapile {
tile: Tile::StoneTile,
biome: Biome::SafeZone,
});
entities.push((GameEntity::Wand, x, y));
entities.push((GameEntity::Crate, x, y));
}
(102, 57, 49, 255) => {
(184, 0, 255, 255) => {
tiles.push(LevelTileMapile {
tile: Tile::StoneTile,
biome: Biome::SafeZone,
});
entities.push((GameEntity::Crate, x, y));
entities.push((GameEntity::Buer, x, y));
}
_ => {
tiles.push(LevelTileMapile {
Expand Down

0 comments on commit 31dbcf6

Please sign in to comment.