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
|
48
slangin.ino
48
slangin.ino
|
@ -84,15 +84,20 @@ void loop() {
|
||||||
if (!(arduboy.nextFrame()))
|
if (!(arduboy.nextFrame()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
String menu[8];
|
||||||
|
int menuLength = 0;
|
||||||
|
bool menuSmall = false;
|
||||||
|
|
||||||
if (!screenInitialized) {
|
if (!screenInitialized) {
|
||||||
arduboy.clear();
|
arduboy.clear();
|
||||||
switch (sGameState) {
|
switch (sGameState) {
|
||||||
case STATE_TITLE:
|
case STATE_TITLE:
|
||||||
drawTitle(" Slangin' v0.9");
|
drawTitle(F("Slangin'"));
|
||||||
//char menu[3][19] = {{"New Game"}};
|
menu[0] = F("New Game");
|
||||||
//draw1ColMenu(1, menu);
|
menu[1] = F("Continue");
|
||||||
char menu[5][19] = {{"Coney Island"},{"Central Park"},{"Manhatten"},{"Ghetto"},{"Brooklyn"}};
|
menuLength = 2;
|
||||||
draw2ColMenu(true, 5, menu);
|
menuSmall = true;
|
||||||
|
draw1ColMenu(menuSmall, menuLength, menu);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
arduboy.display();
|
arduboy.display();
|
||||||
|
@ -102,46 +107,49 @@ void loop() {
|
||||||
/***********************/
|
/***********************/
|
||||||
/* screen draw heplers */
|
/* screen draw heplers */
|
||||||
/***********************/
|
/***********************/
|
||||||
void drawTitle(const char title[]) {
|
void drawTitle(const String title) {
|
||||||
arduboy.setCursor(6, 8);
|
arduboy.setCursor(6, 8);
|
||||||
arduboy.print(title);
|
arduboy.print(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw1ColMenu(const bool small,
|
void draw1ColMenu(const bool small, const int itemCount, const String items[]) {
|
||||||
const int itemCount,
|
|
||||||
const char items[][19]) {
|
|
||||||
int colWidth = 0;
|
int colWidth = 0;
|
||||||
for (int i = 0; i < itemCount; i++) {
|
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 charWidth = small ? 5 : 6;
|
||||||
const int charHeight = small ? 7 : 10;
|
const int charHeight = small ? 9 : 10;
|
||||||
int x = 64 - round(colWidth * (charWidth / 2.0));
|
int x = 66 - round(colWidth * (charWidth / 2.0));
|
||||||
int y = 18 - round(itemCount * (charHeight / 2.0));
|
int y = 18 - round(itemCount * (charHeight / 2.0));
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < itemCount; i++) {
|
||||||
arduboy.setCursor(x, i * charHeight + 22 + y);
|
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]);
|
arduboy.print(items[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw2ColMenu(const bool small,
|
void draw2ColMenu(const bool small, const int itemCount, const String items[]) {
|
||||||
const int itemCount,
|
|
||||||
const char items[][19]) {
|
|
||||||
const int col1Count = round(itemCount / 2.0);
|
const int col1Count = round(itemCount / 2.0);
|
||||||
const int col2Count = itemCount - col1Count;
|
const int col2Count = itemCount - col1Count;
|
||||||
int col1Width = 0;
|
int col1Width = 0;
|
||||||
int col2Width = 0;
|
int col2Width = 0;
|
||||||
for (int i = 0; i < col1Count; i++) {
|
for (int i = 0; i < col1Count; i++) {
|
||||||
const int newLen = strlen(items[i]);
|
const int newLen = items[i].length();
|
||||||
if (newLen > col1Width) col1Width = newLen;
|
if (newLen > col1Width) col1Width = newLen;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < col2Count; i++) {
|
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;
|
if (newLen > col2Width) col2Width = newLen;
|
||||||
}
|
}
|
||||||
const int charWidth = small ? 5 : 6;
|
const int charWidth = small ? 5 : 6;
|
||||||
const int charHeight = small ? 7 : 10;
|
const int charHeight = small ? 9 : 10;
|
||||||
int x = 64 - round((col1Width + col2Width + 2) * (charWidth / 2.0));
|
int x = 66 - round((col1Width + col2Width + 2) * (charWidth / 2.0));
|
||||||
int y = 18 - round(col1Count * (charHeight / 2.0));
|
int y = 18 - round(col1Count * (charHeight / 2.0));
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < itemCount; i++) {
|
||||||
const int cx = (i < col1Count)
|
const int cx = (i < col1Count)
|
||||||
|
|
Loading…
Reference in New Issue