From 65f36ae8201ceb35e7bfde328f86ff710b1b748d Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 1 Feb 2025 05:36:42 -0500 Subject: [PATCH] Draw a card --- card.c | 5 +++++ card.h | 35 +++++++++++++++++++++++++++++++++++ main.c | 18 ++++++------------ 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 card.c create mode 100644 card.h diff --git a/card.c b/card.c new file mode 100644 index 0000000..a63f940 --- /dev/null +++ b/card.c @@ -0,0 +1,5 @@ +#include "card.h" + +void draw_card(Card *c) { + DrawRectangleV(c->position, card_size, RED); +} diff --git a/card.h b/card.h new file mode 100644 index 0000000..9f8a272 --- /dev/null +++ b/card.h @@ -0,0 +1,35 @@ +#ifndef _HF_CARD_ +#define _HF_CARD_ + +#include +#include + +typedef struct Card Card; +#define CARD_WIDTH 63 +#define CARD_HEIGHT 105 +static Vector2 card_size = (Vector2) { CARD_WIDTH, CARD_HEIGHT }; + +typedef enum CardType { + CHAFF, + RIBBON, + ANIMAL, + BRIGHT, +} CardType; + +typedef enum RibbonType { + RIBBON_NONE, + RIBBON_PLAIN, + RIBBON_BLUE, + RIBBON_POETRY, +} RibbonType; + +struct Card { + int index; + CardType type; + RibbonType ribbon_type; + Vector2 position; +}; + +void draw_card(Card *c); + +#endif diff --git a/main.c b/main.c index ff357ca..904b0e1 100644 --- a/main.c +++ b/main.c @@ -5,27 +5,21 @@ #include +#include "card.h" + char *text = "こんにちわ、 世界!"; int main(int argc, char** argv) { InitWindow(800, 450, "Hanafuda Hachi-Hachi"); SetTargetFPS(60); - int codepoints_count; - int *codepoints = LoadCodepoints(text, &codepoints_count); - Font font = LoadFontEx("font/DotGothic16/DotGothic16-Regular.ttf", 48, codepoints, codepoints_count); + Card *c = malloc(sizeof(Card)); + c->position = (Vector2) { 200, 200 }; while (!WindowShouldClose()) { BeginDrawing(); - ClearBackground(BLACK); - DrawTextEx( - font, - text, - (Vector2) { 200, 200 }, - 48, - 5., - RAYWHITE - ); + ClearBackground(RAYWHITE); + draw_card(c); EndDrawing(); }