all menus drawing

This commit is contained in:
Rudis Muiznieks 2022-06-18 13:20:04 -05:00
parent df2f32f1b1
commit a7eafdd1e0
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
2 changed files with 82 additions and 12 deletions

View File

@ -18,9 +18,9 @@ enum GameState {
STATE_JET_MENU,
STATE_BUY_MENU,
STATE_SELL_MENU,
STATE_FIGHT_MENU,
STATE_SHARK_MENU,
STATE_BANK_MENU,
STATE_FIGHT_MENU,
STATE_INVENTORY,
STATE_INFO_DIALOG,
STATE_QUESTION_DIALOG,
@ -93,6 +93,7 @@ void setup() {
screenInitialized = false;
arduboy.begin();
arduboy.setFrameRate(15);
arduboy.initRandomSeed();
}
void loop() {
@ -139,10 +140,61 @@ void loop() {
case STATE_INVENTORY:
drawStatusBar();
drawTitle(F("Trenchcoat"));
drawTitle("Trenchcoat");
buildDrugMenu(pInventory);
drawMenu(menuSmall, menuCols, menuLength, menu);
break;
case STATE_BUY_MENU:
case STATE_SELL_MENU:
drawStatusBar();
if (sGameState == STATE_BUY_MENU) drawTitle("Buy Drugs");
else drawTitle("Sell Drugs");
buildDrugMenu(sDrugPrices);
drawMenu(menuSmall, menuCols, menuLength, menu);
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
break;
case STATE_JET_MENU: {
String title = F("Jet from ");
title = title + lookupLocation(pLocation);
drawStatusBar();
drawTitle(title);
for (int i = 0; i < 5; i++) {
int loc = i >= pLocation ? i + 1 : i;
menu[i] = lookupLocation(loc);
}
menuLength = 5;
menuSmall = true;
menuCols = true;
drawMenu(menuSmall, menuCols, menuLength, menu);
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
}
break;
case STATE_SHARK_MENU:
drawStatusBar();
drawTitle("Loan Shark");
menu[0] = F("Repay Loan");
menu[1] = F("Borrow Money");
menuLength = 2;
menuSmall = false;
menuCols = false;
drawMenu(menuSmall, menuCols, menuLength, menu);
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
break;
case STATE_BANK_MENU:
drawStatusBar();
drawTitle("Bank");
menu[0] = F("Deposit Money");
menu[1] = F("Withdraw Money");
menuLength = 2;
menuSmall = false;
menuCols = false;
drawMenu(menuSmall, menuCols, menuLength, menu);
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
break;
}
screenInitialized = true;
}
@ -204,6 +256,7 @@ void loop() {
sGameState == STATE_SELL_MENU ||
sGameState == STATE_SHARK_MENU ||
sGameState == STATE_BANK_MENU) {
screenInitialized = false;
sGameState = STATE_TURN_MENU;
}
}
@ -239,11 +292,19 @@ void drawStatusBar() {
} else {
const int chars = numberChars(pMoney);
const int x = 128 - (chars * 4);
if (sGameState == STATE_SHARK_MENU || sGameState == STATE_BANK_MENU) {
font3x5.setCursor(1, 0);
font3x5.print(sGameState == STATE_SHARK_MENU ? "Loan" : "Acct");
Sprites::drawOverwrite(19, 1, spriteDollar, 0);
font3x5.setCursor(25, 0);
font3x5.print(sGameState == STATE_SHARK_MENU ? pLoanAmount : pSavingsAmount);
} else {
font3x5.setCursor(1, 0);
font3x5.print("Day");
font3x5.setCursor(14, 0);
font3x5.print(sCurrentDay);
}
Sprites::drawOverwrite(x - 6, 1, spriteDollar, 0);
font3x5.setCursor(1, 0);
font3x5.print("Day");
font3x5.setCursor(14, 0);
font3x5.print(sCurrentDay);
font3x5.setCursor(x, 0);
font3x5.print(pMoney);
}

View File

@ -24,12 +24,12 @@ void incrementDay() {
// TODO: check for game over
// generate new drug prices
sDrugPrices[DRUG_COCAINE] = rand() % 12001 + 16000;
sDrugPrices[DRUG_HEROINE] = rand() % 7001 + 5000;
sDrugPrices[DRUG_ACID] = (rand() % 35 + 10) * 100;
sDrugPrices[DRUG_WEED] = (rand() % 43 + 33) * 10;
sDrugPrices[DRUG_SPEED] = (rand() % 16 + 7) * 10;
sDrugPrices[DRUG_LUDES] = (rand() % 5 + 1) * 10;
sDrugPrices[DRUG_COCAINE] = random(12001) + 16000;
sDrugPrices[DRUG_HEROINE] = random(7001) + 5000;
sDrugPrices[DRUG_ACID] = (random(35) + 10) * 100;
sDrugPrices[DRUG_WEED] = (random(43) + 33) * 10;
sDrugPrices[DRUG_SPEED] = (random(16) + 7) * 10;
sDrugPrices[DRUG_LUDES] = (random(5) + 1) * 10;
}
void handleMenuAction() {
@ -50,10 +50,19 @@ void handleMenuAction() {
sGameState = STATE_INVENTORY;
break;
case 1: // buy drugs
sGameState = STATE_BUY_MENU;
break;
case 2: // sell drugs
sGameState = STATE_SELL_MENU;
break;
case 3: // jet
sGameState = STATE_JET_MENU;
break;
case 4: // loan shark
sGameState = STATE_SHARK_MENU;
break;
case 5: // bank
sGameState = STATE_BANK_MENU;
break;
}
break;