-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcard.h
executable file
·93 lines (79 loc) · 2.43 KB
/
card.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Card.h */
#pragma once
#ifndef CARD_H
#define CARD_H
#include <stdlib.h>
#include "util.h"
enum CardOrdinal {
ACE = 1,
TWO = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6,
SEVEN = 7,
EIGHT = 8,
NINE = 9,
TEN = 10,
JACK = 11,
QUEEN = 12,
KING = 13,
};
enum CardSuit {
CLUB = 0,
DIAMOND = 1,
HEART = 2,
SPADE = 3,
};
struct CardId {
unsigned int pack:4;
unsigned int ordinal:4;
unsigned int suit:4;
};
struct Card /* tag */ {
/* static things */
unsigned magic;
struct CardId id;
int frame; // spritesheet frame, index into Info Vector2D struct
/* dynamically-changing things */
_Bool prone;
Vector2 pos;
struct Pile* owner;
_Bool dragging;
Vector2 dragStartPos;
Vector2 lerpSrc, lerpDst;
float lerpStep, lerpStepAmount;
EasingFunc lerpFunc;
float flipStep, flipWidth;
} /* variable definition */;
#define LOGCARD(c) { char z[64]; CardToString(c, z); fprintf(stdout, "%s\n", z); }
struct Card CardNew(unsigned pack, enum CardOrdinal ord, enum CardSuit suit);
_Bool CardValid(struct Card *const self);
unsigned CardToUnsigned(struct Card *const self);
struct CardId UnsignedToCardId(unsigned u);
void CardToString(struct Card *const self, char* z);
void CardToShortString(struct Card *const self, char* z);
void CardSetOwner(struct Card *const self, struct Pile *const pile);
struct Pile* CardOwner(struct Card *const self);
_Bool CardProne(struct Card *const self);
enum CardOrdinal CardOrdinal(struct Card *const self);
enum CardSuit CardSuit(struct Card *const self);
Vector2 CardBaizePos(struct Card *const self);
Vector2 CardScreenPos(struct Card *const self);
Rectangle CardBaizeRect(struct Card *const self);
Rectangle CardScreenRect(struct Card *const self);
void CardMovePositionBy(struct Card *const self, Vector2 delta);
void CardTransitionTo(struct Card *const self, Vector2 pos);
_Bool CardTransitioning(struct Card *const self);
void CardStartDrag(struct Card *const self);
void CardStopDrag(struct Card *const self);
void CardCancelDrag(struct Card *const self);
_Bool CardWasDragged(struct Card *const self);
_Bool CardDragging(struct Card *const self);
void CardFlipUp(struct Card *const self);
void CardFlipDown(struct Card *const self);
_Bool CardFlipping(struct Card *const self);
void CardUpdate(struct Card *const self);
void CardDraw(struct Card *const self);
void CardFree(struct Card *const self);
#endif