starting on game state management

This commit is contained in:
Rudis Muiznieks 2022-06-15 18:36:12 -05:00
parent d0d2955e58
commit a4d71b9e1a
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
3 changed files with 368 additions and 3 deletions

285
DEV_NOTES.txt Normal file
View File

@ -0,0 +1,285 @@
variables
z: money = 2000
y: loan_amount = 5000
v: savings_amount = 0
k: available_capacity = 100
b: current_day = 1
n: in_bronx = true
i: owned_guns = 0
j: damage = 0
t: carry_capacity = 100
m: owned_cocaine = 0
n: owned_heroine = 0
o: owned_acid = 0
p: owned_weed = 0
q: owned_speed = 0
r: owned_ludes = 0
each round:
cocaine_price = round(rand*12000+16000)
heroine_price = round(rand*7000+5000)
acid_price = round(rand*34+10)*100
weed_price = round(rand*42+33)*10
speed_price = round(rand*15+7)*10
ludes_price = round(rand*4+1)*10
random_event=round(rand*20)
random events:
1: Rival dealers are selling cheap ludes!!!
ludes_price = 2
2: Weed prices have bottomed out!!!
weed_price = 122
3: Pigs are selling cheap heroine from last week's raid!!!!
heroine_price = round(rand*1150+850)
4 or 5: Addicts are buying heroine at outrageous prices!!!
heroine_price = round(rand*25000+18000)
6 or 7: Pigs made a big coke bust! Prices are outrageous!!!!
cocaine_price = round(rand*60000+80000)
8: You were mugged in the subway!
money = round(money/3*2)
9 or 10 or 11: if sum(owned_*) >= 50
pigs = random_event == 9 ? 1
random_event == 10 ? 3
random_event == 11 ? 4
Officer Hardass and {pigs} of his deputies are after you!
->battle mode (pigs + 1)
12 or 13: if money >= 500 and available_capacity >= 5
x = round(rand*2)
weapon = x == 0 ? baretta
x == 1 ? saturday night special
x == 2 ? .44 magnum
Will you buy a {weapon} for 400 dollars?
Y: owned_guns++
money -= 400
carry_capacity -= 5
recalculate available_capacity
14: There's some weed here that smells like good stuff!! Will you smoke it?
Y: You hallucinate on the wildest trip of your life, stumble on to the subway tracks and get creamed by a train.
Just say no to drugs.
-> game over
15: if money >= 300:
Will you buy a new trenchcoat with more pockets for 200 bucks?
Y: carry_capacity += 10
recalculate available_capacity
money -= 200
16: if available_capacity >= 8
amount = round(rand*7+1)
x = round(rand*5+1)
drug = x == 0 ? ludes, owned_ludes += amount
x == 1 ? speed, owned_speed += amount
x == 2 ? weed, owned_weed += amount
x == 3 ? acid, owned_acid += amount
x == 4 ? heroine, owned_heroine += amount
x == 5 ? cocaine, owned_cocaine += amount
You found: {amount} units of: {drug} on a dead dude in the subway!!!
17: The market has been flooded with cheap homemade acid!!!!
acid_price = round(rand*550+250)
battle mode (pigs):
Being chased!!
- View guns
- View damage
- Your damage={damage}
(50 damage and you die!)
- Number of pigs
- There are: {pigs} pigs still chasing you!
- Run
- Running
x = round(rand)
if x == 0:
You lost them in an alley!!
if current_day == 31 goto LabelA
else -> turn menu
else:
You can't shake them!
-> take damage
- Fight
if owned_guns == 0:
You don't have any guns! You have to run!
-> fight menu
else:
x = round(rand)
if x == 0:
You missed!!!
else:
You killed one!!
pigs--
if pigs == 0:
You killed all of them!
found_money = round(rand*1250+750)
money += found_money
You found {found_money} dollars on Officer Hardass' carcass!!
if money >= 1200:
Will you pay 1000 dollars for a doctor to sew you up?
Y: money -= 1000
damage = 0
else:
-> take damage
- take damage:
They're firing at you!!
x = round(rand)
if x == 0:
They missed!!
-> main fight menu
else:
You've been hit!
damage += 3
if damage >= 50:
You've been killed!!
-> game over
else:
-> main fight menu
turn menu, after random event:
Drugwar!
- See prices
show *_prices
- Trenchcoat
show owned_* and available_capacity
- Buy
Day number: {current_day}
What to buy? -> drug
afford_max = floor(money / {drug}_price)
How much? -> quantity
You can afford: {afford_max}
You can hold: {available_capacity}
if g > 0 and g < afford_max:
money -= {drug}_price * quantity
owned_{drug} += quantity
recalculate available_capacity
-> turn menu
- Sell
What to sell? -> drug
How much? You have: {owned_{drug}} -> quantity
if quantity > 0 and quantity <= owned_{drug}:
owned_{drug} -= quantity
money += {drug}_price * quantity
recalculate available_capacity
-> turn menu
- Jet
Where to, dude?
- Bronx, Ghetto, Central Park, Manhatten, Coney Island, Brooklyn, Oops... Stay!
new_location = bronx || not_bronx
if new_location == oops:
-> turn menu
else if new_location == bronx and in_bronx:
You're already in the bronx!
-> jet menu
else:
Subway
current_day++
loan_amount = floor(loan_amount * 1.1)
savings_amount = floor(savings_amount * 1.06)
if current_day == 31 -> game over
else -> turn menu
- See loan shark
if not in_bronx:
The loan shark only deals in the Bronx.
-> turn menu
else:
Loan shark...
- Repay
Your debt is: {loan_amount}
Your wallet={money}
Repay how much? -> repay_amount
if repay_amount <= money and repay_amount <= loan_amount and repay_amount > 0:
money -= repay_amount
loan_amount -= repay_amount
-> turn menu
- Borrow
Your debt={loan_amount}
Your wallet={money}
Borrow how much more? -> borrow_amount
if borrow_amount > 5000:
You think he's crazy, man?!
-> shark menu
else if borrow_amount > 0:
money += borrow_amount
loan_amount += borrow_amount
-> turn menu
- Visit bank
if not in_bronx:
The bank is in the Bronx.
else:
Bank
- View account
Your account={savings_amount}
-> bank menu
- Deposit
How much to deposit? You have: {money} -> deposit_amount
if deposit_amount > 0 and deposit_amount <= money:
savings_amount += deposit_amount
money -= deposit_amount
-> bank menu
- Withdraw
How much to withdraw? Account={savings_amount} -> withdraw_amount
if withdraw_amount > 0 and withdraw_amount <= savings_amount:
savings_amount -= withdraw_amount
money += withdraw_amount
-> bank menu
- Goodbye -> turn menu
game over:
- Game over!
savings_amount = savings_amount + money - loan_amount
if savings_amount < 0:
savings_amount = 0
else:
score = sqrt(savings_amount / 31.5)
if score > 100:
score = 100
Your score (on a scale of 1 to 100)={score}
Play again?
Y: -> start new game
N: Thanks for playing!
Remember: Watch your back.
Have a nice day!
Top status bar: {days remaining} {money} {guns} {health}
Game states:
- Title screen
- new normal game
- new infinite game
- continue last game
- Random event info: basically a dialog over the turn or fight menu
- either dismiss or select yes/no
- Turn Menu
- Menu tab, Prices tab, Inventory tab, stats tab (nav left, right between)
- Menu tab nav up, down between
- buy, sell, jet (in bronx: loan shark, bank)
- Prices tab list current prices
- Inventory tab
- show available capacity
- list current inventory
- stats tab
- show loan amount
- show deposit amount
- Fight menu
- shows # of pigs remaining
- run, fight
- Buy/Sell select drug menu
- Jet menu
- Loan shark menu
- shows loan amount
- Bank menu
- show deposit amount
- amount input
- dialog input? up +1x down -1x right +10x left -10x
- buy/sell amount
- withdraw/deposit amounts
- subway turn transition/animation?
-> either main menu or fight menu with event dialog if triggered
HIGH LEVEL FUNCTIONS
- show image (on title screen)
- print status bar (not on title screen)
- print some kind of art banner?
- show a menu (possible options)
- get selection
- show a dialog
- with or without yes/no buttons
- get y/n response
- get a value (title, max, increment)
- get amount

