mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
More .into()
This commit is contained in:
parent
b357acbba8
commit
23550e579a
|
@ -26,7 +26,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
for y in 0..32u16 {
|
||||
for x in 0..32u16 {
|
||||
bg.set_tile(&mut vram, (x, y).into(), &tileset, 1);
|
||||
bg.set_tile(&mut vram, (x, y), &tileset, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,14 +46,14 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
scroll_x += input.x_tri() as i32;
|
||||
scroll_y += input.y_tri() as i32;
|
||||
|
||||
let scroll_pos = (scroll_x, scroll_y).into();
|
||||
let scroll_pos = (scroll_x, scroll_y);
|
||||
|
||||
rotation += rotation_increase;
|
||||
rotation = rotation.rem_euclid(1.into());
|
||||
|
||||
let transformation = AffineMatrixBackground::from_scale_rotation_position(
|
||||
(0, 0).into(),
|
||||
(1, 1).into(),
|
||||
(0, 0),
|
||||
(1, 1),
|
||||
rotation,
|
||||
scroll_pos,
|
||||
);
|
||||
|
|
|
@ -30,7 +30,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
for x in 0..30u16 {
|
||||
bg.set_tile(
|
||||
&mut vram,
|
||||
(x, y).into(),
|
||||
(x, y),
|
||||
&tileset,
|
||||
water_tiles::water_tiles.tile_settings[0],
|
||||
);
|
||||
|
|
|
@ -64,7 +64,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
let i = i as u16;
|
||||
background.set_tile(
|
||||
&mut vram,
|
||||
(i % 32, i / 32).into(),
|
||||
(i % 32, i / 32),
|
||||
&tileset,
|
||||
TileSetting::from_raw(tile),
|
||||
);
|
||||
|
|
|
@ -31,7 +31,7 @@ fn main(mut gba: Gba) -> ! {
|
|||
|
||||
init_background(&mut bg, &mut vram);
|
||||
|
||||
let mut title_renderer = FONT.render_text((0u16, 3u16).into());
|
||||
let mut title_renderer = FONT.render_text((0u16, 3u16));
|
||||
let mut writer = title_renderer.writer(1, 0, &mut bg, &mut vram);
|
||||
|
||||
writeln!(&mut writer, "Crazy Glue by Josh Woodward").unwrap();
|
||||
|
@ -57,7 +57,7 @@ fn main(mut gba: Gba) -> ! {
|
|||
let mut frame_counter = 0i32;
|
||||
let mut has_written_frame_time = false;
|
||||
|
||||
let mut stats_renderer = FONT.render_text((0u16, 6u16).into());
|
||||
let mut stats_renderer = FONT.render_text((0u16, 6u16));
|
||||
loop {
|
||||
vblank_provider.wait_for_vblank();
|
||||
bg.commit(&mut vram);
|
||||
|
@ -106,7 +106,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) {
|
|||
for x in 0..30u16 {
|
||||
bg.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
(x, y),
|
||||
&background_tile.tile_set(),
|
||||
background_tile.tile_setting(),
|
||||
);
|
||||
|
|
|
@ -58,7 +58,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
let start = timer.value();
|
||||
|
||||
wr.layout((WIDTH, 40).into(), TextAlignment::Justify, 2);
|
||||
wr.layout((WIDTH, 40), TextAlignment::Justify, 2);
|
||||
let end = timer.value();
|
||||
|
||||
agb::println!(
|
||||
|
@ -83,7 +83,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
line_done = false;
|
||||
wr.pop_line();
|
||||
}
|
||||
wr.update((0, HEIGHT - 40).into());
|
||||
wr.update((0, HEIGHT - 40));
|
||||
let end = timer.value();
|
||||
|
||||
frame += 1;
|
||||
|
|
|
@ -34,7 +34,7 @@ fn all_sprites(gfx: &OamManaged, rotation_speed: Num<i32, 16>) {
|
|||
let mut obj = gfx.object_sprite(&SPRITES[0]);
|
||||
obj.set_affine_matrix(matrix.clone());
|
||||
obj.show_affine(object::AffineMode::Affine);
|
||||
obj.set_position((x * 16 + 8, y * 16 + 8).into());
|
||||
obj.set_position((x * 16 + 8, y * 16 + 8));
|
||||
objs.push(obj);
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ fn all_tags(gfx: &OamManaged) {
|
|||
let (size_x, size_y) = (size_x as i32, size_y as i32);
|
||||
let mut obj = gfx.object_sprite(sprite);
|
||||
obj.show();
|
||||
obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2).into());
|
||||
obj.set_position((x * 32 + 16 - size_x / 2, y * 32 + 16 - size_y / 2));
|
||||
objs.push((obj, v));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ fn main(mut gba: Gba) -> ! {
|
|||
|
||||
init_background(&mut bg, &mut vram);
|
||||
|
||||
let mut title_renderer = FONT.render_text((0u16, 3u16).into());
|
||||
let mut title_renderer = FONT.render_text((0u16, 3u16));
|
||||
let mut writer = title_renderer.writer(1, 0, &mut bg, &mut vram);
|
||||
|
||||
writeln!(&mut writer, "Let it in by Josh Woodward").unwrap();
|
||||
|
@ -55,7 +55,7 @@ fn main(mut gba: Gba) -> ! {
|
|||
let mut frame_counter = 0i32;
|
||||
let mut has_written_frame_time = false;
|
||||
|
||||
let mut stats_renderer = FONT.render_text((0u16, 6u16).into());
|
||||
let mut stats_renderer = FONT.render_text((0u16, 6u16));
|
||||
loop {
|
||||
vblank_provider.wait_for_vblank();
|
||||
bg.commit(&mut vram);
|
||||
|
@ -94,7 +94,7 @@ fn init_background(bg: &mut RegularMap, vram: &mut VRamManager) {
|
|||
for x in 0..30u16 {
|
||||
bg.set_tile(
|
||||
vram,
|
||||
(x, y).into(),
|
||||
(x, y),
|
||||
&background_tile.tile_set(),
|
||||
background_tile.tile_setting(),
|
||||
);
|
||||
|
|
|
@ -35,7 +35,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
for x in 0..30u16 {
|
||||
bg.set_tile(
|
||||
&mut vram,
|
||||
(x, y).into(),
|
||||
(x, y),
|
||||
&background_tile.tile_set(),
|
||||
background_tile.tile_setting(),
|
||||
);
|
||||
|
@ -44,7 +44,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
vram.remove_dynamic_tile(background_tile);
|
||||
|
||||
let mut renderer = FONT.render_text((0u16, 3u16).into());
|
||||
let mut renderer = FONT.render_text((0u16, 3u16));
|
||||
let mut writer = renderer.writer(1, 2, &mut bg, &mut vram);
|
||||
|
||||
writeln!(&mut writer, "Hello, World!").unwrap();
|
||||
|
@ -58,7 +58,7 @@ fn main(mut gba: agb::Gba) -> ! {
|
|||
let mut frame = 0;
|
||||
|
||||
loop {
|
||||
let mut renderer = FONT.render_text((4u16, 0u16).into());
|
||||
let mut renderer = FONT.render_text((4u16, 0u16));
|
||||
let mut writer = renderer.writer(1, 2, &mut bg, &mut vram);
|
||||
|
||||
writeln!(&mut writer, "Frame {frame}").unwrap();
|
||||
|
|
|
@ -295,15 +295,15 @@ impl AffineMatrixBackground {
|
|||
/// # }
|
||||
/// ```
|
||||
pub fn from_scale_rotation_position(
|
||||
transform_origin: Vector2D<Num<i32, 8>>,
|
||||
scale: Vector2D<Num<i32, 8>>,
|
||||
transform_origin: impl Into<Vector2D<Num<i32, 8>>>,
|
||||
scale: impl Into<Vector2D<Num<i32, 8>>>,
|
||||
rotation: Num<i32, 16>,
|
||||
position: Vector2D<Num<i32, 8>>,
|
||||
position: impl Into<Vector2D<Num<i32, 8>>>,
|
||||
) -> Self {
|
||||
crate::syscall::bg_affine_matrix(
|
||||
transform_origin,
|
||||
position.try_change_base::<i16, 8>().unwrap().floor(),
|
||||
scale.try_change_base().unwrap(),
|
||||
transform_origin.into(),
|
||||
position.into().try_change_base::<i16, 8>().unwrap().floor(),
|
||||
scale.into().try_change_base().unwrap(),
|
||||
rotation.rem_euclid(1.into()).try_change_base().unwrap(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -78,12 +78,12 @@ impl Font {
|
|||
impl Font {
|
||||
#[must_use]
|
||||
/// Create renderer starting at the given tile co-ordinates.
|
||||
pub fn render_text(&self, tile_pos: Vector2D<u16>) -> TextRenderer<'_> {
|
||||
pub fn render_text(&self, tile_pos: impl Into<Vector2D<u16>>) -> TextRenderer<'_> {
|
||||
TextRenderer {
|
||||
current_x_pos: 0,
|
||||
current_y_pos: 0,
|
||||
font: self,
|
||||
tile_pos,
|
||||
tile_pos: tile_pos.into(),
|
||||
tiles: Default::default(),
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ mod tests {
|
|||
for x in 0..30u16 {
|
||||
bg.set_tile(
|
||||
&mut vram,
|
||||
(x, y).into(),
|
||||
(x, y),
|
||||
&background_tile.tile_set(),
|
||||
background_tile.tile_setting(),
|
||||
);
|
||||
|
@ -301,7 +301,7 @@ mod tests {
|
|||
|
||||
vram.remove_dynamic_tile(background_tile);
|
||||
|
||||
let mut renderer = FONT.render_text((0u16, 3u16).into());
|
||||
let mut renderer = FONT.render_text((0u16, 3u16));
|
||||
|
||||
// Test twice to ensure that clearing works
|
||||
for _ in 0..2 {
|
||||
|
|
|
@ -229,11 +229,11 @@ impl BufferedRender<'_> {
|
|||
/// let mut writer = ObjectTextRender::new(&EXAMPLE_FONT, Size::S16x16, palette);
|
||||
///
|
||||
/// let _ = writeln!(writer, "Hello, World!");
|
||||
/// writer.layout((WIDTH, 40).into(), TextAlignment::Left, 2);
|
||||
/// writer.layout((WIDTH, 40), TextAlignment::Left, 2);
|
||||
///
|
||||
/// loop {
|
||||
/// writer.next_letter_group();
|
||||
/// writer.update((0, 0).into());
|
||||
/// writer.update((0, 0));
|
||||
/// vblank.wait_for_vblank();
|
||||
/// let oam = &mut unmanaged.iter();
|
||||
/// writer.commit(oam);
|
||||
|
@ -287,7 +287,7 @@ impl ObjectTextRender<'_> {
|
|||
/// Force a relayout, must be called after writing.
|
||||
pub fn layout(
|
||||
&mut self,
|
||||
area: Vector2D<i32>,
|
||||
area: impl Into<Vector2D<i32>>,
|
||||
alignment: TextAlignment,
|
||||
paragraph_spacing: i32,
|
||||
) {
|
||||
|
@ -295,7 +295,7 @@ impl ObjectTextRender<'_> {
|
|||
self.buffer.font,
|
||||
&self.buffer.preprocessor,
|
||||
&LayoutSettings {
|
||||
area,
|
||||
area: area.into(),
|
||||
alignment,
|
||||
paragraph_spacing,
|
||||
},
|
||||
|
@ -331,7 +331,7 @@ impl ObjectTextRender<'_> {
|
|||
/// Updates the internal state of the number of letters to write and popped
|
||||
/// line. Should be called in the same frame as and after
|
||||
/// [`next_letter_group`][ObjectTextRender::next_letter_group], [`next_line`][ObjectTextRender::next_line], and [`pop_line`][ObjectTextRender::pop_line].
|
||||
pub fn update(&mut self, position: Vector2D<i32>) {
|
||||
pub fn update(&mut self, position: impl Into<Vector2D<i32>>) {
|
||||
if !self.buffer.buffered_chars.is_empty()
|
||||
&& self.buffer.letters.letters.len() <= self.number_of_objects + 5
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ impl ObjectTextRender<'_> {
|
|||
}
|
||||
|
||||
self.layout.update_objects_to_display_at_position(
|
||||
position,
|
||||
position.into(),
|
||||
self.buffer.letters.letters.iter(),
|
||||
self.number_of_objects,
|
||||
);
|
||||
|
|
|
@ -489,9 +489,9 @@ impl Object<'_> {
|
|||
|
||||
/// Sets the position of the object.
|
||||
/// Use [position](Self::position) to get the value
|
||||
pub fn set_position(&mut self, position: Vector2D<i32>) -> &mut Self {
|
||||
pub fn set_position(&mut self, position: impl Into<Vector2D<i32>>) -> &mut Self {
|
||||
// safety: only have one of these, doesn't modify slotmap
|
||||
unsafe { self.object().set_position(position) };
|
||||
unsafe { self.object().set_position(position.into()) };
|
||||
|
||||
self
|
||||
}
|
||||
|
|
|
@ -377,11 +377,11 @@ impl AffineMap {
|
|||
pub fn set_tile(
|
||||
&mut self,
|
||||
vram: &mut VRamManager,
|
||||
pos: Vector2D<u16>,
|
||||
pos: impl Into<Vector2D<u16>>,
|
||||
tileset: &TileSet<'_>,
|
||||
tile_id: u8,
|
||||
) {
|
||||
let pos = self.map_size().gba_offset(pos);
|
||||
let pos = self.map_size().gba_offset(pos.into());
|
||||
let colours = self.colours();
|
||||
|
||||
let old_tile = self.tiles_mut()[pos];
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
/// for x in 0..30u16 {
|
||||
/// bg.set_tile(
|
||||
/// &mut vram,
|
||||
/// (x, y).into(),
|
||||
/// (x, y),
|
||||
/// &tileset,
|
||||
/// water_tiles::tiles.tile_settings[0],
|
||||
/// );
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use agb::display::object::{OamManaged, Object};
|
||||
use agb::fixnum::Vector2D;
|
||||
use agb::rng;
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
@ -149,7 +150,7 @@ impl<'a> BattleScreenDisplay<'a> {
|
|||
let mut attack_obj = obj
|
||||
.object_sprite(ENEMY_ATTACK_SPRITES.sprite_for_attack(EnemyAttackType::Attack));
|
||||
|
||||
let attack_obj_position = (120, 56 + 32 * i).into();
|
||||
let attack_obj_position = Vector2D::new(120, 56 + 32 * i);
|
||||
attack_obj.set_position(attack_obj_position).hide();
|
||||
|
||||
let mut attack_cooldown =
|
||||
|
|
Loading…
Reference in a new issue