Use some constants

This commit is contained in:
Daniel Lynn 2021-07-17 16:23:45 -05:00
parent aa7e888d9e
commit 6a2c77404b
Signed by: daniel
GPG Key ID: 28496A140E180A9D
2 changed files with 7 additions and 3 deletions

View File

@ -9,6 +9,10 @@ mod prelude {
pub use crate::resources::*;
pub use crate::systems::*;
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::*;

View File

@ -11,9 +11,9 @@ pub fn setup(
// Map
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 map_size = Vec2::new(80.0, 50.0);
let map_size = Vec2::new(SCREEN_HEIGHT, SCREEN_HEIGHT);
let half_x = (map_size.x / 2.0) as i32;
let half_y = (map_size.y / 2.0) as i32;
@ -45,7 +45,7 @@ pub fn add_player(
.insert(Name("Player 1".to_string()))
.insert_bundle(SpriteBundle {
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)),
..Default::default()
});