-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: prototype
Are you sure you want to change the base?
Conversation
Vector2 vector; | ||
int innerRadius; | ||
int outerRadius; | ||
char exist; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
Features: