Game screens

This commit is contained in:
Tony Bark 2024-05-02 22:30:39 -04:00
parent a380de3a44
commit 6379ba1032

View file

@ -3,17 +3,25 @@ const rl = @import("raylib");
const MAX_INPUT_CHARS = 9; const MAX_INPUT_CHARS = 9;
const GameScreen = enum {
logo,
gameplay,
};
// Still in the proof of concept phase, don't midn the mess // Still in the proof of concept phase, don't midn the mess
pub fn main() anyerror!void { pub fn main() anyerror!void {
const screenWidth = 800; const screen_width = 800;
const screenHeight = 600; const screen_height = 600;
// var timePlayed: f32 = 0.0; // var timePlayed: f32 = 0.0;
rl.initWindow(screenWidth, screenHeight, "My Simulation"); rl.initWindow(screen_width, screen_height, "My Simulation");
defer rl.closeWindow(); defer rl.closeWindow();
// var textBox = rl.Rectangle.init(screenWidth / 2.0 - 100, 180, 50); var current_screen: GameScreen = .logo;
var frame_counter: i32 = 0;
// var textBox = rl.Rectangle.init(screen_width / 2.0 - 100, 180, 50);
// var mouseOnText = false; // var mouseOnText = false;
// var letterCount = 0; // var letterCount = 0;
@ -31,25 +39,33 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) { while (!rl.windowShouldClose()) {
// Update // Update
// Load music
// ------------------ // ------------------
// rl.updateMusicStream(music); switch (current_screen) {
// rl.playMusicStream(music); .logo => {
frame_counter += 1;
// timePlayed = rl.getMusicTimePlayed(music) / rl.getMusicTimeLength(music); if (frame_counter > 120) current_screen = .gameplay;
// if (timePlayed > 1.0) timePlayed = 1.0; },
.gameplay => {},
}
// ------------------ // ------------------
// Draw // Draw
rl.beginDrawing(); rl.beginDrawing();
defer rl.endDrawing(); defer rl.endDrawing();
switch (current_screen) {
.logo => {
// Splash screen // Splash screen
rl.drawTexture(splash, 0, 0, rl.Color.white); rl.drawTexture(splash, 0, 0, rl.Color.white);
rl.drawTexture(logo, screenWidth / 2.0 - 240, 30, rl.Color.white); rl.drawTexture(logo, screen_width / 2.0 - 240, 30, rl.Color.white);
// Loading text // Loading text
rl.drawText("Reticulating splines...", 20, screenHeight - 30, 20, rl.Color.white); rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white);
},
.gameplay => {
rl.clearBackground(rl.Color.black);
},
}
} }
} }