Skip to content

Commit

Permalink
Game screens
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Bark committed May 3, 2024
1 parent a380de3 commit 6379ba1
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ const rl = @import("raylib");

const MAX_INPUT_CHARS = 9;

const GameScreen = enum {
logo,
gameplay,
};

// Still in the proof of concept phase, don't midn the mess
pub fn main() anyerror!void {
const screenWidth = 800;
const screenHeight = 600;
const screen_width = 800;
const screen_height = 600;

// var timePlayed: f32 = 0.0;

rl.initWindow(screenWidth, screenHeight, "My Simulation");
rl.initWindow(screen_width, screen_height, "My Simulation");
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 letterCount = 0;

Expand All @@ -31,25 +39,33 @@ pub fn main() anyerror!void {
while (!rl.windowShouldClose()) {

// Update

// Load music
// ------------------
// rl.updateMusicStream(music);
// rl.playMusicStream(music);
switch (current_screen) {
.logo => {
frame_counter += 1;

// timePlayed = rl.getMusicTimePlayed(music) / rl.getMusicTimeLength(music);
// if (timePlayed > 1.0) timePlayed = 1.0;
if (frame_counter > 120) current_screen = .gameplay;
},
.gameplay => {},
}
// ------------------

// Draw
rl.beginDrawing();
defer rl.endDrawing();

// Splash screen
rl.drawTexture(splash, 0, 0, rl.Color.white);
rl.drawTexture(logo, screenWidth / 2.0 - 240, 30, rl.Color.white);
switch (current_screen) {
.logo => {
// Splash screen
rl.drawTexture(splash, 0, 0, rl.Color.white);
rl.drawTexture(logo, screen_width / 2.0 - 240, 30, rl.Color.white);

// Loading text
rl.drawText("Reticulating splines...", 20, screenHeight - 30, 20, rl.Color.white);
// Loading text
rl.drawText("Reticulating splines...", 20, screen_height - 30, 20, rl.Color.white);
},
.gameplay => {
rl.clearBackground(rl.Color.black);
},
}
}
}

0 comments on commit 6379ba1

Please sign in to comment.