core: simplify event iterator
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
8b8489b3e2
commit
09d39fb694
13 changed files with 46 additions and 74 deletions
|
|
@ -71,8 +71,7 @@ fn init(app: *Mod, core: *mach.Core.Mod) !void {
|
|||
}
|
||||
|
||||
fn tick(core: *mach.Core.Mod, app: *Mod) !void {
|
||||
var iter = core.state().pollEvents();
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.close => core.schedule(.exit), // Tell mach.Core to exit the app
|
||||
else => {},
|
||||
|
|
|
|||
|
|
@ -71,8 +71,7 @@ fn init(app: *Mod, core: *mach.Core.Mod) !void {
|
|||
}
|
||||
|
||||
fn tick(core: *mach.Core.Mod, app: *Mod) !void {
|
||||
var iter = core.state().pollEvents();
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.close => core.schedule(.exit), // Tell mach.Core to exit the app
|
||||
else => {},
|
||||
|
|
|
|||
|
|
@ -96,10 +96,9 @@ fn tick(
|
|||
renderer: *Renderer.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
var iter = core.state().pollEvents();
|
||||
var direction = app.state().direction;
|
||||
var spawning = app.state().spawning;
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
|
|
@ -110,12 +110,9 @@ fn tick(
|
|||
glyphs: *Glyphs.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
// TODO(important): event polling should occur in mach.Core module and get fired as ECS events.
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
var direction = app.state().direction;
|
||||
var spawning = app.state().spawning;
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
|
|
@ -185,9 +185,8 @@ fn tick(
|
|||
) !void {
|
||||
// TODO(important): event polling should occur in mach.Core module and get fired as ECS events.
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
var gotta_go_fast = app.state().gotta_go_fast;
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
|
|
@ -104,9 +104,7 @@ fn tick(
|
|||
audio: *mach.Audio.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
|
|
@ -118,9 +118,7 @@ fn tick(
|
|||
audio: *mach.Audio.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| switch (ev.key) {
|
||||
.down => {
|
||||
|
|
|
|||
|
|
@ -114,12 +114,9 @@ fn tick(
|
|||
sprite_pipeline: *gfx.SpritePipeline.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
// TODO(important): event polling should occur in mach.Core module and get fired as ECS events.
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
var direction = app.state().direction;
|
||||
var spawning = app.state().spawning;
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
|
|
@ -125,12 +125,9 @@ fn tick(
|
|||
text_pipeline: *gfx.TextPipeline.Mod,
|
||||
app: *Mod,
|
||||
) !void {
|
||||
// TODO(important): event polling should occur in mach.Core module and get fired as ECS events.
|
||||
// TODO(Core)
|
||||
var iter = core.state().pollEvents();
|
||||
var direction = app.state().direction;
|
||||
var spawning = app.state().spawning;
|
||||
while (iter.next()) |event| {
|
||||
while (core.state().nextEvent()) |event| {
|
||||
switch (event) {
|
||||
.key_press => |ev| {
|
||||
switch (ev.key) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue