misc
This commit is contained in:
parent
01107aece5
commit
84965904b3
1 changed files with 14 additions and 5 deletions
19
src/main.zig
19
src/main.zig
|
@ -78,7 +78,6 @@ pub const Component = struct {
|
||||||
x: u16 = 0,
|
x: u16 = 0,
|
||||||
y: u16 = 0,
|
y: u16 = 0,
|
||||||
|
|
||||||
state: *anyopaque,
|
|
||||||
processFn: *const fn (*Component) void,
|
processFn: *const fn (*Component) void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,13 +88,23 @@ pub const Circuit = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Battery = struct {
|
pub const Battery = struct {
|
||||||
pub fn process(component: *Component) Signal {}
|
component: Component = .{ .processFn = process },
|
||||||
|
value: f32,
|
||||||
|
|
||||||
|
pub fn process(component: *Component, inputs: []*Signal) []Signal {
|
||||||
|
_ = inputs;
|
||||||
|
const self: *Battery = @fieldParentPtr("component", component);
|
||||||
|
return &[_]Signal{.{
|
||||||
|
.digital = std.math.sign(self.value),
|
||||||
|
.analog = self.value,
|
||||||
|
}};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Signal = struct {
|
pub const Signal = struct {
|
||||||
digital: i2,
|
digital: i2 = 0,
|
||||||
analog: f32,
|
analog: f32 = 0.0,
|
||||||
color: u24,
|
color: u24 = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// pub const Wire = struct {
|
// pub const Wire = struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue