diff --git a/README.md b/README.md index 61d732b..b66edbc 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ooga booga - [Examples & Documentation](#examples--documentation) - [Known bugs](#known-bugs) - [Licensing](#licensing) -- [Contributions)(#contributions) +- [Contributions](#contributions) ## What is ooga booga? @@ -109,7 +109,17 @@ You can obtain the full commercial license by being an active member of the comm [Learn more here](https://www.skool.com/game-dev) ## Contributions -I'm not sure what the most optimal way to do this but here are some house rules I'll continually update which I'd like us to follow for contributions: - - Open PR's with `dev` as the base branch -- Keep it simple \ No newline at end of file +- Keep it simple, no multi-layer abstractions +- Keep the implementation code readable, comment confusing code +- If you're introducing a new file/module, document the API and how to use it at the top of the file +- Add tests in tests.c if it makes sense to test +- Run tests (#define RUN_TESTS 1) before submitting PR +- Don't submit PR's for: + - the sake of submitting PR's + - Small polishing/tweaks that doesn't really affect the people making games +- When you submit a PR, please answer these prompts (if you're submitting a bugfix then you can skip this): + - What feature/bugfix does this PR implement? + - Why do we need this? + - Describe at least one specific and practical problem this solves for people developing a game + - Does this add complexity/friction for people making games? If so, how do you justify that? \ No newline at end of file diff --git a/build.c b/build.c index 9e16373..fbb44aa 100644 --- a/build.c +++ b/build.c @@ -37,11 +37,11 @@ typedef struct Context_Extra { // #include "oogabooga/examples/text_rendering.c" // #include "oogabooga/examples/custom_logger.c" -#include "oogabooga/examples/renderer_stress_test.c" +// #include "oogabooga/examples/renderer_stress_test.c" // #include "oogabooga/examples/tile_game.c" // #include "oogabooga/examples/audio_test.c" // #include "oogabooga/examples/custom_shader.c" -// #include "oogabooga/examples/growing_array_example.c" +#include "oogabooga/examples/growing_array_example.c" // This is where you swap in your own project! // #include "entry_yourepicgamename.c" diff --git a/changelog.txt b/changelog.txt index 0b531ee..f0a8ee5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,5 @@ -## v0.01.003 - +## v0.01.003 - Nothing, really - Os layer - Implemented setting of mouse pointers, either to system standard pointers or a custom image - Ignore SETCURSOR events unless window resize @@ -10,7 +10,9 @@ - Fix bad uv sampling bug when uneven window dimensions - Misc - - + - Deprecate Rangef stuff + - peek_random() + - Update #Contributions ## v0.01.002 - Flexible build options, Hotloading, growing array diff --git a/oogabooga/cpu.c b/oogabooga/cpu.c index 087ebd4..1c0a0cf 100644 --- a/oogabooga/cpu.c +++ b/oogabooga/cpu.c @@ -170,7 +170,7 @@ typedef struct Cpu_Capabilities { #define COMPILER_CAN_DO_AVX512 0 #endif - #define DEPRECATED(proc, msg) proc __attribute__((deprecated(msg))) + #define DEPRECATED(proc, msg) __attribute__((deprecated(msg))) proc inline bool compare_and_swap_8(uint8_t *a, uint8_t b, uint8_t old) { diff --git a/oogabooga/examples/text_rendering.c b/oogabooga/examples/text_rendering.c index befa5f4..10c9478 100644 --- a/oogabooga/examples/text_rendering.c +++ b/oogabooga/examples/text_rendering.c @@ -32,8 +32,9 @@ int entry(int argc, char **argv) { float now = (float)os_get_current_time_in_seconds(); float animated_x = sin(now*0.1)*(window.width*0.5); - draw_text(font, STR("I am text"), font_height, v2(animated_x-2, 2), v2(1, 1), COLOR_BLACK); - draw_text(font, STR("I am text"), font_height, v2(animated_x, 0), v2(1, 1), COLOR_WHITE); + // UTF-8 ! + draw_text(font, STR("Привет"), font_height, v2(animated_x-2, 2), v2(1, 1), COLOR_BLACK); + draw_text(font, STR("Привет"), font_height, v2(animated_x, 0), v2(1, 1), COLOR_WHITE); // New lines are handled when drawing text string hello_str = STR("Hello,\nTTTT New line\nAnother line"); diff --git a/oogabooga/random.c b/oogabooga/random.c index 1ee31f3..012deee 100644 --- a/oogabooga/random.c +++ b/oogabooga/random.c @@ -13,8 +13,13 @@ ogb_instance u64 seed_for_random; u64 seed_for_random = 1; #endif +// Like get_random but it doesn't advance the seed +u64 peek_random() { + return seed_for_random * MULTIPLIER + INCREMENT; +} + u64 get_random() { - seed_for_random = seed_for_random * MULTIPLIER + INCREMENT; + seed_for_random = peek_random(); return seed_for_random; } diff --git a/oogabooga/range.c b/oogabooga/range.c index f5983a5..7c5bafa 100644 --- a/oogabooga/range.c +++ b/oogabooga/range.c @@ -1,51 +1,61 @@ - -// randy: we might wanna remove the f by default, similar to the Vector2 ? -// I know that we'll have a Range2i at some point, so maybe it's better to be explicit for less confusion? -// I'll leave this decision up to u charlie just delete this whenever u see it - -// charlie: -// Is this range stuff really necessary? -// Why not just: -// typedef Vector2 Range1f; -// typedef Vector4 Range2f; -// Vector4 also already have alias for x1, y1, x2, y2 and we could add an alias for min & max vectors (see linmath.c) -// This feels like introducing unnecessary complexity and vocabulary when it's really just -// another way to say Vector2 and Vector4. - -typedef struct Range1f { - float min; - float max; -} Range1f; -// ... - -typedef struct Range2f { - Vector2 min; - Vector2 max; -} Range2f; - -inline Range2f range2f_make(Vector2 min, Vector2 max) { return (Range2f) { min, max }; } - -Range2f range2f_shift(Range2f r, Vector2 shift) { - r.min = v2_add(r.min, shift); - r.max = v2_add(r.max, shift); - return r; -} - -Range2f range2f_make_bottom_center(Vector2 size) { - Range2f range = {0}; - range.max = size; - range = range2f_shift(range, v2(size.x * -0.5, 0.0)); - return range; -} - -Vector2 range2f_size(Range2f range) { - Vector2 size = {0}; - size = v2_sub(range.min, range.max); - size.x = fabsf(size.x); - size.y = fabsf(size.y); - return size; -} - -bool range2f_contains(Range2f range, Vector2 v) { - return v.x >= range.min.x && v.x <= range.max.x && v.y >= range.min.y && v.y <= range.max.y; + +// randy: we might wanna remove the f by default, similar to the Vector2 ? +// I know that we'll have a Range2i at some point, so maybe it's better to be explicit for less confusion? +// I'll leave this decision up to u charlie just delete this whenever u see it + +// charlie: +// Is this range stuff really necessary? +// Why not just: +// typedef Vector2 Range1f; +// typedef Vector4 Range2f; +// Vector4 also already have alias for x1, y1, x2, y2 and we could add an alias for min & max vectors (see linmath.c) +// This feels like introducing unnecessary complexity and vocabulary when it's really just +// another way to say Vector2 and Vector4. + +typedef DEPRECATED(struct Range1f Range1f, "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); +typedef DEPRECATED(struct Range2f Range2f, "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); + +typedef struct Range1f { + float min; + float max; +} Range1f; +// ... + +typedef struct Range2f { + Vector2 min; + Vector2 max; +} Range2f; + +DEPRECATED(Range2f range2f_make(Vector2 min, Vector2 max), "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); +DEPRECATED(Range2f range2f_shift(Range2f r, Vector2 shift), "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); +DEPRECATED(Range2f range2f_make_bottom_center(Vector2 size), "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); +DEPRECATED(Vector2 range2f_size(Range2f range), "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); +DEPRECATED(bool range2f_contains(Range2f range, Vector2 v), "Range2f & Range1f will be removed. If you are using this, you should yoink it into your game code (from oogabooga/range.c)."); + + +inline Range2f range2f_make(Vector2 min, Vector2 max) { return (Range2f) { min, max }; } + +Range2f range2f_shift(Range2f r, Vector2 shift) { + r.min = v2_add(r.min, shift); + r.max = v2_add(r.max, shift); + return r; +} + +Range2f range2f_make_bottom_center(Vector2 size) { + Range2f range = {0}; + range.max = size; + range = range2f_shift(range, v2(size.x * -0.5, 0.0)); + return range; +} + +Vector2 range2f_size(Range2f range) { + Vector2 size = {0}; + size = v2_sub(range.min, range.max); + size.x = fabsf(size.x); + size.y = fabsf(size.y); + return size; +} + +bool range2f_contains(Range2f range, Vector2 v) { + return v.x >= range.min.x && v.x <= range.max.x && v.y >= range.min.y && v.y <= range.max.y; } \ No newline at end of file