Simplify and cleanup
This commit is contained in:
parent
e683e5c490
commit
a83a8ce528
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
/target
|
/target
|
||||||
|
.vscode
|
||||||
|
8
.idea/.gitignore
generated
vendored
8
.idea/.gitignore
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
||||||
# Datasource local storage ignored files
|
|
||||||
/dataSources/
|
|
||||||
/dataSources.local.xml
|
|
6
.idea/GitLink.xml
generated
6
.idea/GitLink.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="uk.co.ben_gibson.git.link.SettingsState">
|
|
||||||
<option name="host" value="e0f86390-1091-4871-8aeb-f534fbc99cf0" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
8
.idea/compilerexplorer.settings.xml
generated
8
.idea/compilerexplorer.settings.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerExplorerSettingsProvider">
|
|
||||||
<option name="enabled" value="false" />
|
|
||||||
<option name="highlightColorRGB" value="-16711681" />
|
|
||||||
<option name="initialNoticeShown" value="true" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
7
.idea/discord.xml
generated
7
.idea/discord.xml
generated
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DiscordProjectSettings">
|
|
||||||
<option name="show" value="PROJECT_FILES" />
|
|
||||||
<option name="description" value="" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
15
.idea/git_toolbox_prj.xml
generated
15
.idea/git_toolbox_prj.xml
generated
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="GitToolBoxProjectSettings">
|
|
||||||
<option name="commitMessageIssueKeyValidationOverride">
|
|
||||||
<BoolValueOverride>
|
|
||||||
<option name="enabled" value="true" />
|
|
||||||
</BoolValueOverride>
|
|
||||||
</option>
|
|
||||||
<option name="commitMessageValidationEnabledOverride">
|
|
||||||
<BoolValueOverride>
|
|
||||||
<option name="enabled" value="true" />
|
|
||||||
</BoolValueOverride>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/monstrous.iml" filepath="$PROJECT_DIR$/.idea/monstrous.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
11
.idea/monstrous.iml
generated
11
.idea/monstrous.iml
generated
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="CPP_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
821
Cargo.lock
generated
821
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -7,5 +7,5 @@ license = "AGPL-3.0-or-later"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.7.0"
|
bevy = "0.8.0"
|
||||||
bevy_ecs_tilemap = "0.6.0"
|
bevy_ecs_tilemap = "0.7.0"
|
||||||
|
BIN
assets/tileset.aseprite
Normal file
BIN
assets/tileset.aseprite
Normal file
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 130 B After Width: | Height: | Size: 2.1 KiB |
@ -1 +0,0 @@
|
|||||||
pub mod texture;
|
|
@ -1,20 +0,0 @@
|
|||||||
use bevy::{prelude::*, render::render_resource::TextureUsages};
|
|
||||||
|
|
||||||
pub fn set_texture_filters_to_nearest(
|
|
||||||
mut texture_events: EventReader<AssetEvent<Image>>,
|
|
||||||
mut textures: ResMut<Assets<Image>>,
|
|
||||||
) {
|
|
||||||
// quick and dirty, run this for all textures anytime a texture is created.
|
|
||||||
for event in texture_events.iter() {
|
|
||||||
match event {
|
|
||||||
AssetEvent::Created { handle } => {
|
|
||||||
if let Some(mut texture) = textures.get_mut(handle) {
|
|
||||||
texture.texture_descriptor.usage = TextureUsages::TEXTURE_BINDING
|
|
||||||
| TextureUsages::COPY_SRC
|
|
||||||
| TextureUsages::COPY_DST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
65
src/main.rs
65
src/main.rs
@ -1,38 +1,47 @@
|
|||||||
use bevy::input::mouse::MouseMotion;
|
use bevy::{
|
||||||
use bevy::prelude::*;
|
input::mouse::MouseMotion,
|
||||||
|
prelude::*,
|
||||||
|
render::texture::ImageSettings, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||||
|
};
|
||||||
use bevy_ecs_tilemap::prelude::*;
|
use bevy_ecs_tilemap::prelude::*;
|
||||||
|
|
||||||
mod helpers;
|
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
|
commands.spawn_bundle(Camera2dBundle::default());
|
||||||
fn startup(mut commands: Commands, asset_server: Res<AssetServer>, mut map_query: MapQuery) {
|
|
||||||
commands.spawn_bundle(OrthographicCameraBundle::new_2d());
|
|
||||||
|
|
||||||
let texture_handle = asset_server.load("tileset.png");
|
let texture_handle = asset_server.load("tileset.png");
|
||||||
|
|
||||||
let map_entity = commands.spawn().id();
|
let tilemap_size = TilemapSize { x: 320, y: 320 };
|
||||||
let mut map = Map::new(0u16, map_entity);
|
let mut tile_storage = TileStorage::empty(tilemap_size);
|
||||||
|
let tilemap_entity = commands.spawn().id();
|
||||||
|
|
||||||
let (mut layer_builder, layer_entity) = LayerBuilder::<TileBundle>::new(
|
for x in 0..320u32 {
|
||||||
&mut commands,
|
for y in 0..320u32 {
|
||||||
LayerSettings::new(
|
let tile_pos = TilePos { x, y };
|
||||||
MapSize(3, 3),
|
let tile_entity = commands
|
||||||
ChunkSize(8, 8),
|
.spawn()
|
||||||
TileSize(8.0, 8.0),
|
.insert_bundle(TileBundle {
|
||||||
TextureSize(24.0, 24.0)
|
position: tile_pos,
|
||||||
),
|
tilemap_id: TilemapId(tilemap_entity),
|
||||||
0u16,
|
..Default::default()
|
||||||
0u16
|
})
|
||||||
);
|
.id();
|
||||||
layer_builder.set_all(TileBundle::default());
|
tile_storage.set(&tile_pos, Some(tile_entity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
map_query.build_layer(&mut commands, layer_builder, texture_handle);
|
let tile_size = TilemapTileSize { x: 32.0, y: 32.0 };
|
||||||
map.add_layer(&mut commands, 0u16, layer_entity);
|
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.entity(map_entity)
|
.entity(tilemap_entity)
|
||||||
.insert(map)
|
.insert_bundle(TilemapBundle {
|
||||||
.insert(Transform::from_xyz(-128.0, -128.0, 0.0))
|
grid_size: TilemapGridSize { x: 32.0, y: 32.0 },
|
||||||
.insert(GlobalTransform::default());
|
size: tilemap_size,
|
||||||
|
storage: tile_storage,
|
||||||
|
texture: TilemapTexture(texture_handle),
|
||||||
|
tile_size,
|
||||||
|
transform: bevy_ecs_tilemap::helpers::get_centered_transform_2d(&tilemap_size, &tile_size, 0.0),
|
||||||
|
..Default::default()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mouse_motion(
|
fn mouse_motion(
|
||||||
@ -58,10 +67,12 @@ fn main() {
|
|||||||
title: String::from("Monstrous"),
|
title: String::from("Monstrous"),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
|
.insert_resource(ImageSettings::default_nearest())
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugin(LogDiagnosticsPlugin::default())
|
||||||
|
.add_plugin(FrameTimeDiagnosticsPlugin::default())
|
||||||
.add_plugin(TilemapPlugin)
|
.add_plugin(TilemapPlugin)
|
||||||
.add_startup_system(startup)
|
.add_startup_system(startup)
|
||||||
.add_system(helpers::texture::set_texture_filters_to_nearest)
|
|
||||||
.add_system(mouse_motion)
|
.add_system(mouse_motion)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user