Init
This commit is contained in:
59
src/main.zig
Normal file
59
src/main.zig
Normal file
@@ -0,0 +1,59 @@
|
||||
const std = @import("std");
|
||||
const rl = @import("raylib");
|
||||
const rg = @import("raygui");
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const screenWidth = 800;
|
||||
const screenHeight = 450;
|
||||
const rect2 = rl.Rectangle{ .x = @as(f32, @floatFromInt(10)), .y = @as(f32, @floatFromInt(10)), .width = @as(f32, @floatFromInt(300)), .height = @as(f32, @floatFromInt(100)) };
|
||||
var msg_res : i32=-1;
|
||||
var state : i32=-1;
|
||||
rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
|
||||
defer rl.closeWindow(); // Close window and OpenGL context
|
||||
|
||||
rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!rl.windowShouldClose()) { // Detect window close button or ESC key
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rl.clearBackground(rl.getColor(rg.guiGetStyle(rl.DEFAULT,rl.BACKGROUND_COLOR)));
|
||||
|
||||
if(state != 0){
|
||||
msg_res = rg.guiMessageBox(rect2, "Title", "question?", "Nice;Cool;dsf;asd");
|
||||
if(msg_res > -1){
|
||||
state = msg_res;
|
||||
}
|
||||
rl.clearBackground(rl.Color.white);
|
||||
switch(state){
|
||||
1 => {
|
||||
rl.drawText("1", 190, 200, 20, rl.Color.red);
|
||||
},
|
||||
2 => {
|
||||
rl.drawText("2", 190, 200, 20, rl.Color.red);
|
||||
},
|
||||
else =>{},
|
||||
}
|
||||
}
|
||||
|
||||
rl.beginDrawing();
|
||||
defer rl.endDrawing();
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
}
|
||||
Reference in New Issue
Block a user