View File

@ -8,4 +8,4 @@ clean:
rm -rf ./build ./slangin.hex rm -rf ./build ./slangin.hex
run: slangin.hex run: slangin.hex
sim_arduboy ./slangin.hex sim_arduboy -p 8 ./slangin.hex

View File

@ -8,7 +8,71 @@ License: WTFPL
Arduboy2 arduboy; Arduboy2 arduboy;
enum GameState {
STATE_TITLE = 0,
STATE_TURN_MENU,
STATE_JET_MENU,
STATE_PRICE_LIST,
STATE_INVENTORY,
STATE_BUY_MENU,
STATE_SELL_MENU,
STATE_FIGHT_MENU,
STATE_SHARK_MENU,
STATE_BANK_MENU,
STATE_INFO_DIALOG,
STATE_QUESTION_DIALOG,
STATE_AMOUNT_DIALOG,
STATE_SUBWAY
};
enum GameLocation {
LOC_BRONX = 0,
LOC_GHETTO,
LOC_CENTRAL_PARK,
LOC_MANHATTEN,
LOC_CONEY_ISLAND,
LOC_BROOKLYN
};
enum Drug {
DRUG_COCAINE = 0,
DRUG_HEROINE,
DRUG_ACID,
DRUG_WEED,
DRUG_SPEED,
DRUG_LUDES
};
enum StatusType {
STATUS_NONE = 0,
STATUS_TURN,
STATUS_FIGHT
};
enum DialogType {
DIALOG_INFO = 0,
DIALOG_YESNO,
DIALOG_AMOUNT
};
bool screenInitialized;
StatusType showStatus;
GameState gameState;
int sCurrentDay;
char sTitle[21] = {0};
char sMenuItems[8][9] = {0};
int pMoney;
int pLoanAmount;
int pSavingsAmount;
GameLocation pLocation;
int pGuns;
int pCapacity;
int pHealth;
int pInventory[6] = {0};
void setup() { void setup() {
gameState = STATE_TITLE;
screenInitialized = false;
arduboy.begin(); arduboy.begin();
arduboy.setFrameRate(15); arduboy.setFrameRate(15);
} }
@ -17,8 +81,24 @@ void loop() {
if (!(arduboy.nextFrame())) if (!(arduboy.nextFrame()))
return; return;
if (!screenInitialized) {
switch (gameState) {
case STATE_TITLE:
showStatus = STATUS_NONE;
strcpy(sTitle, " Slangin' v0.9");
break;
default:
showStatus = STATUS_NONE;
strcpy(sTitle, "[UNIMPLEMENTED]");
break;
}
drawScreen();
}
}
void drawScreen() {
arduboy.clear(); arduboy.clear();
arduboy.setCursor(4, 9); arduboy.setCursor(6, 12);
arduboy.print(F("Slangin'")); arduboy.print(sTitle);
arduboy.display(); arduboy.display();
} }