Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
c9fe252019
|
@ -53,8 +53,8 @@ fn getTab(self: *Self) MenuTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tick(self: *Self) State {
|
pub fn tick(self: *Self) State {
|
||||||
const sel = self.getSel();
|
//const sel = self.getSel();
|
||||||
const tab = self.getTab();
|
//const tab = self.getTab();
|
||||||
var key_state = SDL.getKeyboardState();
|
var key_state = SDL.getKeyboardState();
|
||||||
|
|
||||||
for (self.action_list) |*action| {
|
for (self.action_list) |*action| {
|
||||||
|
@ -72,11 +72,11 @@ pub fn tick(self: *Self) State {
|
||||||
action.*.call(self);
|
action.*.call(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std.debug.print(
|
//std.debug.print(
|
||||||
\\Tab: {s}
|
//\\Tab: {s}
|
||||||
\\Selection: {s}
|
//\\Selection: {s}
|
||||||
\\
|
//\\
|
||||||
, .{ tab.name, sel.name });
|
//, .{ tab.name, sel.name });
|
||||||
return self.state;
|
return self.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ pub fn main() !void {
|
||||||
try SDL.image.init(.{ .jpg = true });
|
try SDL.image.init(.{ .jpg = true });
|
||||||
|
|
||||||
mainLoop: while (true) {
|
mainLoop: while (true) {
|
||||||
|
const start = SDL.getTicks64();
|
||||||
|
|
||||||
while (SDL.pollEvent()) |ev| {
|
while (SDL.pollEvent()) |ev| {
|
||||||
switch (ev) {
|
switch (ev) {
|
||||||
.quit => break :mainLoop,
|
.quit => break :mainLoop,
|
||||||
|
@ -26,17 +28,15 @@ pub fn main() !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = SDL.getTicks64();
|
|
||||||
|
|
||||||
current_state = switch (current_state) {
|
current_state = switch (current_state) {
|
||||||
.main_menu => main_menu.tick(),
|
.main_menu => main_menu.tick(),
|
||||||
.game => game.tick(),
|
.game => game.tick(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
renderer.render();
|
renderer.render();
|
||||||
|
|
||||||
const delay = SDL.getTicks64() - start;
|
const delay = SDL.getTicks64() - start;
|
||||||
|
|
||||||
std.debug.print("{} ms\n", .{delay});
|
std.debug.print("{} ms\n", .{delay});
|
||||||
if (delay < 16) {
|
if (delay < 16) {
|
||||||
SDL.delay(16 - @intCast(u32, delay));
|
SDL.delay(16 - @intCast(u32, delay));
|
||||||
|
|
Loading…
Reference in New Issue