E. Final Program with Comments

clear
clc
fprintf(‘\n************************************************\n’)
fprintf(‘* *\n’)
fprintf(‘* SDP Text Adventure *\n’)
fprintf(‘* *\n’)
fprintf(‘************************************************\n’)
fprintf(‘\n’)
fprintf(‘\n’)
%fprintf(‘Snow batters your helmet lenses, lazers whizz above your head. \n’)
% You faintly hear anti-aircraft stations blasting away at the sky above your barracks.
%fprintf(‘TEST TEST ETTTSTETWGABDLKWB \n’)
% ez copy code fprintf(‘\n’)
fprintf(‘This is a high-stakes text adventure in which you will run into story-based decisions which will lead you down different paths. \n’)
pause(6)
fprintf(‘Your decisions will only require you to input a 1 or a 2 according to labelled options. \n’)
pause(6)
fprintf(‘One of each pair of options will lead to your demise. \n’)
pause(6)
fprintf(‘It is recommended to memorize your path of decisions if you would like to reach the end. \n’)
pause(6)
fprintf(‘Moreover, a survivalist and sometimes cowardly approach will give you the highest chance of reaching the end of the story. \n’)
pause(6)
fprintf(‘\n’)
pause(6)
fprintf(‘\n’)
pause(6)
fprintf(‘You wake up at the crack of dawn. \n’)
pause(6)
fprintf(‘The rest of the squad slowly gets out of their beds in the barracks. \n’)
pause(6)
fprintf(‘In a corner at a small beat-up table, Skips shuffles his cards. \n’)
pause(6)
fprintf(‘He invites you over, and sure, why not. \n’)
pause(6)

%%BlackJack
ten_card = 10;
ace = 11;
jack = 10;
queen = 10;
king = 10;
card_sum = 0;
x = 1;
chips = 100;
dealerHit = 0;
% Logan’s Code

%fprintf(‘****************WELCOME TO THE BLACKJACK TABLE********************\n’)

%fprintf(‘\n In an ominous country accent…\n’);

%pause(1);

%fprintf(‘\n …\n’);

%pause(1);

%fprintf(‘\n …\n’);

%pause(1);
fprintf(2, ‘Skips: Hi there Partner! Welcome to the table.\n’);
pause(1)
ask_name = ‘Please input your name:\n->’;
name = input(ask_name, ‘s’);
pause(1)
fprintf(2,’\nSkips: Thank you for joining me! %s.\n’, name)
pause(1)
ask_start = ‘Care to play?(Y/N)\n->’;
s = input(ask_start,’s’);
if strcmp(s, ‘yes’) || strcmp(s,’Yes’) || strcmp(s,’Y’) || strcmp(s, ‘y’)
pause(1)
fprintf(2,’\nSkips: Lovely! Lets start. \n’)
pause(1)
fprintf(‘Your starting chip count is %.0f\n’, chips)
elseif strcmp(s, ‘No’) || strcmp(s,’no’) || strcmp(s,’N’) || strcmp(s,’n’)
pause(1)
fprintf(2,’Skips: Thats ok, maybe next time.\n’)
x = 0;
pause(3)
clc
end
while false==strcmp(s, ‘yes’)&&false==strcmp(s,’Yes’)&&false==strcmp(s,’Y’)&&false==strcmp(s, ‘y’)&&false==strcmp(s, ‘No’)&&false== strcmp(s,’no’)&&false== strcmp(s,’N’)&&false== strcmp(s,’n’)
pause(1)
fprintf(‘Please enter a valid answer.\n’)
s = input(ask_start, ‘s’);
if strcmp(s, ‘yes’) || strcmp(s,’Yes’) || strcmp(s,’Y’) || strcmp(s, ‘y’)
pause(1)
fprintf(2,’\nSkips: Lovely! Lets start. \n’)
pause(1)
fprintf(‘Your starting chip count is %.0f\n’, chips)
elseif strcmp(s, ‘No’) || strcmp(s,’no’) || strcmp(s,’N’) || strcmp(s,’n’)
pause(1)
fprintf(2,’Skips: Thats ok, maybe next time.\n’)
pause(3)
clc
x = 0;
end
end

%End Logan’s Code
pause(.5);
while(x ~= 0)
bet = input(‘What would you like to bet?\n’);
fprintf(‘You have bet %.0f\n’, bet)
while(bet > chips)
bet = input(‘You went over your chip count please enter a new bet:\n’)
end

%establishes deck
i = 5;
hearts = [ace,2,3,4,5,6,7,8,9,ten_card,jack,queen,king];
spades = [ace,2,3,4,5,6,7,8,9,ten_card,jack,queen,king];
diamonds = [ace,2,3,4,5,6,7,8,9,ten_card,jack,queen,king];
clubs = [ace,2,3,4,5,6,7,8,9,ten_card,jack,queen,king];
deck = [hearts, diamonds, clubs, spades];
%establishes scene
my_scene = simpleGameEngine(‘retro_cards.png’,16,16,10,[0,170,0]);
card_sprite = (21:74);

%resets cards so another game can continuealy be played
card_back = 6;
card_sum = 0;
playerHand = 0;
dealerHand = 0;
empty_card = 0;
%shuffles deck
shuffle = randperm(52);
deck = deck(shuffle);
%assigns the player and dealers initial hands
playerCardOne = deck(1);
playerCardTwo = deck(3);
dealerCardOne = deck(2);
dealerCardTwo = deck(4);
playerHand = [playerCardOne, playerCardTwo]
playerSum = playerCardOne + playerCardTwo;
dealerHand = [dealerCardOne, dealerCardTwo];
dealerSum = dealerCardOne + dealerCardTwo;
card_sum = length(playerHand) + length(dealerHand) + 1;
empty_card(1:card_sum) = 2;
%shows the original hands with the six being a card back as the dealer’s
%second card can’t be shown
card_display = [card_sprite(shuffle(1)),card_sprite(shuffle(3)), 11, card_sprite(shuffle(2)), 6];
player_array = [card_sprite(shuffle(1)),card_sprite(shuffle(3))];
dealer_array = [card_sprite(shuffle(2)), 6];
k = 5;
drawScene(my_scene,empty_card,card_display)
fprintf(‘Your cards total %.0f\n’, playerSum)
fprintf(‘Skips has %.0f and an unknown\n’, dealerCardOne)
%a decision to allow the player to get another card
y = input(‘If you want a hit press 1. If you want to stay press 0. \n’);
playerCard = 0;
while(y ~= 0)
i = i + 2;
playerCard = deck(i);
card_sum = card_sum + 1;
k = k + 1;
empty_card(1:card_sum) = 2;
card_display = [player_array, card_sprite(shuffle(i)), 11, dealer_array];
player_array = [player_array, card_sprite(shuffle(i))];
drawScene(my_scene,empty_card,card_display)
playerHand = [playerHand, playerCard];
pause(1);
playerSum = playerSum + playerCard;
%Important Ace problem
%checks to see if the player has bust
if playerSum >= 22
for j = (1:length(playerHand))
if playerSum > 21 & playerHand(j) == 11
playerSum = playerSum – 10;
playerHand(j) = 1;
end
end
end
playerHand
pause(1);
if playerSum >= 22
fprintf(‘Your cards total %.0f\n’, playerSum)
pause(.5);
fprintf(‘Skips has %.0f and an unknown\n’, dealerCardOne)
%fprintf(‘The dealer has %.0f\n’, dealerSum)
y = 0;
else
fprintf(‘Your cards total %.0f\n’, playerSum)
pause(.5);
fprintf(‘Skips has %.0f and an unknown\n’, dealerCardOne)
%fprintf(‘The dealer has %.0f\n’, dealerSum)
y = input(‘If you want a hit press 1. If you want to stay press 0.\n’);
end
%this will show the dealers hidden card if you don’t bust out and it
%becomes the dealers turn.
card_display(k) = [card_sprite(shuffle(4))];
end
i = 4;
while(dealerSum < 17 && playerSum <= 21)
i = i + 2;
%dealer/skips turn to add more cards to his hand if he chooses so
fprintf(‘Skips Hits!\n’)
pause(1);
dealerCard = deck(i);
card_sum = card_sum + 1;
empty_card(1:card_sum) = 2;
card_display = [card_display, card_sprite(shuffle(i))];
drawScene(my_scene,empty_card,card_display)
dealerHand = [dealerHand, dealerCard];
dealerSum = dealerSum + dealerCard;
pause(1);
if dealerSum > 21
for k = (1:length(dealerHand))
if dealerSum > 21 && dealerHand(k) == 11
dealerSum = dealerSum – 10;
dealerHand(k) = 1;
end
end
end
dealerHand
pause(.5);
dealerHit = 1;
fprintf(‘Your cards total %.0f\n’, playerSum)
fprintf(‘Skips has %.0f\n’, dealerSum)
end
pause(1);
%will show the final card sums if the dealer doesn’t hit
if ~dealerHit
fprintf(‘Your cards total %.0f\n’, playerSum)
fprintf(‘Skips has %.0f\n’, dealerSum)
end
%these if, elseif and else statements are to deterimine who wins and who
%loses
if playerSum == dealerSum
fprintf(‘You tied Skips sorry…\n’)
%Logan’s Code
pause(1)
drawScene(my_scene,empty_card,card_display)
rT = randi(3);
if rT==1
fprintf(2,’\nSkips: One more try and we will decide the true winner.\n’)
elseif rT==2
fprintf(2,’\nSkips: Your score may match but your skill certainly does not.\n’)
elseif rT==3
fprintf(2,’\nSkips: The score that matters is the next one…\n’)
end
% End Logan’s Code
elseif playerSum > 21
fprintf(‘You have bust sorry…\n’)
% Logan’s Code
pause(1)
drawScene(my_scene,empty_card,card_display)
rL = randi(3);
if rL==1
fprintf(2,’\nSkips: Today just was not your day.\n’)
elseif rL==2
fprintf(2,’\nSkips: Another day, another dollar…am I right?\n’)
elseif rL==3
fprintf(2,’\nSkips: Yeah right pal, I win! \n’)
end
% End Logan’s Code
chips = chips – bet;
fprintf(‘You have a chip total of %.0f\n’, chips)
elseif dealerSum > 21
fprintf(‘Dealer busts! You Win!\n’)
drawScene(my_scene,empty_card,card_display)
%Logan’s Code
pause(1)
rW = randi(3);
if rW==1
fprintf(2,’\nSkips: I did not expect this from someone so new to the game.\n’)
elseif rW==2
fprintf(2, ‘\nSkips: You can take my money but not my pride!\n’)
elseif rW==3
fprintf(2,’\nSkips: One more time and I betcha I can win that back…\n’)
end
%End Logan’s Code
chips = chips + bet;
fprintf(‘You have a chip total of %.0f\n’, chips)
elseif playerSum == 21
fprintf(‘You have blackjack! You win!\n’)
drawScene(my_scene,empty_card,card_display)
% Logan’s Code
pause(1)
rW = randi(3);
if rW==1
fprintf(2,’\nSkips: I did not expect this from someone so new to the game.\n’)
elseif rW==2
fprintf(2, ‘\nSkips: You can take my money but not my pride!\n’)
elseif rW==3
fprintf(2,’\nSkips: One more time and I betcha I can win that back…\n’)
end
% End Logan’s Code
chips = chips + bet;
fprintf(‘You have a chip total of %.0f\n’, chips)
elseif playerSum > dealerSum
fprintf(‘Congratulations! You have won!\n’)
drawScene(my_scene,empty_card,card_display)
% Logan’s Code
pause(1)
rW = randi(3);
if rW==1
fprintf(2,’\nDealer: I did not expect this from someone so new to the game.\n’)
elseif rW==2
fprintf(2, ‘\nDealer: You can take my money but not my pride!\n’)
elseif rW==3
fprintf(2,’\nDealer: One more time and I betcha I can win that back…\n’)
end
% end Logan’s Code
chips = chips + bet;
fprintf(‘You have a chip total of %.0f\n’, chips)
elseif dealerSum > playerSum
fprintf(‘You lost to Skips…\n’)
drawScene(my_scene,empty_card,card_display)
%Logan’s Code
pause(1)
rL = randi(3);
if rL==1
fprintf(2,’\nSkips: Today just was not your day.\n’)
elseif rL==2
fprintf(2,’\nSkips: Another day, another dollar…am I right?\n’)
elseif rL==3
fprintf(2,’\nSkips: Yeah right pal, I win! \n’)
end
%End Logan’s Code
chips = chips – bet;
fprintf(‘You have a chip total of %.0f\n’, chips)
end
x = input(‘press 1 if you would like to play again or press 0 if you quit\n’);
if chips == 0 && x == 1
x = 0;
fprintf(‘Sorry you can not play anymore, you are out of chips\n’)
elseif x == 0
fprintf(2,’Skips: Play again soon!…\n’)
fprintf(‘Have a nice day!\n’)
end
end

%%Start of the Text based adventure

pause(6)
fprintf(‘As you walk away from the table, a deafening crack from above sends everyone sprawling into the floor. \n’)
pause(6)
fprintf(‘Stunned, you look up from the floor. Snow pours in from the ceiling. Alarms around the room blare. \n’)
pause(6)
fprintf(‘Echo Base is under attack. \n’)
pause(6)
fprintf(‘In the corner, Skips is pinned under a chunk of rubble from the ceiling, yelling for help as the rest of the squadron hastily makes their way into the hall towards the armory.\n’)
pause(6)
%fprintf(‘Do you decide to help Skips (1), or follow the rest of the squadron towards the armory? (2) \n’)
%input1 = input(
%These promts will help decide your choices throughout the game and lead
%you along the path you choose
prompt = ‘Do you decide to help Skips (1), or follow the rest of the squadron towards the armory? (2) \n ‘;
input1 = input(prompt);
if input1 == 1
fprintf(‘\n’)
fprintf(‘You are the only one who decided to help Skips, but you are unable to lift the rock. A second bomb is dropped on your underground barracks and the entire ceiling collapses into the room.\n’)
fprintf(‘You and Skips die.\n’)
return ;
elseif input1 == 2
fprintf(‘\n’)
fprintf(‘As you run down the hallway, a second bomb drops on the ground above your underground barracks, blowing the entire ceiling down and crushing anyone inside including Skips.\n’)
else
% if they input something other than 1 or 2, ask prompt again + repeat
fprintf(‘\n’)
fprintf(‘Please enter a 1 or 2 according to the path you would like to follow. \n’)
prompt = ‘Do you decide to help Skips (1), or follow the rest of the squadron towards the armory? (2) \n ‘;
input1 = input(prompt);
if input1 == 1
fprintf(‘\n’)
fprintf(‘You are the only one who decided to help Skips, but you are unable to lift the rock. A second bomb is dropped on your underground barracks and the entire ceiling collapses into the room.\n’)
fprintf(‘You and Skips die.\n’)
return ;
elseif input1 == 2
fprintf(‘\n’)
fprintf(‘As you run down the hallway, a second bomb drops on the ground above your underground barracks, blowing the entire ceiling down and crushing anyone inside including Skips.\n’)
end
end
pause(6)
fprintf(‘The squadron reaches the armory, a now beaten up dark room eerily illuminated by a red emergency alarm shining a single red beam on all walls as it spins. \n’)
pause(6)
fprintf(‘Hal and Stevens chestplates were cracked by debris, Blues blaster has a mangled stock. \n’)
pause(6)
fprintf(‘The squadron makes do with what it has, and runs toward the barracks doors. \n’)
pause(6)
fprintf(‘Blue takes point on the left of the door, and Hal takes the right. \n’)
pause(6)
fprintf(‘Stevens slowly opens the door and peers through, a quiet click is heard. \n’)
pause(6)
fprintf(‘A tripmine set on the door from the outside blows the doors off their hinges, half of a door flying through the air and smashing into your chest. \n’)
pause(6)
fprintf(‘Pieces of Stevens are strewn across the room. Hal and Blue sit stunned against the walls around the door. \n’)
pause(6)
fprintf(‘With the doors now open, concentrated light beaming off of the snow outside blinds the squadron inside. \n’)
pause(6)
fprintf(‘Snow pours in around Hal and Blues boots. \n’)
pause(6)
fprintf(‘Red and green lazers spray around the snowy fields, a lightshow of death.\n’)
pause(6)
fprintf(‘Giant Imperial AT-ATs slowly stomp towards the base, rebel planes circling and firing on them. \n’)
pause(6)
fprintf(‘The tops of hundreds of rebel helmets are visible to you from the doors.\n’)
pause(6)
fprintf(‘Blue commands what is left of the squadron to join the rest of Echo base in the trenches.\n’)
pause(6)
fprintf(‘Ion cannons firing away deafen you as you sprint to the nearest foxhole containing other rebels. \n’)
pause(6)
fprintf(‘Wasting no time to secure your own safety, you dive in, your planted foot slipping off the snow. \n’)
pause(6)
fprintf(‘A rebel named Jack picks you up off your side, handing you your blaster. \n’)
pause(6)
fprintf(‘Something hot sprays you in the face, a stray red lazer hit Jack in the neck. \n’)
pause(6)
fprintf(‘Dazed, you look out of the foxhole to see a jet black figure with two Imperial snowtroopers standing 20 meters away. \n’)
pause(6)
fprintf(‘Shellshocked, you stand and watch as the snowtroopers around him drop one-by-one to green rebel lazers. \n’)
pause(6)
fprintf(‘The dark figure in the middle bats away any lazers flying towards him using a lightsaber. \n’)
pause(6)
fprintf(‘You are suddenly aware that the others in the foxhole have left running. \n’)
pause(6)
fprintf(‘You snap yourself out of it. \n’)
pause(6)
prompt2 = ‘Do you engage the figure and fire on him (1), or follow the rebel troopers in running away? (2) \n ‘;
input2 = input(prompt2);
if input2 == 1
fprintf(‘\n’)
fprintf(‘You hold your finger on the trigger and blast away at the figure. \n’)
pause(3)
fprintf(‘The figure moves lightning fast, batting each and every lazer back at you, sending them through the same spot in your chest. \n’)
pause(6)
fprintf(‘You die.\n’)

return ;
elseif input2 == 2
fprintf(‘\n’)
fprintf(‘You turn and sprint. \n’)
else
% if they input something other than 1 or 2, ask prompt again + repeat
fprintf(‘\n’)
fprintf(‘Please enter a 1 or 2 according to the path you would like to follow. \n’)
prompt2 = ‘Do you engage the figure and fire on him (1), or follow the rebel troopers in running away? (2) \n ‘;
input2 = input(prompt2);
if input2 == 1
fprintf(‘\n’)
fprintf(‘You hold your finger on the trigger and blast away at the figure. \n’)
pause(1)
fprintf(‘The figure moves lightning fast, batting each and every lazer back at you, sending them through the same spot in your chest. \n’)
pause(1)
fprintf(‘You die.\n’)
return ;
elseif input2 == 2
fprintf(‘\n’)
fprintf(‘You turn and sprint.\n’)
end
end
% fprintf(‘\n’) copy paste reference
pause(6)
fprintf(‘A few strides in, you realize your feet are no longer striking the snowy ground. \n’)
pause(6)
fprintf(‘You are suddenly 10 feet tall, no, wait, you are floating four feet above the ground. \n’)
pause(6)
fprintf(‘Your floating body jerks around, you now face the dark figure. \n’)
pause(6)
fprintf(‘He stands eerily still, his hand is open pointing at you. \n’)
pause(6)
fprintf(‘For the first time, you see his features for a few seconds. \n’)
pause(6)
fprintf(‘A strong angular helmet, large bug-eyed lenses. A strange apparatus over the mouth. A chestplate with a colorful console.\n’)
pause(6)
fprintf(‘Snow batters his black cape. He does not speak. You feel quiet terror as you are held in the air. \n’)
pause(6)
fprintf(‘He makes a sudden move. You flinch. With a flick of his wrist to the side, you are jerked to the left, flying through the air. \n’)
pause(6)
fprintf(‘You fly over two trenches, you seem to be in the air for an eternity. \n’)
pause(6)
fprintf(‘The last thing you feel is a cold, hard impact with the ground and a popping feeling in your ribs. \n’)
pause(6)
fprintf(‘You wake up to the blasting of the anti-aircraft rebel ion cannons. \n’)
pause(6)
%fprintf(‘To your left, the upper half of a rebel lies on the ground. His bottom half is on your right. He was cut cleanly in half. \n’)
%pause(6)
%fprintf(‘Must have been the dark figures work, you realize. \n’)
%pause(6)
fprintf(‘The trenches at your position are no longer occupied by rebels. \n’)
pause(6)
fprintf(‘The giant AT-ATs have fallen, you see cables wrapped around their legs. \n’)
pause(6)
fprintf(‘Genius, you think. \n’)
pause(6)
fprintf(‘You get up from the snowy ground into a weak crouch. \n’)
pause(6)
fprintf(‘The Imperialists have moved past your position and are now attacking the second row of trenches. \n’)
pause(6)
fprintf(‘You are behind enemy lines. \n’)
pause(6)
% Make decision to fire on the Imperialist troopers from behind??
prompt3 = ‘Do you fire on the backs of the Imperialist troopers using a blaster on the ground (1), or flee? (2) \n ‘;
input3 = input(prompt3);
if input3 == 1
fprintf(‘\n’)
fprintf(‘You blow a hole in the back of two Imperialist troopers, but the rest of their squadron realizes they are being attacked from behind. \n’)
pause(6)
fprintf(‘An Imperialist sniper takes aim on you and fires. \n’)
pause(6)
fprintf(‘You are struck in the shoulder. \n’)
pause(6)
fprintf(‘You lay back against the snow. \n’)
pause(6)
fprintf(‘Your entire body hurts. \n’)
pause(6)
fprintf(‘You slowly no longer feel the cold or the pain. \n’)
pause(6)
fprintf(‘You fade into blackness. \n’)
pause(6)
fprintf(‘The End. \n’)
return;
return ;
elseif input3 == 2
fprintf(‘\n’)
fprintf(‘You painfully jog to a lone snowspeeder, its rider laying dead in the snow next to it. \n’)
else
% if they input something other than 1 or 2, ask prompt again + repeat
fprintf(‘ \n’)
fprintf(‘Please enter a 1 or 2 according to the path you would like to follow. \n’)
prompt3 = ‘Do you fire on the backs of the Imperialist troopers using a blaster on the ground (1), or flee? (2) \n ‘;
input3 = input(prompt3);
if input3 == 1
fprintf(‘\n’)
fprintf(‘You blow a hole in the back of two Imperialist troopers, but the rest of their squadron realizes they are being attacked from behind. \n’)
pause(6)
fprintf(‘An Imperialist sniper takes aim on you and fires. \n’)
pause(6)
fprintf(‘You are struck in the shoulder. \n’)
pause(6)
fprintf(‘You lay back against the snow. \n’)
pause(6)
fprintf(‘Your entire body hurts. \n’)
pause(6)
fprintf(‘You slowly no longer feel the cold or the pain. \n’)
pause(6)
fprintf(‘You fade into blackness. \n’)
pause(6)
fprintf(‘The End. \n’)
return;
elseif input3 == 2
fprintf(‘\n’)
fprintf(‘You painfully jog to a lone snowspeeder, its rider laying dead in the snow next to it. \n’)
end
end
pause(6)
fprintf(‘You grab the dead riders blaster pistol, and ride away from the battle on his snowspeeder. \n’)
pause(6)
fprintf(‘The loss of life witnessed instilled a stronger desire to live than fight and die. \n’)
pause(6)
fprintf(‘You ride along the edge of the snow-capped mountains until you come across a shallow cave. \n’)
pause(6)
fprintf(‘Seeking refuge, you skid to a stop. \n’)
pause(6)
fprintf(‘The back end of the snowspeeder scrapes the ground, snow sprays. \n’)
pause(6)
fprintf(‘You hop off and reach the entrance of the cave. \n’)
pause(6)
fprintf(‘A wampas severed arm lays on the floor. \n’)
pause(6)
fprintf(‘Each step you take disturbs the top layer of snow on the cave floor, revealing a bloody frozen layer underneath. \n’)
pause(6)
fprintf(‘You do not notice. \n’)
pause(6)
fprintf(‘You sit to rest against the cave wall. \n’)
pause(6)
fprintf(‘You feel increasingly tired. \n’)
pause(6)
fprintf(‘You sleep. \n’)
pause(4)
fprintf(‘You wake up to a wampa picking you up by the leg. \n’)
pause(6)
fprintf(‘You are thrown across the room. \n’)
pause(4)
fprintf(‘Your head hits rock. Blackness again. \n’)
pause(4)
fprintf(‘You wake up upside down. \n’)
pause(4)
fprintf(‘Your arms dangle under you, your feet are frozen into the ceiling. \n’)
pause(6)
fprintf(‘The wampa stands in the corner with its back to you. \n’)
pause(6)
fprintf(‘You reach for your pistol in a painful vertical situp. \n’)
pause(6)
fprintf(‘The rustling attracts the attention of the wampa. \n’)
pause(6)
fprintf(‘He turns to you, and begins to walk over. \n’)
pause(6)
fprintf(‘You take aim. \n’)
pause(6)
prompt4 = ‘Do you fire on the center of the wampas body (1), or aim for his head? (2) \n ‘;
input4 = input(prompt4);
if input4 == 1
fprintf(‘\n’)
fprintf(‘The shot punches a hole through the wampa, but he seems unphased. \n’)
pause(6)
fprintf(‘He runs towards you. \n’)
pause(6)
fprintf(‘You close your eyes. \n’)
pause(6)
fprintf(‘The wampa bites you in the middle of your body. \n’)
pause(6)
fprintf(‘You feel warmth pouring down your sides, down your chest towards your head. \n’)
pause(6)
fprintf(‘You slowly no longer feel the cold or the pain. \n’)
pause(6)
fprintf(‘You fade into blackness. \n’)
pause(6)
fprintf(‘The End. \n’)
return ;
elseif input4 == 2
fprintf(‘\n’)
fprintf(‘You fire at the wampas head. \n’)
pause(6)
fprintf(‘Its brains cover the walls. \n’)
pause(6)
fprintf(‘You sigh of exhaustion. \n’)
pause(6)
fprintf(‘Two shots at the ceiling break the ice around your feet. \n’)
pause(6)
fprintf(‘You land on your back. \n’)
else
% if they input something other than 1 or 2, ask prompt again + repeat
fprintf(‘ \n’)
pause(6)
fprintf(‘Please enter a 1 or 2 according to the path you would like to follow. \n’)
pause(6)
prompt4 = ‘Do you fire on the center of the wampas body (1), or aim for his head? (2) \n ‘;
input4 = input(prompt4);
if input4 == 1
fprintf(‘\n’)
fprintf(‘The shot punches a hole through the wampa, but he seems unphased. \n’)
pause(6)
fprintf(‘He runs towards you. \n’)
pause(6)
fprintf(‘You close your eyes. \n’)
pause(6)
fprintf(‘The wampa bites you in the middle of your body. \n’)
pause(6)
fprintf(‘You feel warmth pouring down your sides, down your chest towards your head. \n’)
pause(6)
fprintf(‘You slowly no longer feel the cold or the pain. \n’)
pause(6)
fprintf(‘You fade into blackness. \n’)
pause(6)
fprintf(‘The End. \n’)
return;
elseif input4 == 2
fprintf(‘\n’)
fprintf(‘You fire at the wampas head. \n’)
pause(6)
fprintf(‘Its brains cover the walls. \n’)
pause(6)
fprintf(‘You sigh of exhaustion. \n’)
pause(6)
fprintf(‘Two shots at the ceiling break the ice around your feet. \n’)
pause(6)
fprintf(‘You land on your back. \n’)
end
end
fprintf(‘You hobble towards the cave entrance. \n’)
pause(6)
fprintf(‘Smoke rises in the distance, Echo Base must have fallen to the Imperialist invasion. \n’)
pause(6)
fprintf(‘You lean against the snowspeeder and clutch your cold face. \n’)
pause(6)
fprintf(‘You have never felt more tired. \n’)
pause(6)
fprintf(‘You slowly no longer feel the cold or the pain. \n’)
pause(6)
fprintf(‘You fade into blackness. \n’)
pause(6)
fprintf(‘The End. \n’)