generated from 2ndbeam/bevy-template
feat: Barely working tilemap system
- Added tilemap bundle - Added HALVED_METERS_PER_PIXEL constant
This commit is contained in:
parent
ffdb5d94a8
commit
b59cec172d
8 changed files with 109 additions and 18 deletions
|
|
@ -5,8 +5,7 @@ use bevy::{
|
|||
use bevy_rapier2d::prelude::*;
|
||||
|
||||
use crate::{
|
||||
inventory::item::Item,
|
||||
player::Player,
|
||||
HALVED_PIXELS_PER_METER, PIXELS_PER_METER, inventory::item::Item, player::Player
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
@ -73,8 +72,42 @@ pub fn setup_world(
|
|||
Item::new_positioned(uvec2(2, 3), uvec2(6, 2)),
|
||||
Item::new_positioned(uvec2(4, 4), uvec2(0, 4)),
|
||||
];
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(16., 0.), true));
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(48., 0.), false));
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(80., 0.), false)).insert(Locked);
|
||||
|
||||
// floor
|
||||
let mut tiles = (0..16).map(|x| {
|
||||
(0, uvec2(x, 1))
|
||||
}).collect::<Vec<(u16, UVec2)>>();
|
||||
|
||||
// ceiling
|
||||
tiles.extend((0..16).map(|x| {
|
||||
(0, uvec2(x, 5))
|
||||
}));
|
||||
|
||||
// walls
|
||||
tiles.extend([
|
||||
(0, 4), (0, 3), (0, 2),
|
||||
(15, 4), (15, 3), (15, 2),
|
||||
].iter().map(|(x, y)| {
|
||||
(1, uvec2(*x, *y))
|
||||
}));
|
||||
|
||||
// wall connectors
|
||||
tiles.extend([
|
||||
(13, 4), (11, 4), (9, 4),
|
||||
].iter().map(|(x, y)| {
|
||||
(2, uvec2(*x, *y))
|
||||
}));
|
||||
|
||||
let colliders: Vec<(Collider, Vec2)> = vec![
|
||||
(Collider::cuboid(HALVED_PIXELS_PER_METER, PIXELS_PER_METER * 1.5),
|
||||
vec2(HALVED_PIXELS_PER_METER, HALVED_PIXELS_PER_METER)),
|
||||
(Collider::cuboid(HALVED_PIXELS_PER_METER, PIXELS_PER_METER * 1.5),
|
||||
vec2(PIXELS_PER_METER * 15.5, HALVED_PIXELS_PER_METER)),
|
||||
];
|
||||
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(PIXELS_PER_METER * 1.5, 0.), true));
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(PIXELS_PER_METER * 3.5, 0.), false));
|
||||
commands.spawn(door::door_bundle(&asset_server, vec2(PIXELS_PER_METER * 5.5, 0.), false)).insert(Locked);
|
||||
commands.spawn(container::container_bundle(&asset_server, vec2(-32., 0.), uvec2(8, 8), items));
|
||||
commands.spawn(tilemap::tilemap_bundle(&asset_server, uvec2(16, 6), tiles, colliders));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue