Create a proto-game
This commit is contained in:
parent
df146d7c0a
commit
5c54d2d48c
@ -124,6 +124,10 @@ pub static COMMA: [u8; 8] = [
|
|||||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b10000000,
|
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b10000000,
|
||||||
];
|
];
|
||||||
#[unsafe(link_section = ".progmem.data")]
|
#[unsafe(link_section = ".progmem.data")]
|
||||||
|
pub static COLON: [u8; 8] = [
|
||||||
|
0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01100000, 0b01100000,
|
||||||
|
];
|
||||||
|
#[unsafe(link_section = ".progmem.data")]
|
||||||
pub static EMPTY: [u8; 8] = [
|
pub static EMPTY: [u8; 8] = [
|
||||||
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,
|
||||||
];
|
];
|
||||||
@ -208,6 +212,7 @@ fn letter(character: char) -> *const [u8; 8] {
|
|||||||
'9' => addr_of!(NUM_9),
|
'9' => addr_of!(NUM_9),
|
||||||
'!' => addr_of!(EXCLAMATION),
|
'!' => addr_of!(EXCLAMATION),
|
||||||
',' => addr_of!(COMMA),
|
',' => addr_of!(COMMA),
|
||||||
|
':' => addr_of!(COLON),
|
||||||
_ => addr_of!(EMPTY),
|
_ => addr_of!(EMPTY),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,7 +280,7 @@ pub fn draw_number<T: DelayNs, DCPin: PinOps, RSTPin: PinOps>(
|
|||||||
position: &mut Vec2,
|
position: &mut Vec2,
|
||||||
scale: u16,
|
scale: u16,
|
||||||
) {
|
) {
|
||||||
if number > 10 {
|
if number >= 10 {
|
||||||
draw_number(display, number / 10, fg, bg, position, scale);
|
draw_number(display, number / 10, fg, bg, position, scale);
|
||||||
}
|
}
|
||||||
let character = match number % 10 {
|
let character = match number % 10 {
|
||||||
|
44
src/main.rs
44
src/main.rs
@ -85,43 +85,53 @@ fn main() -> ! {
|
|||||||
let mut position = Vec2 { x: 10, y: 10 };
|
let mut position = Vec2 { x: 10, y: 10 };
|
||||||
draw_text(
|
draw_text(
|
||||||
&mut display,
|
&mut display,
|
||||||
"hi,my name is adafruit!nice to meet you!\n",
|
"how many times can you press the button:\n",
|
||||||
Rgb565::white(),
|
Rgb565::white(),
|
||||||
Rgb565::black(),
|
Rgb565::black(),
|
||||||
&mut position,
|
&mut position,
|
||||||
3,
|
3,
|
||||||
);
|
);
|
||||||
|
let mut counter = 0;
|
||||||
draw_number(
|
draw_number(
|
||||||
&mut display,
|
&mut display,
|
||||||
1234,
|
counter,
|
||||||
Rgb565::white(),
|
Rgb565::white(),
|
||||||
Rgb565::black(),
|
Rgb565::black(),
|
||||||
&mut position,
|
&mut position.clone(),
|
||||||
3,
|
3,
|
||||||
);
|
);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if button.poll() {
|
if button.poll() {
|
||||||
match draw_image(
|
counter += 1;
|
||||||
&mut serial,
|
draw_number(
|
||||||
&mut images[idx].iter(),
|
|
||||||
&mut display,
|
&mut display,
|
||||||
Vec2 { x: 0, y: 0 },
|
counter,
|
||||||
) {
|
|
||||||
Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(),
|
|
||||||
Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(),
|
|
||||||
}
|
|
||||||
|
|
||||||
draw_text(
|
|
||||||
&mut display,
|
|
||||||
"you just lost the game!",
|
|
||||||
Rgb565::white(),
|
Rgb565::white(),
|
||||||
Rgb565::black(),
|
Rgb565::black(),
|
||||||
&mut Vec2 { x: 10, y: 10 },
|
&mut position.clone(),
|
||||||
3,
|
3,
|
||||||
);
|
);
|
||||||
|
// match draw_image(
|
||||||
|
// &mut serial,
|
||||||
|
// &mut images[idx].iter(),
|
||||||
|
// &mut display,
|
||||||
|
// Vec2 { x: 0, y: 0 },
|
||||||
|
// ) {
|
||||||
|
// Ok(_) => ufmt::uwriteln!(serial, "Successfully read QOI").unwrap(),
|
||||||
|
// Err(e) => ufmt::uwriteln!(serial, "Error: {:?}", e).unwrap(),
|
||||||
|
// }
|
||||||
|
|
||||||
idx = (idx + 1) % len;
|
// draw_text(
|
||||||
|
// &mut display,
|
||||||
|
// "you just lost the game!",
|
||||||
|
// Rgb565::white(),
|
||||||
|
// Rgb565::black(),
|
||||||
|
// &mut Vec2 { x: 10, y: 10 },
|
||||||
|
// 3,
|
||||||
|
// );
|
||||||
|
|
||||||
|
// idx = (idx + 1) % len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user