Skip to content

Commit

Permalink
refine book shelf
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Nov 3, 2024
1 parent ad3d122 commit 2859022
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 14 deletions.
Binary file modified assets/image/asset.aseprite
Binary file not shown.
Binary file modified docs/assets/image/asset.aseprite
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=assets/favicon.png rel=icon><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="EQsjDQ6rnZ8+uod9vZFYWA==" type=module>import init, * as bindings from './magiaboost-5bdd60a7011b2e87.js';
const wasm = await init('./magiaboost-5bdd60a7011b2e87_bg.wasm');
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=assets/favicon.png rel=icon><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="7IE5vAKuIytAU3JO9g9JNQ==" type=module>import init, * as bindings from './magiaboost-5541238713fcb20e.js';
const wasm = await init('./magiaboost-5541238713fcb20e_bg.wasm');


window.wasmBindings = bindings;


dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title>Magia Boost 0.1</title><link crossorigin href=./magiaboost-5bdd60a7011b2e87.js integrity=sha384-HuokoSX1m5iA3jc8vzMnKe6LFEcFwSJNEpfHS7B7cv1RUKY2hVupQ3b/bKH+p0W3 rel=modulepreload><link as=fetch crossorigin href=./magiaboost-5bdd60a7011b2e87_bg.wasm integrity=sha384-J8ia1MGPk5lt9YIPBEXM4ZSdTjGUgt8DhOL1xeMz0AIHiZ3/ra5R/Y/lmHuJeAJi rel=preload type=application/wasm></head><body></body></html>
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title>Magia Boost 0.1</title><link crossorigin href=./magiaboost-5541238713fcb20e.js integrity=sha384-r/wB2Fw0ATsCCcuxjHdHnayEZdvQ5dGc2xZDDU6WFJSuKUoaLxNe6kC2zGhMNY7U rel=modulepreload><link as=fetch crossorigin href=./magiaboost-5541238713fcb20e_bg.wasm integrity=sha384-SWEsD0uoX7GeDHiWcxb4030v3jQIE9s3Isiugx6VbtLF+a4YQ/JBp9oIksWGfoGJ rel=preload type=application/wasm></head><body></body></html>

Large diffs are not rendered by default.

Binary file not shown.
1 change: 1 addition & 0 deletions src/controller/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ fn receive_events(
golds,
last_update: *frame_count,
},
true,
);
info!("Remote player spawned: {}", uuid);
}
Expand Down
2 changes: 2 additions & 0 deletions src/entity.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod actor;
pub mod book_shelf;
pub mod breakable;
pub mod broken_magic_circle;
pub mod bullet;
pub mod chest;
pub mod gold;
Expand All @@ -22,6 +23,7 @@ pub enum GameEntity {
Chest,
BookShelf,
MagicCircle,
BrokenMagicCircle,
}

#[derive(Component)]
Expand Down
25 changes: 25 additions & 0 deletions src/entity/broken_magic_circle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::{constant::*, states::GameState};
use bevy::prelude::*;
use bevy_aseprite_ultra::prelude::*;

#[derive(Component)]
pub struct BrokenMagicCircle;

pub fn spawn_broken_magic_circle(
commands: &mut Commands,
aseprite: Handle<Aseprite>,
x: f32,
y: f32,
) {
commands.spawn((
Name::new("broken_magic_circle"),
StateScoped(GameState::InGame),
BrokenMagicCircle,
AsepriteSliceBundle {
aseprite: aseprite,
slice: "broken_magic_circle".into(),
transform: Transform::from_translation(Vec3::new(x, y, PAINT_LAYER_Z)),
..default()
},
));
}
2 changes: 1 addition & 1 deletion src/entity/chest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn break_chest(
commands.entity(entity).despawn_recursive();
play_se(&audio, &config, assets.kuzureru.clone());

for _ in 0..(1 + random::<i32>() % 10) {
for _ in 0..(3 + random::<i32>().abs() % 10) {
spawn_gold(
&mut commands,
&assets,
Expand Down
8 changes: 4 additions & 4 deletions src/entity/witch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub fn spawn_witch<T: Component>(
max_life: i32,
res: &Res<LifeBarResource>,
controller: T,
life_bar: bool,
) {
let mut entity = commands.spawn((
Name::new("witch"),
Expand Down Expand Up @@ -96,10 +97,9 @@ pub fn spawn_witch<T: Component>(
});
}

// リモートプレイヤーのライフバー
// spawn_actor_life_bar(spawn_children, &mut meshes, &mut materials);

spawn_life_bar(spawn_children, &res);
if life_bar {
spawn_life_bar(spawn_children, &res);
}
});

// SpriteBundle に PointLight2d を追加すると、画面外に出た時に Sprite が描画されなくなり、
Expand Down
3 changes: 0 additions & 3 deletions src/ui/player_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ struct PlayerList;
#[derive(Component)]
struct PlayersLabel;

#[derive(Component)]
struct SelfPlayerLabel;

#[derive(Component)]
struct RemotePlayerListItem;

Expand Down
14 changes: 12 additions & 2 deletions src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use super::world::map::image_to_tilemap;
use super::world::map::LevelTileMap;
use super::world::tile::*;
use crate::config::GameConfig;
use crate::entity::broken_magic_circle::spawn_broken_magic_circle;
use crate::entity::magic_circle::spawn_magic_circle;
use bevy::asset::*;
use bevy::core::FrameCount;
Expand Down Expand Up @@ -109,8 +110,8 @@ fn spawn_level(
respawn_world(&mut commands, &assets, collider_query, &chunk, &world_tile);
spawn_entities(&mut commands, &assets, &chunk);

let player_x = TILE_SIZE * chunk.entry_point.x as f32;
let player_y = -TILE_SIZE * chunk.entry_point.y as f32;
let player_x = TILE_SIZE * chunk.entry_point.x as f32 + TILE_HALF;
let player_y = -TILE_SIZE * chunk.entry_point.y as f32 - TILE_HALF;

if let Ok(mut camera) = camera.get_single_mut() {
camera.translation.x = player_x;
Expand Down Expand Up @@ -144,6 +145,7 @@ fn spawn_level(
last_idle_life: life,
last_idle_max_life: max_life,
},
false,
);

for _ in 0..10 {
Expand Down Expand Up @@ -281,6 +283,14 @@ fn spawn_entities(mut commands: &mut Commands, assets: &Res<GameAssets>, chunk:
ty - TILE_HALF,
);
}
GameEntity::BrokenMagicCircle => {
spawn_broken_magic_circle(
&mut commands,
assets.asset.clone(),
tx + TILE_HALF,
ty - TILE_HALF,
);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/world/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pub fn image_to_tilemap(
tile: Tile::StoneTile,
});
entry_point = Vec2::new(x as f64, y as f64);
entities.push((GameEntity::BrokenMagicCircle, x, y));
}
_ => {
tiles.push(LevelTileMapile { tile: Tile::Blank });
Expand Down

0 comments on commit 2859022

Please sign in to comment.