Draw a card
This commit is contained in:
parent
3b6d384506
commit
65f36ae820
5
card.c
Normal file
5
card.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "card.h"
|
||||
|
||||
void draw_card(Card *c) {
|
||||
DrawRectangleV(c->position, card_size, RED);
|
||||
}
|
35
card.h
Normal file
35
card.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef _HF_CARD_
|
||||
#define _HF_CARD_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <raylib.h>
|
||||
|
||||
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
|
18
main.c
18
main.c
@ -5,27 +5,21 @@
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user