update of drboy WIP
This commit is contained in:
parent
b6cf7e43c7
commit
ae84c66d13
1 changed files with 30 additions and 4 deletions
|
@ -33,14 +33,27 @@ struct Player {
|
||||||
x: i16,
|
x: i16,
|
||||||
y: i16,
|
y: i16,
|
||||||
}
|
}
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Enemy {
|
||||||
|
bitmap: *const u8,
|
||||||
|
bitmap_frame: u8,
|
||||||
|
x: i16,
|
||||||
|
y: i16,
|
||||||
|
}
|
||||||
|
impl Enemy {
|
||||||
|
fn move_down(&mut self) {
|
||||||
|
self.x -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
static mut p: Player = Player {
|
static mut p: Player = Player {
|
||||||
bitmap: get_sprite_addr!(enemies),
|
bitmap: get_sprite_addr!(enemies),
|
||||||
bitmap_frame: 0,
|
bitmap_frame: 0,
|
||||||
x: 10,
|
x: 10,
|
||||||
y: 10,
|
y: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
progmem!(
|
progmem!(
|
||||||
static mut walls: Vec<Player, 100> = Vec::new();
|
static mut walls: Vec<Enemy, 100> = Vec::new();
|
||||||
);
|
);
|
||||||
|
|
||||||
unsafe impl Sync for Player {}
|
unsafe impl Sync for Player {}
|
||||||
|
@ -63,9 +76,22 @@ pub unsafe extern "C" fn loop_() {
|
||||||
}
|
}
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
sprites::draw_override(p.x, p.y, p.bitmap, p.bitmap_frame);
|
sprites::draw_override(p.x, p.y, p.bitmap, p.bitmap_frame);
|
||||||
walls.iter().for_each(|f| {
|
walls.iter_mut().for_each(|f| {
|
||||||
sprites::draw_override(f.x * 8, f.y * 8, f.bitmap, f.bitmap_frame);
|
sprites::draw_override(f.x * 8, f.y * 8, f.bitmap, f.bitmap_frame);
|
||||||
|
if arduboy.every_x_frames(30) {
|
||||||
|
f.move_down();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
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();
|
arduboy.poll_buttons();
|
||||||
if arduboy.pressed(UP) {
|
if arduboy.pressed(UP) {
|
||||||
p.y -= 1;
|
p.y -= 1;
|
||||||
|
@ -87,10 +113,10 @@ pub unsafe extern "C" fn loop_() {
|
||||||
}
|
}
|
||||||
if arduboy.just_pressed(B) {
|
if arduboy.just_pressed(B) {
|
||||||
walls
|
walls
|
||||||
.push(Player {
|
.push(Enemy {
|
||||||
bitmap: get_sprite_addr!(pills),
|
bitmap: get_sprite_addr!(pills),
|
||||||
bitmap_frame: random_less_than(3) as u8,
|
bitmap_frame: random_less_than(3) as u8,
|
||||||
x: random_between(0, 16) as i16,
|
x: random_between(15, 16) as i16,
|
||||||
y: random_between(0, 8) as i16,
|
y: random_between(0, 8) as i16,
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue