'Trick or Treat candy collection simulator
'One key only input
'2021-12-Oct
'Author - Cobalt
'-----------------Lets do our setup---------------------
TYPE Trick_or_Treatr_Data
Bag_Size
AS _BYTE 'Size of player's colletion bag; Small, Med, Large, and back of Dad's pickup! Houses_hit
AS INTEGER 'How many houses has player approched? Treats
AS SINGLE 'How many OZs of treats has player recieved Tricks
AS INTEGER 'How many Tricks have been played on player Energy
AS SINGLE 'How much energy\drive does player have to walk up to houses? Distance
AS SINGLE 'How far has player traveled collecting candy?
N_Houses
AS _BYTE 'How many houses are lit on street N_Feet
AS INTEGER 'how long is the street(This is used to calculate remaining energy) Egain
AS INTEGER 'slight random chance of regaining energy Treats
AS _BYTE 'how much candy did player get from that street?
CONST North
= 0, East
= 2, West
= 3, South
= 1
Layer
(1) = _NEWIMAGE(80, 25, 0) 'our temp layerLayer
(2) = _NEWIMAGE(80, 25, 0) 'Menu Master layer'------------------------------------------------------
Directions(0) = "North"
Directions(1) = "South"
Directions(2) = "East"
Directions(3) = "West"
Player.Energy = 5280 'players starting energy
Player.Distance = 0
'------------------------------------------------------
Title_Screen
_TITLE "Trick Or Treat Sim Ver 1.0" Select_Collection_Bag_Size
Create_Street_Options 'pick new streets
Select_Street
Generate_Results Game.Street
Display_Stats
Display_Results
Display_Stats
Display_Stats
'Player quit so display final stats
PRINT "You visited"; Player.Houses_hit;
"houses and collected"; Player.Treats;
"oz of candy!" PRINT "You traveled"; Generate_Distance
(5);
"miles in your search for candy." PRINT "You were tricked"; Player.Tricks;
"times." PRINT "your bag was"; Bag_Load;
" full," PRINT "Amazing job! Just don't forget to brush your teeth!" PRINT "Not Bad, enough candy for a super sugar high!" PRINT "A good practice year, you'll get even more next year for sure!" PRINT "What happened!? Too many tricks and not enough treats?" PRINT "Pathetic... really pathetic! You call your self a Trick or Treatr'?" Exitflag%% = True
PRINT "After walking"; Generate_Distance
(Game.Street
);
" miles and visiting";
PRINT Game.N_Houses;
"houses;" PRINT Game.S_Houses;
"houses;" PRINT Game.E_Houses;
"houses;" PRINT Game.W_Houses;
"houses;" PRINT "You gained"; Game.Treats;
"oz candy." PRINT "You lost an extra"; Game.Eloss;
"points of energy from tricks." PRINT "You gained"; Game.Egain;
"energy from a punch bowl at one house!" Game.Egain = 0
PRINT "press any space bar to continue"
SUB Generate_Results
(Which%%
) Player.Distance = Player.Distance + Game.N_Feet
Player.Energy = Player.Energy - Game.N_Feet 'Remove the distance traveled from players energy
H%% = Game.W_Houses 'temp variable for number of houses
Player.Distance = Player.Distance + Game.S_Feet
Player.Energy = Player.Energy - Game.S_Feet
H%% = Game.S_Houses 'temp variable for number of houses
Player.Distance = Player.Distance + Game.E_Feet
Player.Energy = Player.Energy - Game.E_Feet
H%% = Game.E_Houses 'temp variable for number of houses
Player.Distance = Player.Distance + Game.W_Feet
Player.Energy = Player.Energy - Game.W_Feet
H%% = Game.W_Houses 'temp variable for number of houses
'how many houses treated and how many tricked
Player.Houses_hit = Player.Houses_hit + H%%
Game.Treats
= INT(H%%
* (RND + .05)) 'treats add weight Tricks = H%% - Game.Treats 'tricks take energy
Player.Treats
= Player.Treats
+ INT(RND * Game.Treats
) * 2 'add to weight up to 2x the treat houses Game.Eloss = Tricks * 2 'stored here for the results messages
Player.Energy = Player.Energy - Tricks * 2 'energy cost
Player.Tricks = Player.Tricks + Tricks
'slight chance that player will gain some energy
Game.Egain
= INT(RND * 263) + 263 Player.Energy = Player.Energy + Game.Egain
'---------------create menu for bag selection----------------
Make_Menu 2
'------------------------------------------------------------
'main loop
Selection_Timer = 0
'Move the selection while spacebar is down at 1\2 second intervals
Selection_Timer%% = Selection_Timer%% + 1
Key_Down%% = True
Key_Down%% = False
IF Key_Down%%
THEN 'while key is down increment selection every 30 cycles IF Selection_Timer%%
= 30 THEN Selection%%
= Selection%%
+ 1: Selection_Timer%%
= 0 IF Selection%%
= 6 THEN Selection%%
= 1 ELSEIF Selection%%
> 0 THEN 'only make choice if a selection was made Game.Street = Selection%% - 1
ExitFlag%% = True
Selection_Timer%% = 0 'if player just tapped space bar reset timer
LOCATE 12, 12: Describe_Street Game.N_Houses
, Generate_Distance
(North
), North
LOCATE 14, 12: Describe_Street Game.S_Houses
, Generate_Distance
(South
), South
LOCATE 16, 12: Describe_Street Game.E_Houses
, Generate_Distance
(East
), East
LOCATE 18, 12: Describe_Street Game.W_Houses
, Generate_Distance
(West
), West
Display_Stats
SUB Create_Street_Options
'generate the street info at this intersection
'Houses giving candy
Game.N_Houses
= INT(RND * 100) + 1 Game.S_Houses
= INT(RND * 100) + 1 Game.E_Houses
= INT(RND * 100) + 1 Game.W_Houses
= INT(RND * 100) + 1 'length of street(energy used to visit houses)
Game.N_Feet
= INT(RND * 1056) + 528 + Game.N_Houses
* 10 Game.S_Feet
= INT(RND * 1056) + 528 + Game.S_Houses
* 10 Game.E_Feet
= INT(RND * 1056) + 528 + Game.E_Houses
* 10 Game.W_Feet
= INT(RND * 1056) + 528 + Game.W_Houses
* 10
SUB Select_Collection_Bag_Size
'---------------create menu for bag selection----------------
Make_Menu 1
'------------------------------------------------------------
'main loop
Selection_Timer = 0
'Move the selection while spacebar is down at 1\2 second intervals
Selection_Timer%% = Selection_Timer%% + 1
Key_Down%% = True
Key_Down%% = False
IF Key_Down%%
THEN 'while key is down increment selection every 30 cycles IF Selection_Timer%%
= 30 THEN Selection%%
= Selection%%
+ 1: Selection_Timer%%
= 0 IF Selection%%
= 5 THEN Selection%%
= 1 ELSEIF Selection%%
> 0 THEN 'only make choice if a selection was made Player.Bag_Size = Selection%%
ExitFlag%% = True
Selection_Timer%% = 0 'if player just tapped space bar reset timer
LOCATE 18, 12:
PRINT "Dad's Pickup Truck(can hold ~32000oz)" Display_Stats
LOCATE 3, 1:
PRINT "Instructions: Hold the space bar down until your option is selected then release " CASE 1 'bag selection menu" Display_Option_Box 10, 10, 60, 9
LOCATE 18, 12:
PRINT "Dad's Pickup Truck(can hold ~32000oz)" CASE 2 'Street Selection Menu" Display_Option_Box 5, 10, 70, 11
LOCATE 12, 12: Describe_Street Game.N_Houses
, Generate_Distance
(North
), North
LOCATE 14, 12: Describe_Street Game.S_Houses
, Generate_Distance
(South
), South
LOCATE 16, 12: Describe_Street Game.E_Houses
, Generate_Distance
(East
), East
LOCATE 18, 12: Describe_Street Game.W_Houses
, Generate_Distance
(West
), West
SUB Display_Option_Box
(X1
, Y1
, Xsize
, Ysize
) 'Ä¿À³ÙÚ
'----------top and bottom line----------------
'---------------------------------------------
'---------Left and Right lines----------------
'---------------------------------------------
'----------Four corners-----------------------
'---------------------------------------------
LOCATE 1, 1:
PRINT "Bag Status:"; Bag_Load$;
" full";
TAB(25);
"Energy Left:"; Player.Energy;
TAB(50);
"Candy Collected:"; Player.Treats;
"oz"
SUB Describe_Street
(Count%
, Length!
, Direction%
) PRINT "To the "; Directions
(Direction%
);
" has"; Count%;
"lights on, and is"; Length!;
"miles long"
Result! = Game.N_Feet / 5280
Result! = Game.S_Feet / 5280
Result! = Game.E_Feet / 5280
Result! = Game.W_Feet / 5280
CASE 5 'player final distance Result! = Player.Distance / 5280
Result!
= INT(Result!
* 100) / 100 Generate_Distance = Result!
Result$ = "0%"
Result$
= STR$(INT(Player.Treats
/ 160 * 100)) + "%" Result$
= STR$(INT(Player.Treats
/ 240 * 100)) + "%" Result$
= STR$(INT(Player.Treats
/ 400 * 100)) + "%" Result$
= STR$(INT(Player.Treats
/ 32000 * 100)) + "%" Bag_Load = Result$
PRINT " TTTTTT RRRR IIIIII CCCC KK KK " PRINT " TT RR RR II CC CC KK KK " PRINT " TT RR RR II CC KKKK " PRINT " TT RR RR II CC CC KK KK " PRINT " TT RR RR IIIIII CCCC KK KK " PRINT " __(_(__ OOOO RR RR " PRINT " .'.' (•\'/¢) '.'. TTTTTT RRRR EEEEEE AA TTTTTT " PRINT " / :_/_: ê :_\_: \ TT RR RR EE AAAA TT " PRINT " | : \'=...='/ : | TT RR RR EEEE AA AA TT " PRINT " \ : :'.___.': : / TT RR RR EE AAAAAA TT " PRINT " '-:__:__:__:__:-' TT RR RR EEEEEE AA AA TT " LOCATE 23, 1:
PRINT "Powered by QB64 (press space bar to continue)"
'
' @@@
' @@@
' @@@ H A P P Y
' @@@
' @@@@@@@@@@@@@@@@@@@@@@ H A L L O W E E N
' @@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@ @@@@@@@@@@@@@@@@ @@@@@@@@
' @@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@
' @@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@
' @@@@@@@@@@ @@@@ @@@@ @@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@
' @@@@@@@@ @@ @@ @@ @@ @@ @@ @@ @ @@@@@@@@
' @@@@@@@ @@@@@@@
' @@@@@@ @@ @@ @@ @@ @@ @@ @ @@@@@@
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@@@@@@@
' @@@@@@@@@@@@@@@@@@@@@@
'
'------------------------------------------------
'Thank you for visiting https://asciiart.website/
'This ASCII pic can be found at
'https://asciiart.website/index.php?art=holiday/halloween