Refactor window resolution to use tilemap constants
This commit is contained in:
23
src/main.rs
23
src/main.rs
@@ -1,8 +1,20 @@
|
|||||||
use bevy::{prelude::*, window::WindowResolution};
|
use bevy::{prelude::*, window::WindowResolution};
|
||||||
use bevy_ecs_tilemap::prelude::*;
|
use bevy_ecs_tilemap::prelude::*;
|
||||||
|
|
||||||
const MAP_SIZE: TilemapSize = TilemapSize { x: 50, y: 25 };
|
const TILEMAP_WIDTH: u32 = 50;
|
||||||
const TILE_SIZE: TilemapTileSize = TilemapTileSize { x: 25.0, y: 25.0 };
|
const TILEMAP_HEIGHT: u32 = 25;
|
||||||
|
|
||||||
|
const TILE_WIDTH: f32 = 25.0;
|
||||||
|
const TILE_HEIGHT: f32 = 25.0;
|
||||||
|
|
||||||
|
const MAP_SIZE: TilemapSize = TilemapSize {
|
||||||
|
x: TILEMAP_WIDTH,
|
||||||
|
y: TILEMAP_HEIGHT,
|
||||||
|
};
|
||||||
|
const TILE_SIZE: TilemapTileSize = TilemapTileSize {
|
||||||
|
x: TILE_WIDTH,
|
||||||
|
y: TILE_HEIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2d);
|
commands.spawn(Camera2d);
|
||||||
@@ -94,8 +106,11 @@ fn main() {
|
|||||||
.set(WindowPlugin {
|
.set(WindowPlugin {
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
title: String::from("War in Tunnels"),
|
title: String::from("War in Tunnels"),
|
||||||
resolution: WindowResolution::new(1250, 625)
|
resolution: WindowResolution::new(
|
||||||
.with_scale_factor_override(1.0),
|
TILEMAP_WIDTH * TILE_WIDTH as u32,
|
||||||
|
TILEMAP_HEIGHT * TILE_HEIGHT as u32,
|
||||||
|
)
|
||||||
|
.with_scale_factor_override(1.0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
|
|||||||
Reference in New Issue
Block a user