game updates

This commit is contained in:
Lokathor 2023-01-01 18:04:10 -07:00
parent f9fe8b07f7
commit c7ee6ba2ec

View file

@ -26,7 +26,7 @@ struct Rect {
h: u16, h: u16,
} }
impl Rect { impl Rect {
pub fn intersect(self, other: Self) -> bool { fn intersect(self, other: Self) -> bool {
self.x < other.x + other.w self.x < other.x + other.w
&& self.x + self.w > other.x && self.x + self.w > other.x
&& self.y < other.y + other.h && self.y < other.y + other.h
@ -51,7 +51,7 @@ extern "C" fn main() -> ! {
creatures[0].x = 11; creatures[0].x = 11;
creatures[0].y = 14; creatures[0].y = 14;
// //
creatures[1].x = 41; creatures[1].x = 44;
creatures[1].y = 38; creatures[1].y = 38;
creatures[2].x = 100; creatures[2].x = 100;
creatures[2].y = 23; creatures[2].y = 23;
@ -63,9 +63,9 @@ extern "C" fn main() -> ! {
let mut world = [[0_u8; 32]; 32]; let mut world = [[0_u8; 32]; 32];
for i in 0..32 { for i in 0..32 {
world[0][i] = b'z'; world[0][i] = b'z';
world[31][i] = b'z'; world[19][i] = b'z';
world[i][0] = b'z'; world[i][0] = b'z';
world[i][31] = b'z'; world[i][29] = b'z';
} }
world[1][3] = b'B'; world[1][3] = b'B';
world[2][3] = b'G'; world[2][3] = b'G';
@ -78,12 +78,14 @@ extern "C" fn main() -> ! {
TIMER0_CONTROL.write(TimerControl::new().with_enabled(true)); TIMER0_CONTROL.write(TimerControl::new().with_enabled(true));
// bg
BG_PALETTE.index(1).write(Color::MAGENTA); BG_PALETTE.index(1).write(Color::MAGENTA);
OBJ_PALETTE.index(1).write(Color::CYAN); // obj
OBJ_PALETTE.index(16 * 1 + 1).write(Color::GREEN); let colors =
OBJ_PALETTE.index(16 * 2 + 1).write(Color::RED); [Color::CYAN, Color::GREEN, Color::RED, Color::BLUE, Color::YELLOW];
OBJ_PALETTE.index(16 * 3 + 1).write(Color::BLUE); for (pal, color) in colors.iter().enumerate() {
OBJ_PALETTE.index(16 * 4 + 1).write(Color::YELLOW); obj_palbank(pal).index(1).write(*color);
}
Cga8x8Thick.bitunpack_4bpp(CHARBLOCK0_4BPP.as_region(), 0); Cga8x8Thick.bitunpack_4bpp(CHARBLOCK0_4BPP.as_region(), 0);
Cga8x8Thick.bitunpack_4bpp(OBJ_TILES.as_region(), 0); Cga8x8Thick.bitunpack_4bpp(OBJ_TILES.as_region(), 0);