-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpriteManager.ino
More file actions
executable file
·62 lines (47 loc) · 1.39 KB
/
SpriteManager.ino
File metadata and controls
executable file
·62 lines (47 loc) · 1.39 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
/*
* SpriteManager.ino - runs the sprite manager, the screen that allows a user
* to select a specific sprite to edit using the SpriteMaker.
*/
// UI Vars
#define spriteSpacingW 64
#define spriteTileBaseX 8
#define spriteTileBaseY 60
void drawSpriteManager(void){
tft.fillScreen(LIGHTGRAY);
tft.setCursor(40, 5);
tft.setTextColor(BLACK);
tft.setTextSize(3);
tft.println("Sprite Manager");
for (int i = 0; i < numSprites; i++){
int x = (i % 5) * spriteSpacingW + spriteTileBaseX - 1;
int y = (i / 5) * spriteSpacingW + spriteTileBaseY - 1;
int w = spriteTileW;
int h = spriteTileW;
// tft.fillRect(sbX + x * sbS + 1, sbY + y * sbS + 1, sbS - 1, sbS - 1, colors[sprites[currentSprite][x][y]]);
Button *b = makeButton(x, y, w, h, BLACK, WHITE, BLACK, sprintf("%d", i), clickSprite, i);
drawButton(b);
drawSprite(x, y, i);
}
}
void clickSprite(int i){
currentSprite = i;
pushToState(SPRITE_MAKER);
}
void runSpriteManager(void){
TSPoint p = getTouchPoint();
if (p.z == 500){
int a = 0;
for (int i = 0; i < buttons->size(); i++){
Button *b = buttons->at(i);
if (p.x >= b->x && p.x < b->x + b->w && p.y >= b->y && p.y < b->y + b->h){
b->callFunc(b->p);
a = 1;
break;
}
}
if (a == 0){
setKeyboardMaxLength(40);
pushToState(KEYBOARD_INPUT);
}
}
}