Compare commits
6 Commits
ef4a98627e
...
main
Author | SHA1 | Date | |
---|---|---|---|
7b56c52fff
|
|||
6a2c77404b
|
|||
aa7e888d9e
|
|||
170088b836
|
|||
34d1de5847
|
|||
70e4ac0c81
|
BIN
assets/grass.png
BIN
assets/grass.png
Binary file not shown.
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 153 B |
Binary file not shown.
Before Width: | Height: | Size: 275 B After Width: | Height: | Size: 335 B |
BIN
assets/wall.png
BIN
assets/wall.png
Binary file not shown.
Before Width: | Height: | Size: 381 B After Width: | Height: | Size: 624 B |
@ -9,6 +9,10 @@ mod prelude {
|
|||||||
pub use crate::resources::*;
|
pub use crate::resources::*;
|
||||||
pub use crate::systems::*;
|
pub use crate::systems::*;
|
||||||
pub use bevy::prelude::*;
|
pub use bevy::prelude::*;
|
||||||
|
|
||||||
|
pub const SCREEN_WIDTH: f32 = 80.0;
|
||||||
|
pub const SCREEN_HEIGHT: f32 = 50.0;
|
||||||
|
pub const TILE_SIZE: f32 = 64.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
@ -11,9 +11,9 @@ pub fn setup(
|
|||||||
|
|
||||||
// Map
|
// Map
|
||||||
let grass_material = materials.add(asset_server.load("grass.png").into());
|
let grass_material = materials.add(asset_server.load("grass.png").into());
|
||||||
let tile_size = Vec2::new(64.0, 64.0);
|
let tile_size = Vec2::new(TILE_SIZE, TILE_SIZE);
|
||||||
let sprite = Sprite::new(tile_size);
|
let sprite = Sprite::new(tile_size);
|
||||||
let map_size = Vec2::new(80.0, 50.0);
|
let map_size = Vec2::new(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||||
let half_x = (map_size.x / 2.0) as i32;
|
let half_x = (map_size.x / 2.0) as i32;
|
||||||
let half_y = (map_size.y / 2.0) as i32;
|
let half_y = (map_size.y / 2.0) as i32;
|
||||||
|
|
||||||
@ -37,15 +37,15 @@ pub fn add_player(
|
|||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
) {
|
) {
|
||||||
let player_sprite = materials.add(asset_server.load("marshmallow.png").into());
|
let player_material = materials.add(asset_server.load("marshmallow.png").into());
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn()
|
.spawn()
|
||||||
.insert(Player)
|
.insert(Player)
|
||||||
.insert(Name("Player 1".to_string()))
|
.insert(Name("Player 1".to_string()))
|
||||||
.insert_bundle(SpriteBundle {
|
.insert_bundle(SpriteBundle {
|
||||||
material: player_sprite,
|
material: player_material,
|
||||||
sprite: Sprite::new(Vec2::new(64.0, 64.0)),
|
sprite: Sprite::new(Vec2::new(TILE_SIZE, TILE_SIZE)),
|
||||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
|
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 1.0)),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user