diff --git a/Examples/drboy/assets/Ingame-overlay.aseprite b/Examples/drboy/assets/Ingame-overlay.aseprite new file mode 100644 index 0000000..1689d1d Binary files /dev/null and b/Examples/drboy/assets/Ingame-overlay.aseprite differ diff --git a/Examples/drboy/assets/Ingame-overlay1.png b/Examples/drboy/assets/Ingame-overlay1.png new file mode 100644 index 0000000..ec212fc Binary files /dev/null and b/Examples/drboy/assets/Ingame-overlay1.png differ diff --git a/Examples/drboy/assets/Ingame-overlay2.png b/Examples/drboy/assets/Ingame-overlay2.png new file mode 100644 index 0000000..368d4a8 Binary files /dev/null and b/Examples/drboy/assets/Ingame-overlay2.png differ diff --git a/Examples/drboy/assets/Ingame-overlay3.png b/Examples/drboy/assets/Ingame-overlay3.png new file mode 100644 index 0000000..d7ec085 Binary files /dev/null and b/Examples/drboy/assets/Ingame-overlay3.png differ diff --git a/Examples/drboy/assets/Titlescreen.aseprite b/Examples/drboy/assets/Titlescreen.aseprite new file mode 100644 index 0000000..5b5cf29 Binary files /dev/null and b/Examples/drboy/assets/Titlescreen.aseprite differ diff --git a/Examples/drboy/assets/Titlescreen.png b/Examples/drboy/assets/Titlescreen.png new file mode 100644 index 0000000..c96bf90 Binary files /dev/null and b/Examples/drboy/assets/Titlescreen.png differ diff --git a/Examples/drboy/src/gameloop.rs b/Examples/drboy/src/gameloop.rs new file mode 100644 index 0000000..a5b7a3d --- /dev/null +++ b/Examples/drboy/src/gameloop.rs @@ -0,0 +1,118 @@ +use crate::*; + +pub unsafe fn gameloop() { + arduboy.set_cursor(70, 0); + arduboy.print(get_string_addr!(overlay_score)); + arduboy.print(p.counter as i16); + match p.live { + 3 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_3hearts), 0), + 2 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_2hearts), 0), + 1 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_1heart), 0), + _ => (), + } + if p.active { + sprites::draw_override(p.rect.x, p.rect.y, p.bitmap, p.bitmap_frame as u8); + } + + if p.immortal { + p.immortal_frame_count += 1; + if arduboy.every_x_frames(10) { + p.active = !p.active + } + if p.immortal_frame_count == 60 { + p.immortal_frame_count = 0; + p.immortal = false; + p.active = true + } + } + vec_enemies.iter_mut().for_each(|f| { + if f.active { + sprites::draw_override(f.rect.x * 8, f.rect.y * 8, f.bitmap, f.bitmap_frame); + } + + if arduboy.every_x_frames(p.speed as u8) && f.active { + f.move_down(); + if f.rect.x < 0 { + f.active = false; + p.live -= 1; + } + } + + let frect = Rect { + x: f.rect.x * 8, + y: f.rect.y * 8, + width: 8, + height: 8, + }; + if !p.immortal && f.active { + if arduboy.collide_rect(p.rect, frect) { + if p.bitmap_frame as u8 == f.bitmap_frame { + f.active = false; + p.speed_change = false; + p.counter += 1; + } else { + p.live -= 1; + p.immortal = true; + } + } + } + }); + if arduboy.every_x_frames((p.speed * 2) as u8) && enemy_count < 30 { + vec_enemies + .push(Enemy { + active: true, + bitmap: get_sprite_addr!(enemies), + bitmap_frame: random_less_than(3) as u8, + rect: Rect { + x: random_between(15, 16) as i16, + y: random_between(1, 8) as i16, + width: 8, + height: 8, + }, + }) + .unwrap(); + enemy_count += 1 + } + if p.live == 0 { + p.gamemode = GameMode::Losescreen; + } + arduboy.poll_buttons(); + if arduboy.pressed(UP) { + if p.rect.y > 7 { + p.rect.y -= 1; + } + } + if arduboy.pressed(DOWN) { + if p.rect.y < 56 { + p.rect.y += 1; + } + } + if arduboy.pressed(LEFT) { + if p.rect.x > 0 { + p.rect.x -= 1; + } + } + if arduboy.pressed(RIGHT) { + if p.rect.x < 120 { + p.rect.x += 1; + } + } + if arduboy.just_pressed(A) { + p.bitmap_frame += 1; + if p.bitmap_frame > 2 { + p.bitmap_frame = 0 + } + } + if arduboy.just_pressed(B) { + p.bitmap_frame -= 1; + if p.bitmap_frame < 0 { + p.bitmap_frame = 2 + } + } + if p.counter % 5 == 0 && p.counter != 0 && !p.speed_change { + p.speed_change = true; + p.speed -= 1 + } +} + +progmem!(); diff --git a/Examples/drboy/src/lib.rs b/Examples/drboy/src/lib.rs index f82331f..86ef923 100644 --- a/Examples/drboy/src/lib.rs +++ b/Examples/drboy/src/lib.rs @@ -4,59 +4,71 @@ //Include the Arduboy Library #[allow(unused_imports)] use arduboy_rust::prelude::*; +mod gameloop; #[allow(dead_code)] -const arduboy: Arduboy2 = Arduboy2::new(); +pub const arduboy: Arduboy2 = Arduboy2::new(); -// Progmem data -// 8x16 - -progmem!( - pub static pills: [u8; _] = [ - // width, height, - 8, 8, 0x7e, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x7e, // TILE 00 - 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7e, // TILE 01 - 0x7e, 0xd5, 0xab, 0xd5, 0xab, 0xd5, 0xab, 0x7e, // TILE 02 - ]; - pub static enemies: [u8; _] = [ - 8, 8, // width, height, - 0xa3, 0x51, 0xa6, 0x51, 0xa1, 0x56, 0xa1, 0x53, // TILE 00 - 0x7e, 0xdf, 0xb3, 0xdf, 0xbf, 0xd3, 0xbf, 0x7e, // TILE 01 - 0x7e, 0xc1, 0xad, 0xc1, 0xa1, 0xcd, 0xa1, 0x7e, // TILE 02 - ]; -); // dynamic ram variables #[derive(Debug)] -struct Player { - bitmap: *const u8, - bitmap_frame: u8, - x: i16, - y: i16, -} -#[derive(Debug)] -struct Enemy { - bitmap: *const u8, - bitmap_frame: u8, - x: i16, - y: i16, +pub struct Enemy { + pub active: bool, + pub bitmap: *const u8, + pub bitmap_frame: u8, + pub rect: Rect, } impl Enemy { - fn move_down(&mut self) { - self.x -= 1; + pub fn move_down(&mut self) { + self.rect.x -= 1; } } -static mut p: Player = Player { - bitmap: get_sprite_addr!(enemies), +#[derive(Debug)] +pub struct Player { + pub gamemode: GameMode, + pub immortal: bool, + pub immortal_frame_count: u8, + pub active: bool, + pub live: u8, + pub speed: u8, + pub speed_change: bool, + pub counter: u8, + pub bitmap: *const u8, + pub bitmap_frame: i8, + pub rect: Rect, + pub gameover_height: i16, +} + +pub static mut p: Player = Player { + gamemode: GameMode::Titlescreen, + live: 3, + immortal: false, + immortal_frame_count: 0, + active: true, + counter: 0, + speed: 30, + speed_change: false, + bitmap: get_sprite_addr!(player), bitmap_frame: 0, - x: 10, - y: 10, + rect: Rect { + x: 0, + y: 8, + width: 8, + height: 8, + }, + gameover_height: -30, }; -progmem!( - static mut walls: Vec = Vec::new(); -); - unsafe impl Sync for Player {} +#[derive(Debug)] +pub enum GameMode { + Titlescreen, + GameLoop, + Winscreen, + Losescreen, + Scoreboard, + Reset, + NextLevel, +} // The setup() function runs once when you turn your Arduboy on #[no_mangle] @@ -75,52 +87,174 @@ pub unsafe extern "C" fn loop_() { return; } arduboy.clear(); - sprites::draw_override(p.x, p.y, p.bitmap, p.bitmap_frame); - walls.iter_mut().for_each(|f| { - sprites::draw_override(f.x * 8, f.y * 8, f.bitmap, f.bitmap_frame); - if arduboy.every_x_frames(30) { - f.move_down(); + + match p.gamemode { + GameMode::Titlescreen => { + sprites::draw_override(0, 0, get_sprite_addr!(titlescreen), 0); + if arduboy.pressed(A) { + p.gamemode = GameMode::GameLoop; + } } - }); - if arduboy.every_x_frames(60) { - walls - .push(Enemy { - bitmap: get_sprite_addr!(pills), - bitmap_frame: random_less_than(3) as u8, - x: random_between(15, 16) as i16, - y: random_between(0, 8) as i16, - }) - .unwrap(); - } - arduboy.poll_buttons(); - if arduboy.pressed(UP) { - p.y -= 1; - } - if arduboy.pressed(DOWN) { - p.y += 1; - } - if arduboy.pressed(LEFT) { - p.x -= 1; - } - if arduboy.pressed(RIGHT) { - p.x += 1; - } - if arduboy.just_pressed(A) { - p.bitmap_frame += 1; - if p.bitmap_frame > 2 { - p.bitmap_frame = 0 + GameMode::GameLoop => { + gameloop::gameloop(); + } + GameMode::Losescreen => { + //todo + arduboy.set_text_size(2); + arduboy.set_cursor(13, p.gameover_height); + arduboy.print(get_string_addr!(text_gameover)); + if arduboy.every_x_frames(2) && p.gameover_height < 15 { + p.gameover_height += 1 + } + if p.gameover_height == 15 { + arduboy.set_text_size(1); + arduboy.set_cursor(13, 35); + arduboy.print(get_string_addr!(text_gameover_score)); + arduboy.print(p.counter as i16); + } + } + GameMode::Winscreen => { + arduboy.set_text_size(2); + arduboy.set_cursor(13, p.gameover_height); + arduboy.print(get_string_addr!(text_levelwin)); + if arduboy.every_x_frames(2) && p.gameover_height < 15 { + p.gameover_height += 1 + } + if p.gameover_height == 15 { + arduboy.set_text_size(1); + arduboy.set_cursor(13, 35); + arduboy.print(get_string_addr!(text_gameover_score)); + arduboy.print(p.counter as i16); + } + } + GameMode::Scoreboard => { + //todo + } + GameMode::Reset => { + //todo + } + GameMode::NextLevel => { + //todo } - } - if arduboy.just_pressed(B) { - walls - .push(Enemy { - bitmap: get_sprite_addr!(pills), - bitmap_frame: random_less_than(3) as u8, - x: random_between(15, 16) as i16, - y: random_between(0, 8) as i16, - }) - .unwrap(); } arduboy.display(); } +pub static mut enemy_count: u8 = 0; +pub static mut vec_enemies: Vec = Vec::::new(); +progmem!( + static text_gameover: [u8; _] = *b"Game Over\0"; + static text_levelwin: [u8; _] = *b"Congrats\0"; + static text_gameover_score: [u8; _] = *b"Your score is: \0"; + pub static player: [u8; _] = [ + 8, 8, // width, height, + 0xa3, 0x51, 0xa6, 0x51, 0xa1, 0x56, 0xa1, 0x53, // TILE 00 + 0x7e, 0xdf, 0xb3, 0xdf, 0xbf, 0xd3, 0xbf, 0x7e, // TILE 01 + 0x7e, 0xc1, 0xad, 0xc1, 0xa1, 0xcd, 0xa1, 0x7e, // TILE 02 + ]; + pub static titlescreen: [u8; _] = [ + // width, height, + 128, 64, 0xff, 0xff, 0xff, 0x3f, 0x1f, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x0f, 0x1f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x07, 0x06, 0x1e, 0xfc, 0xf0, 0x00, 0x00, 0x00, 0xf0, 0xf0, 0x60, 0x30, 0x30, 0x30, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0xfe, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0x60, 0x30, + 0x30, 0x30, 0x30, 0x60, 0xe0, 0x80, 0x00, 0x10, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x80, + 0xe0, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x70, 0x30, 0x3c, 0x1f, 0x07, 0x00, 0x00, + 0x00, 0x7f, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x7f, 0x60, 0x60, 0x60, 0x60, 0x60, 0x71, 0x3f, + 0x1e, 0x00, 0x00, 0x00, 0x0f, 0x3f, 0x30, 0x60, 0x60, 0x60, 0x60, 0x30, 0x3f, 0x0f, 0x00, + 0x00, 0x00, 0x03, 0x0f, 0xfe, 0xf0, 0x3e, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x07, 0x03, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x10, 0x60, 0x10, 0x10, 0x60, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x60, 0x56, 0x60, 0x50, + 0x66, 0x50, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x05, 0x0a, 0x05, + 0x0a, 0x05, 0x0a, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x6f, 0x59, + 0x6f, 0x5f, 0x69, 0x5f, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xe0, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xc0, 0xe0, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xd9, 0xb6, 0xb6, 0xb6, 0xcd, 0xff, 0xc7, 0xbb, 0xbb, 0xbb, 0xff, 0xc7, 0xbb, 0xbb, 0xbb, + 0xc7, 0xff, 0x83, 0xfb, 0xfb, 0xff, 0xff, 0xc7, 0xab, 0xab, 0xab, 0xa7, 0xff, 0xbb, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xb6, 0xb6, 0xb6, 0xc9, 0xff, 0xff, 0x7f, + 0x3e, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1c, 0x3e, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xf6, 0xf6, 0xf6, 0xf9, 0xff, + 0x80, 0xff, 0x9f, 0xab, 0xab, 0xab, 0x87, 0xff, 0x73, 0x4f, 0x3f, 0xcf, 0xf3, 0xff, 0xbb, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xc7, 0xe9, 0xee, 0xe9, 0xc7, 0xbf, + 0xff, 0xff, 0xff, 0xff, 0xff, + ]; + + pub static overlay_score: [u8; _] = *b"Score: \0"; + + pub static enemies: [u8; _] = [ + 8, 8, // width, height, + 0x7e, 0xd5, 0xab, 0xd5, 0xab, 0xd5, 0xab, 0x7e, // TILE 00 Gray + 0x7e, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7e, // TILE 01 White + 0x7e, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x7e, // TILE 02 Black + ]; + pub static overlay_3hearts: [u8; _] = [ + // width, height, + 64, 8, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c, + 0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e, + 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, + 0x0c, 0x00, 0x00, 0x00, 0x00, + ]; + pub static overlay_2hearts: [u8; _] = [ + // width, height, + 64, 8, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c, + 0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e, + 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + ]; + pub static overlay_1heart: [u8; _] = [ + // width, height, + 64, 8, 0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c, + 0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, + ]; +); diff --git a/arduboy-rust/src/library/arduboy2.rs b/arduboy-rust/src/library/arduboy2.rs index 8cd478c..0a72b9f 100644 --- a/arduboy-rust/src/library/arduboy2.rs +++ b/arduboy-rust/src/library/arduboy2.rs @@ -40,6 +40,7 @@ impl Not for Color { } } /// This struct is used by a few Arduboy functions. +#[derive(Debug, Clone, Copy)] pub struct Rect { /// Position X pub x: i16, @@ -51,6 +52,7 @@ pub struct Rect { pub height: u8, } /// This struct is used by a few Arduboy functions. +#[derive(Debug, Clone, Copy)] pub struct Point { /// Position X pub x: i16, diff --git a/arduboy-rust/src/library/progmem.rs b/arduboy-rust/src/library/progmem.rs index ac890bd..622227d 100644 --- a/arduboy-rust/src/library/progmem.rs +++ b/arduboy-rust/src/library/progmem.rs @@ -80,7 +80,7 @@ pub(super) use progmem; #[macro_export] macro_rules! get_sprite_addr { ( $s:expr ) => { - addr_of!($s) as *const u8 + unsafe { addr_of!($s) as *const u8 } }; } pub(super) use get_sprite_addr; @@ -89,7 +89,7 @@ pub(super) use get_sprite_addr; #[macro_export] macro_rules! get_tones_addr { ( $s:expr ) => { - addr_of!($s) as *const u16 + unsafe { addr_of!($s) as *const u16 } }; } pub(super) use get_tones_addr; @@ -99,7 +99,7 @@ pub(super) use get_tones_addr; macro_rules! get_string_addr { ( $s:expr ) => { Pstring { - pointer: addr_of!($s) as *const i8, + pointer: unsafe { addr_of!($s) as *const i8 }, } }; }