1.44mb-gamejam

submission for the 1.44mb game jam - https://2pgarcade.com/contest-144mb.html
git clone git://brookjeynes.dev/bjeynes/1.44mb-gamejam.git
Log | Files | Refs

ui.zig (738B)


      1 const raylib = @import("raylib");
      2 
      3 pub const Button = struct {
      4     size: raylib.Vector2,
      5     position: raylib.Vector2,
      6     bounds: raylib.Rectangle,
      7 
      8     pub fn new(size: raylib.Vector2, position: raylib.Vector2) Button {
      9         return .{
     10             .size = size,
     11             .position = position,
     12             .bounds = .{
     13                 .x = position.x,
     14                 .y = position.y,
     15                 .width = size.x,
     16                 .height = size.y,
     17             },
     18         };
     19     }
     20 
     21     pub fn clicked(self: Button, target: raylib.Vector2) bool {
     22         if (raylib.CheckCollisionPointRec(target, self.bounds)) {
     23             return raylib.IsMouseButtonReleased(raylib.MOUSE_BUTTON_LEFT);
     24         }
     25 
     26         return false;
     27     }
     28 };