2 Commits

Author SHA1 Message Date
d6b2a93eac make bases smaller 2025-11-18 22:12:46 +01:00
ef257f43e6 Refactor window resolution to use tilemap constants 2025-11-18 19:30:31 +01:00

View File

@@ -1,8 +1,20 @@
use bevy::{prelude::*, window::WindowResolution};
use bevy_ecs_tilemap::prelude::*;
const MAP_SIZE: TilemapSize = TilemapSize { x: 50, y: 25 };
const TILE_SIZE: TilemapTileSize = TilemapTileSize { x: 25.0, y: 25.0 };
const TILEMAP_WIDTH: u32 = 50;
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>) {
commands.spawn(Camera2d);
@@ -30,8 +42,8 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
}
}
for x in 0..5 {
for y in 10..15 {
for x in 0..3 {
for y in 11..14 {
if x < MAP_SIZE.x && y < MAP_SIZE.y {
let tile_pos = TilePos { x, y };
let tile_entity = commands
@@ -46,8 +58,8 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
}
}
for x in 45..50 {
for y in 10..15 {
for x in 47..50 {
for y in 11..14 {
if x < MAP_SIZE.x && y < MAP_SIZE.y {
let tile_pos = TilePos { x, y };
let tile_entity = commands
@@ -94,8 +106,11 @@ fn main() {
.set(WindowPlugin {
primary_window: Some(Window {
title: String::from("War in Tunnels"),
resolution: WindowResolution::new(1250, 625)
.with_scale_factor_override(1.0),
resolution: WindowResolution::new(
TILEMAP_WIDTH * TILE_WIDTH as u32,
TILEMAP_HEIGHT * TILE_HEIGHT as u32,
)
.with_scale_factor_override(1.0),
..Default::default()
}),
..default()