mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
changes made to make new game (#343)
- [x] Changelog updated / no changelog update needed
This commit is contained in:
commit
d4025638f3
|
@ -336,7 +336,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Num<I, N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A bit for bit conversion from a number to a fixed num
|
/// A bit for bit conversion from a number to a fixed num
|
||||||
pub fn from_raw(n: I) -> Self {
|
pub const fn from_raw(n: I) -> Self {
|
||||||
Num(n)
|
Num(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +819,7 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> From<Vector2D<I>> for Vector2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
/// A rectangle with a position in 2d space and a 2d size
|
/// A rectangle with a position in 2d space and a 2d size
|
||||||
pub struct Rect<T: Number> {
|
pub struct Rect<T: Number> {
|
||||||
/// The position of the rectangle
|
/// The position of the rectangle
|
||||||
|
@ -901,7 +901,7 @@ impl<T: Number> Rect<T> {
|
||||||
/// assert_eq!(r.overlapping_rect(r2), None);
|
/// assert_eq!(r.overlapping_rect(r2), None);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn overlapping_rect(&self, other: Rect<T>) -> Option<Self> {
|
pub fn overlapping_rect(&self, other: Rect<T>) -> Option<Self> {
|
||||||
if !self.touches(other.clone()) {
|
if !self.touches(other) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,11 @@ pub mod tiled;
|
||||||
/// Giving out graphics mode.
|
/// Giving out graphics mode.
|
||||||
pub mod video;
|
pub mod video;
|
||||||
|
|
||||||
|
pub mod affine;
|
||||||
pub mod blend;
|
pub mod blend;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
pub mod affine;
|
|
||||||
|
|
||||||
mod font;
|
pub mod font;
|
||||||
pub use font::{Font, FontLetter};
|
pub use font::{Font, FontLetter};
|
||||||
|
|
||||||
const DISPLAY_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0000) };
|
const DISPLAY_CONTROL: MemoryMapped<u16> = unsafe { MemoryMapped::new(0x0400_0000) };
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::fixnum::Vector2D;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use core::convert::From;
|
use core::convert::From;
|
||||||
|
|
||||||
|
@ -77,6 +78,42 @@ impl ButtonController {
|
||||||
(up, down).into()
|
(up, down).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn vector<T>(&self) -> Vector2D<T>
|
||||||
|
where
|
||||||
|
T: From<i32> + crate::fixnum::FixedWidthUnsignedInteger,
|
||||||
|
{
|
||||||
|
(self.x_tri() as i32, self.y_tri() as i32).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn just_pressed_x_tri(&self) -> Tri {
|
||||||
|
let left = self.is_just_pressed(Button::LEFT);
|
||||||
|
let right = self.is_just_pressed(Button::RIGHT);
|
||||||
|
|
||||||
|
(left, right).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn just_pressed_y_tri(&self) -> Tri {
|
||||||
|
let up = self.is_just_pressed(Button::UP);
|
||||||
|
let down = self.is_just_pressed(Button::DOWN);
|
||||||
|
|
||||||
|
(up, down).into()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn just_pressed_vector<T>(&self) -> Vector2D<T>
|
||||||
|
where
|
||||||
|
T: From<i32> + crate::fixnum::FixedWidthUnsignedInteger,
|
||||||
|
{
|
||||||
|
(
|
||||||
|
self.just_pressed_x_tri() as i32,
|
||||||
|
self.just_pressed_y_tri() as i32,
|
||||||
|
)
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn is_pressed(&self, keys: Button) -> bool {
|
pub fn is_pressed(&self, keys: Button) -> bool {
|
||||||
let currently_pressed = u32::from(self.current);
|
let currently_pressed = u32::from(self.current);
|
||||||
|
|
Loading…
Reference in a new issue