Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(drawing): Create the display system #3

Draft
wants to merge 5 commits into
base: prototype
Choose a base branch
from

Conversation

dbcalitis
Copy link
Collaborator

@dbcalitis dbcalitis commented Dec 8, 2024

Features:

  • GFX
    • VFX
    • UI
      • Main Menu UI
        • Game Title
        • Buttons
      • In-Game UI
        • Visual Feedback for Input
        • Visual Metronome
        • Health Bar
        • Mania Meter
        • Fight UI

@dbcalitis dbcalitis added the enhancement New feature or request label Dec 8, 2024
@dbcalitis dbcalitis requested a review from andwu137 December 8, 2024 16:27
@dbcalitis dbcalitis removed the enhancement New feature or request label Dec 8, 2024
@andwu137 andwu137 changed the base branch from main to prototype December 8, 2024 16:35
@andwu137 andwu137 changed the title Prototype drawing feat(drawing): Create the display system Dec 8, 2024
Vector2 vector;
int innerRadius;
int outerRadius;
char exist;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use <stdbool.h> and true | false.

@@ -1,6 +1,32 @@
#include <raylib.h>
#include <raymath.h>

typedef struct Effect {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not to use typedef, makes it less confusing which type you have (struct vs union vs enum vs ptr).

@@ -1,6 +1,32 @@
#include <raylib.h>
#include <raymath.h>

typedef struct Effect {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Effect struct is not very generalized in comparison to its name. Any plans for an effect system?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, field names are a little meaningless atm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Effect struct is not very generalized in comparison to its name. Any plans for an effect system?

I'll probably make more structs and think about how I should format it . It really depends what I want to add.
I'm thinking the Effect's fields should be just: vector (center coordinates), struct EffectType, bool exist.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its a type, then you might wanna consider enum example from my repo.

Also, idk if center or top left is better. Cause for most elements other than circle, they normally go top left? But, the circle can just use the same vector struct as the center?

Copy link
Collaborator Author

@dbcalitis dbcalitis Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, idk if center or top left is better. Cause for most elements other than circle, they normally go top left? But, the circle can just use the same vector struct as the center?

Yeah, true... :v

If its a type, then you might wanna consider enum example from my repo.

I'll use a struct instead bc I have to keep track of other stuff as well like innerRadius and outerRadius for the one i have right now to animate it.

Copy link
Owner

@andwu137 andwu137 Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does something like this work for you, or is this not flexible enough? (tagged unions)

struct Effect {
    enum {
        EFFECT_RING,
        EFFECT_TRANSLATE,
    } type;

    double completion; /* range: [0, 1] */

    union {
        struct {
            int startInnerRadius;
            int startOuterRadius;
            int endInnerRadius;
            int endOuterRadius;
        } ring;

        struct {
            Vector2 startPosition;
            Vector2 endPosition;
        } translate;
    } data;
};

If you dont like duplication?

union EffectData {
    struct {
        int innerRadius;
        int outerRadius;
    } ring;

    struct {
        Vector2 position;
    } translate;
};


struct Effect {
    enum {
        EFFECT_RING,
        EFFECT_TRANSLATE,
    } type;

    double completion; /* range: [0, 1] */

    union EffectData startData;
    union EffectData endData;
};

char exist;
} Effect;

void spawnEffect(Effect *e, Vector2 v) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently using snakecase for my functions, we need a consensus on that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently using snakecase for my functions, we need a consensus on that.

Only for functions? Should we use another naming convention like camelCase for fields and other stuff? Or should we just make it all snakecase?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have
Types: Pascal
Variables: Camel
Functions: Snake
Files: Snake
Constants: Caps
Macros: Snake or Caps

@@ -10,15 +36,24 @@ int main(int argc, char *argv[]) {
SetTargetFPS(60);

while (!WindowShouldClose()) {
Vector2 v = {100, 100};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use field name initializers {.x = 100, .y = 100}.

// Update

// Draw
BeginDrawing();
{
ClearBackground(RAYWHITE);
ClearBackground(DARKGRAY);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't clear twice, as that does nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the RAYWHITE one is still there. I don't have it on my end.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe u forgot to push your second commit?

}
EndDrawing();
if (effect.exist == 0) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use if (!effect.exist).

@@ -10,15 +36,24 @@ int main(int argc, char *argv[]) {
SetTargetFPS(60);

while (!WindowShouldClose()) {
Vector2 v = {100, 100};
Effect effect;
spawnEffect(&effect, v);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are tabbed incorrectly; also in the finished product, we should try to keep variable declarations above the block they are used in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants