idk anymore. I think I fixed something?

This commit is contained in:
Evan Pratten 2022-04-03 14:31:03 -04:00
parent 8bbb0619a9
commit 0145c42a51
3 changed files with 13 additions and 6 deletions

View File

@ -1,11 +1,11 @@
[
{
"type": "env",
"name": "env_umbrella",
"variant": "Blue",
"position": [
1,0
5,
7
],
"rotation_degrees": 90
}

View File

@ -76,6 +76,9 @@ impl WorldObjectRef {
)
}
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
}
}

View File

@ -264,6 +264,10 @@ impl MapRenderer {
Vector2::new(screen_width as f32, screen_height as f32),
camera,
);
let player_position = na::Vector2::new(
player_position.x,
player_position.y * -1.0,
);
// Handle each layer from the bottom up
for layer in self.map.layers() {
@ -319,12 +323,12 @@ impl MapRenderer {
// Check if there is an object at this tile
for obj_ref in &self.world_objects.object_references {
if obj_ref.get_world_space_position().x == sampler_x as f32
&& obj_ref.get_world_space_position().y == sampler_y as f32
if obj_ref.get_tile_space_position().x == sampler_x as f32
&& obj_ref.get_tile_space_position().y == sampler_y as f32
{
// Get access to the actual object definition
let object_key = obj_ref.into_key();
debug!("Found object: {}", object_key);
// debug!("Found object: {}", object_key);
let obj_def = self
.world_objects
.object_definitions