switched char[] to string
This commit is contained in:
parent
4f36c0c932
commit
f6881b3e40
|
@ -0,0 +1,16 @@
|
|||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
# Tab indentation (no size specified)
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
[*.{ino,c,h,cpp,hpp}]
|
||||
indent_size = 2
|
50
slangin.ino
50
slangin.ino
|
@ -84,15 +84,20 @@ void loop() {
|
|||
if (!(arduboy.nextFrame()))
|
||||
return;
|
||||
|
||||
String menu[8];
|
||||
int menuLength = 0;
|
||||
bool menuSmall = false;
|
||||
|
||||
if (!screenInitialized) {
|
||||
arduboy.clear();
|
||||
switch (sGameState) {
|
||||
case STATE_TITLE:
|
||||
drawTitle(" Slangin' v0.9");
|
||||
//char menu[3][19] = {{"New Game"}};
|
||||
//draw1ColMenu(1, menu);
|
||||
char menu[5][19] = {{"Coney Island"},{"Central Park"},{"Manhatten"},{"Ghetto"},{"Brooklyn"}};
|
||||
draw2ColMenu(true, 5, menu);
|
||||
drawTitle(F("Slangin'"));
|
||||
menu[0] = F("New Game");
|
||||
menu[1] = F("Continue");
|
||||
menuLength = 2;
|
||||
menuSmall = true;
|
||||
draw1ColMenu(menuSmall, menuLength, menu);
|
||||
break;
|
||||
}
|
||||
arduboy.display();
|
||||
|
@ -102,46 +107,49 @@ void loop() {
|
|||
/***********************/
|
||||
/* screen draw heplers */
|
||||
/***********************/
|
||||
void drawTitle(const char title[]) {
|
||||
void drawTitle(const String title) {
|
||||
arduboy.setCursor(6, 8);
|
||||
arduboy.print(title);
|
||||
}
|
||||
|
||||
void draw1ColMenu(const bool small,
|
||||
const int itemCount,
|
||||
const char items[][19]) {
|
||||
void draw1ColMenu(const bool small, const int itemCount, const String items[]) {
|
||||
int colWidth = 0;
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
if (strlen(items[i]) > colWidth) colWidth = strlen(items[i]);
|
||||
const int newLen = items[i].length();
|
||||
if (newLen > colWidth) colWidth = newLen;
|
||||
}
|
||||
const int charWidth = small ? 5 : 6;
|
||||
const int charHeight = small ? 7 : 10;
|
||||
int x = 64 - round(colWidth * (charWidth / 2.0));
|
||||
const int charHeight = small ? 9 : 10;
|
||||
int x = 66 - round(colWidth * (charWidth / 2.0));
|
||||
int y = 18 - round(itemCount * (charHeight / 2.0));
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
arduboy.setCursor(x, i * charHeight + 22 + y);
|
||||
arduboy.print(items[i]);
|
||||
const int cy = i * charHeight + 22 + y;
|
||||
if (small) {
|
||||
font4x6.setCursor(x, cy);
|
||||
font4x6.print(items[i]);
|
||||
} else {
|
||||
arduboy.setCursor(x, cy);
|
||||
arduboy.print(items[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void draw2ColMenu(const bool small,
|
||||
const int itemCount,
|
||||
const char items[][19]) {
|
||||
void draw2ColMenu(const bool small, const int itemCount, const String items[]) {
|
||||
const int col1Count = round(itemCount / 2.0);
|
||||
const int col2Count = itemCount - col1Count;
|
||||
int col1Width = 0;
|
||||
int col2Width = 0;
|
||||
for (int i = 0; i < col1Count; i++) {
|
||||
const int newLen = strlen(items[i]);
|
||||
const int newLen = items[i].length();
|
||||
if (newLen > col1Width) col1Width = newLen;
|
||||
}
|
||||
for (int i = 0; i < col2Count; i++) {
|
||||
const int newLen = strlen(items[col1Count + i]);
|
||||
const int newLen = items[i].length();
|
||||
if (newLen > col2Width) col2Width = newLen;
|
||||
}
|
||||
const int charWidth = small ? 5 : 6;
|
||||
const int charHeight = small ? 7 : 10;
|
||||
int x = 64 - round((col1Width + col2Width + 2) * (charWidth / 2.0));
|
||||
const int charHeight = small ? 9 : 10;
|
||||
int x = 66 - round((col1Width + col2Width + 2) * (charWidth / 2.0));
|
||||
int y = 18 - round(col1Count * (charHeight / 2.0));
|
||||
for (int i = 0; i < itemCount; i++) {
|
||||
const int cx = (i < col1Count)
|
||||
|
|
Loading…
Reference in New Issue