idk anymore. I think I fixed something?
This commit is contained in:
parent
8bbb0619a9
commit
0145c42a51
4
game/dist/map_gameMap.objects.json
vendored
4
game/dist/map_gameMap.objects.json
vendored
@ -1,11 +1,11 @@
|
|||||||
[
|
[
|
||||||
|
|
||||||
{
|
{
|
||||||
"type": "env",
|
"type": "env",
|
||||||
"name": "env_umbrella",
|
"name": "env_umbrella",
|
||||||
"variant": "Blue",
|
"variant": "Blue",
|
||||||
"position": [
|
"position": [
|
||||||
1,0
|
5,
|
||||||
|
7
|
||||||
],
|
],
|
||||||
"rotation_degrees": 90
|
"rotation_degrees": 90
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,9 @@ impl WorldObjectRef {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn get_world_space_position(&self)-> na::Vector2<f32> {
|
pub fn get_world_space_position(&self)-> na::Vector2<f32> {
|
||||||
self.position * 2.0
|
self.position * 128.0
|
||||||
|
}
|
||||||
|
pub fn get_tile_space_position(&self)-> na::Vector2<f32> {
|
||||||
|
self.position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,6 +264,10 @@ impl MapRenderer {
|
|||||||
Vector2::new(screen_width as f32, screen_height as f32),
|
Vector2::new(screen_width as f32, screen_height as f32),
|
||||||
camera,
|
camera,
|
||||||
);
|
);
|
||||||
|
let player_position = na::Vector2::new(
|
||||||
|
player_position.x,
|
||||||
|
player_position.y * -1.0,
|
||||||
|
);
|
||||||
|
|
||||||
// Handle each layer from the bottom up
|
// Handle each layer from the bottom up
|
||||||
for layer in self.map.layers() {
|
for layer in self.map.layers() {
|
||||||
@ -319,12 +323,12 @@ impl MapRenderer {
|
|||||||
|
|
||||||
// Check if there is an object at this tile
|
// Check if there is an object at this tile
|
||||||
for obj_ref in &self.world_objects.object_references {
|
for obj_ref in &self.world_objects.object_references {
|
||||||
if obj_ref.get_world_space_position().x == sampler_x as f32
|
if obj_ref.get_tile_space_position().x == sampler_x as f32
|
||||||
&& obj_ref.get_world_space_position().y == sampler_y as f32
|
&& obj_ref.get_tile_space_position().y == sampler_y as f32
|
||||||
{
|
{
|
||||||
// Get access to the actual object definition
|
// Get access to the actual object definition
|
||||||
let object_key = obj_ref.into_key();
|
let object_key = obj_ref.into_key();
|
||||||
debug!("Found object: {}", object_key);
|
// debug!("Found object: {}", object_key);
|
||||||
let obj_def = self
|
let obj_def = self
|
||||||
.world_objects
|
.world_objects
|
||||||
.object_definitions
|
.object_definitions
|
||||||
|
Reference in New Issue
Block a user