mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
update tiled functions to use new vector2d
This commit is contained in:
parent
77f6512ba9
commit
df954505bf
|
@ -1,6 +1,9 @@
|
||||||
use core::{borrow::Borrow, cell::RefCell, convert::TryInto, ops::Deref};
|
use core::{borrow::Borrow, cell::RefCell, convert::TryInto, ops::Deref};
|
||||||
|
|
||||||
use crate::memory_mapped::MemoryMapped1DArray;
|
use crate::{
|
||||||
|
memory_mapped::MemoryMapped1DArray,
|
||||||
|
number::{Rect, Vector2D},
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
object::ObjectControl, palette16, set_graphics_mode, set_graphics_settings, DisplayMode,
|
object::ObjectControl, palette16, set_graphics_mode, set_graphics_settings, DisplayMode,
|
||||||
|
@ -132,22 +135,25 @@ impl Background {
|
||||||
/// block assigned to this background. This is currently unnecesary to call.
|
/// block assigned to this background. This is currently unnecesary to call.
|
||||||
/// Setting position already updates the drawn map, and changing map forces
|
/// Setting position already updates the drawn map, and changing map forces
|
||||||
/// an update.
|
/// an update.
|
||||||
pub fn draw_full_map(&mut self, map: &[u16], dim_x: u32, dim_y: u32) {
|
pub fn draw_full_map(&mut self, map: &[u16], dimensions: Vector2D<u32>) {
|
||||||
self.draw_area(map, dim_x, dim_y, -1, -1, 32, 22);
|
let area: Rect<i32> = Rect {
|
||||||
|
position: Vector2D::new(-1, -1),
|
||||||
|
size: Vector2D::new(32, 22),
|
||||||
|
};
|
||||||
|
self.draw_area(map, dimensions, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Forces a specific area of the screen to be drawn, taking into account any positonal offsets.
|
/// Forces a specific area of the screen to be drawn, taking into account any positonal offsets.
|
||||||
pub fn draw_area(
|
pub fn draw_area(&self, map: &[u16], dimensions: Vector2D<u32>, area: Rect<i32>) {
|
||||||
&self,
|
self.draw_area_mapped(
|
||||||
map: &[u16],
|
&map,
|
||||||
dim_x: u32,
|
dimensions.x,
|
||||||
dim_y: u32,
|
dimensions.y,
|
||||||
left: i32,
|
area.position.x,
|
||||||
top: i32,
|
area.position.y,
|
||||||
width: i32,
|
area.size.x,
|
||||||
height: i32,
|
area.size.y,
|
||||||
) {
|
);
|
||||||
self.draw_area_mapped(&map, dim_x, dim_y, left, top, width, height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_area_mapped<T>(
|
fn draw_area_mapped<T>(
|
||||||
|
@ -190,10 +196,15 @@ impl Background {
|
||||||
/// Sets the position of the map to be shown on screen. This automatically
|
/// Sets the position of the map to be shown on screen. This automatically
|
||||||
/// manages copying the correct portion to the map block and moving the map
|
/// manages copying the correct portion to the map block and moving the map
|
||||||
/// registers.
|
/// registers.
|
||||||
pub fn set_position(&mut self, map: &[u16], dim_x: u32, dim_y: u32, x: i32, y: i32) {
|
pub fn set_position(
|
||||||
self.set_position_mapped(&map, dim_x, dim_y, x, y);
|
&mut self,
|
||||||
self.pos_x = x;
|
map: &[u16],
|
||||||
self.pos_y = y;
|
dimensions: Vector2D<u32>,
|
||||||
|
position: Vector2D<i32>,
|
||||||
|
) {
|
||||||
|
self.set_position_mapped(&map, dimensions.x, dimensions.y, position.x, position.y);
|
||||||
|
self.pos_x = position.x;
|
||||||
|
self.pos_y = position.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_position_mapped<T>(&self, map: &T, dim_x: u32, dim_y: u32, x: i32, y: i32)
|
fn set_position_mapped<T>(&self, map: &T, dim_x: u32, dim_y: u32, x: i32, y: i32)
|
||||||
|
|
Loading…
Reference in a new issue