-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocations.cpp
More file actions
110 lines (96 loc) · 2.15 KB
/
Copy pathlocations.cpp
File metadata and controls
110 lines (96 loc) · 2.15 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "game.h"
#include "card.h"
#include "locations.h"
int horizontalSpace(int w) {
return w / 33;
}
int verticalSpace(int w) {
return w / 33;
}
int verticalPileSpace(int w) {
return w / 45;
}
int cardWidth(int w) {
return w / 11;
}
int cardHeight(int w) {
return 2 * w / 11;
}
SDL_Rect PileRect(int n, int c) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = (1 + n) * horizontalSpace(w) + n * cardWidth(w);
r.y = 2 * verticalSpace(w) + cardHeight(w) + c * verticalPileSpace(w);
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
SDL_Rect CellRect(int n) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = (1 + n)* horizontalSpace(w) + n * cardWidth(w);
r.y = verticalSpace(w);
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
SDL_Rect FlowerCellRect() {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = 4.67 * horizontalSpace(w) + 3.67 * cardWidth(w);
r.y = verticalSpace(w);
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
SDL_Rect FoundationRect(int n) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = (6 + n) * horizontalSpace(w) + (5 + n) * cardWidth(w);
r.y = verticalSpace(w);
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
SDL_Rect HeldRect(int c, int x, int y, int xoff, int yoff) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = x - xoff;
r.y = y - yoff + (c-1) * verticalPileSpace(w);
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
SDL_Rect ButtonRect(int n) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = 3.7 * horizontalSpace(w) + 3 * cardWidth(w);
r.y = verticalSpace(w) + cardHeight(w) * n * 0.365;
// w & h from dimensions of buttons in illustrator
r.w = cardWidth(w) * 0.5;
r.h = cardHeight(w) * 0.27;
return r;
}
SDL_Rect MovingRect(int x, int y) {
int w;
SDL_GetWindowSize(window, &w, NULL);
SDL_Rect r = SDL_Rect();
r.x = x;
r.y = y;
r.w = cardWidth(w);
r.h = cardHeight(w);
return r;
}
bool inRect(int px, int py, SDL_Rect r) {
return
(px >= r.x) &&
(py >= r.y) &&
(px <= r.x + r.w) &&
(py <= r.y + r.h);
}