From 8af1af7350281f5d263b9fbc9779ff7d4cddcf2d Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Mon, 11 Aug 2025 12:35:44 +0200 Subject: Added custom color examples and fixed arg parsing bug --- README.md | 30 ++++++++++++++++++++++++++++++ main.c | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6de516d..8ff0d81 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,36 @@ close_window() | `color.BLANK` | 0 | 0 | 0 | 0 | | `color.MAGENTA` | 255 | 0 | 255 | 255 | +#### Using custom colors + +Color is essentially a structure with RGBA data. So constructing new colors is +very easy. + +Alpha channel can be omitted and will by default be 255. + +```lua +-- my_game.lua + +open_window(800, 800, "My Game") +set_fps(60) + +my_color1 = { r = 200, g = 200, b = 200, a = 255 } +my_color2 = { r = 200, g = 200, b = 200 } + +while window_running() do + start_drawing() + clear_window(color.BLACK) + + draw_rect(100, 100, 100, 100, my_color1) + draw_rect(300, 100, 100, 100, my_color2) + + draw_info() + stop_drawing() +end + +close_window() +``` + ## Libraries & Assets - https://github.com/rxi/microtar diff --git a/main.c b/main.c index aa72b33..e895f2a 100644 --- a/main.c +++ b/main.c @@ -528,7 +528,7 @@ static int l_stop_sound(lua_State *L) { static void help(const char *argv0) { printf("Usage: %s [options]\n" "\nAvailable options:\n" - " -r,--run=file.lua run input file\n" + " -f,--file=file.lua run input file\n" " -b,--bundle bundles this folder\n" " -d,--debug prints debug information\n" " -h,--help this help\n" @@ -550,7 +550,7 @@ int main(int argc, char *argv[]) { const char short_options[] = "f:dbhv"; const struct option long_options[] = { - { "file", 1, NULL, 'r' }, + { "file", 1, NULL, 'f' }, { "debug", 0, NULL, 'd' }, { "bundle", 0, NULL, 'b' }, { "help", 0, NULL, 'h' }, -- cgit v1.2.3