improve v0.1, and add docs
This commit is contained in:
@@ -18,6 +18,10 @@ impl Color {
|
||||
Self((r5 << 11) | (g6 << 5) | b5)
|
||||
}
|
||||
|
||||
pub const fn gray_scale(c: u8) -> Self {
|
||||
Self::rgb(c, c, c)
|
||||
}
|
||||
|
||||
pub const fn from_raw(raw: u16) -> Self {
|
||||
Self(raw)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::peripherals::{Gfx, InputSignals, Pad, Touch};
|
||||
use crate::peripherals::{BlendMode, Gfx, InputSignals, Pad, Touch};
|
||||
use crate::Color;
|
||||
|
||||
/// PROMETEU "hardware lógico" (v0).
|
||||
/// O Host alimenta INPUT/TOUCH e chama `step_frame()` em 60Hz.
|
||||
/// O Host alimenta INPUT SIGNALS e chama `step_frame()` em 60Hz.
|
||||
pub struct Machine {
|
||||
pub gfx: Gfx,
|
||||
pub pad: Pad,
|
||||
@@ -54,7 +54,10 @@ impl Machine {
|
||||
Color::rgb(0xFF, 0x40, 0x40)
|
||||
};
|
||||
|
||||
self.gfx.fill_rect(x, y, 24, 24, color);
|
||||
// game
|
||||
self.gfx.fill_rect(x, y, 20, 20, color);
|
||||
// smoke
|
||||
self.gfx.fill_rect_blend(140, 0, 40, 180, Color::gray_scale(0x88), BlendMode::Half)
|
||||
}
|
||||
|
||||
/// Final do frame: troca buffers.
|
||||
@@ -63,8 +66,8 @@ impl Machine {
|
||||
}
|
||||
|
||||
fn demo_pos(&self) -> (i32, i32) {
|
||||
let t = (self.frame_index % 280) as i32;
|
||||
let z = (self.pad.a.hold_frames % 140) as i32;
|
||||
(20 + t, z)
|
||||
let x = (self.frame_index % 300) as i32;
|
||||
let y = (self.pad.a.hold_frames % 160) as i32;
|
||||
(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ mod touch;
|
||||
mod input_signal;
|
||||
|
||||
pub use gfx::Gfx;
|
||||
pub use gfx::BlendMode;
|
||||
pub use input_signal::InputSignals;
|
||||
pub use pad::Pad;
|
||||
pub use touch::Touch;
|
||||
|
||||
Reference in New Issue
Block a user