E. Final Program with Comments

 

“Memory Quest.m”

clc
clear
warning(‘off’,’all’)
set(0,’DefaultFigureWindowStyle’,’docked’)
%Set Player Class & Gender Placeholders.
global name
global PlayerClass
PlayerClass=’Holder’;
global Gender
Gender=0;
global PlayerMaxHP
global PlayerHP
PlayerHP=1;
global PlayerSTR
global PlayerSPD
global PlayerEnergy
global PlayerRG
global Gold
Gold=0;
%Draw initial POV Screen.
SplashDraw(1)
pause = ginput(1);
SplashDraw(2)
pause = ginput(1);
%###################ACT I #################################################
DrawUX(2,PlayerClass,0)
fprintf(‘You awaken in a small clearing- dense woodlands surround you. The moon above glows a deep red.<< Click for next line.>>\n’)
pause = ginput(1);
fprintf(‘Shaking your head, you gain your bearings. You remember-\n’)
pause = ginput(1);
name=input(‘Your name is…(input your name):’,’s’);
fprintf(“That’s right…your name is…%s.\n”,name)
pause = ginput(1);
fprintf(‘You recall that your trade in life was…\n’)
DrawUX(3,PlayerClass,0)
fprintf(‘(Click on a character sprite to select a class.)\n’)
fprintf(‘(Axemen have higher Attack Strength with lower Speed.\n’)
fprintf(‘(Hunters have lower Attack Strength with higher Speed.\n’)
fprintf(‘(Healers have lower Attack Strength and Speed, but gain Focus Energy faster.\n’)
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>0 && clickY<100)%(FemaleAxeman)
PlayerClass=’Axeman’;
Gender=2;
PlayerMaxHP=100;
PlayerEnergy=0;
PlayerSTR=10;
PlayerSPD=6;
PlayerRG=1;
elseif (clickX > 0 && clickX < 100) && (clickY>100 && clickY<200)%(MaleAxeman)
PlayerClass=’Axeman’;
Gender=1;
PlayerMaxHP=100;
PlayerEnergy=0;
PlayerSTR=10;
PlayerSPD=6;
PlayerRG=1;
elseif (clickX > 100 && clickX < 200) && (clickY>0 && clickY<100)%(FemaleHunter)
PlayerClass=’Hunter’;
Gender=2;
PlayerMaxHP=80;
PlayerEnergy=0;
PlayerSTR=6;
PlayerSPD=10;
PlayerRG=1;
elseif (clickX > 100 && clickX < 200) && (clickY>100 && clickY<200)%(MaleHunter)
PlayerClass=’Hunter’;
Gender=1;
PlayerMaxHP=80;
PlayerEnergy=0;
PlayerSTR=6;
PlayerSPD=10;
PlayerRG=1;
elseif (clickX > 200 && clickX < 300) && (clickY>0 && clickY<100)%(FemalePhysician)
PlayerClass=’Healer’;
Gender=2;
PlayerMaxHP=75;
PlayerEnergy=0;
PlayerSTR=5;
PlayerSPD=6;
PlayerRG=2;
elseif (clickX > 200 && clickX < 300) && (clickY>100 && clickY < 200)%(MalePhysician)
PlayerClass=’Healer’;
Gender=1;
PlayerMaxHP=75;
PlayerEnergy=0;
PlayerSTR=5;
PlayerSPD=6;
PlayerRG=2;
end
%Draw New scene
DrawUX(2,PlayerClass,Gender)
fprintf(‘You remember yourself being a fairly capable %s.\n’,PlayerClass)
pause = ginput(1);
fprintf(‘Nothing else surfaces about your old life.\n’)
pause = ginput(1);
fprintf(‘Unsettled, you clamber to your feet and look around.\n’)
pause = ginput(1);
fprintf(‘The foliage around you is thick and imposing, with two clear paths out.\n’)
pause = ginput(1);
fprintf(‘To the east, you hear the sound of running water. To the north, you see a faint, flickering light.\n’)
pause = ginput(1);
%Draw New scene
DrawUX(8,PlayerClass,0)
fprintf(‘What direction do you move in? (Select (1) to go east, (2) to go north):\n’);
%Choice 1 Selection
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C1=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C1=2;
else
C1=1;
end
choice1(C1)
pause = ginput(1);
%Choice 2 Selection
if C1==1
fprintf(‘The waters appear fairly calm, with pale mist rolling off the banks of the stream.\n’)
pause = ginput(1);
fprintf(‘What do you do? (Select (1) to try and swim across, (2) to try and find a bridge.):\n’);
DrawUX(7,PlayerClass,0)
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C2=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C2=2;
end
choice2a(C2,PlayerClass)
elseif C1==2
fprintf(‘A deer startles as you approach. It stares at you curiously, before starting to the east.\n’)
pause = ginput(1);
DrawUX(6,PlayerClass,0)
fprintf(‘The torch seems to beckon to you..do you decide to take it? (Select (1) to leave the torch and follow the deer. (2) to take the torch.):\n’);
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C2=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C2=2;
end
choice2b(C2,PlayerClass)
end

%%############################ACT II#############################%%
%Draw New scene
DrawUX(2,PlayerClass,0)
fprintf(‘Time passes…\n’)
pause = ginput(1);
fprintf(‘Exhausted, you sit on the ground- finally out of the woods.\n’)
pause = ginput(1);
fprintf(‘In the distance, you spot a village.\n’)
pause = ginput(1);
fprintf(‘Gathering your wits, you make your way into town.\n’)
pause = ginput(1);
%Draw New scene
DrawUX(9,PlayerClass,0)
fprintf(‘…\n’)
pause = ginput(1);
fprintf(‘Despite it being dusk, you notice that almost all of villages residents are awake.\n’)
pause = ginput(1);
fprintf(‘People talk in nearby pubs, and eye you warily through thier windows.\n’)
pause = ginput(1);
fprintf(‘You decide to go into a nearby pub to look for info.\n’)
%Draw New scene
DrawUX(12,PlayerClass,0)
fprintf(‘OLD BARKEEP:”Eh, fancy a bite to eat? Or are you here to deal with the rats?”\n’)
pause = ginput(1);
%Draw Choices
DrawUX(14,PlayerClass,0)
fprintf(‘1.)”Rats? Im just a traveler…” 2.)Order a meal. (-10Gold, +10MaxHP)\n’)
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C3=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C3=2;
else
C3=1;
end
%Draw New scene
DrawUX(12,PlayerClass,0)
%Choice selection
if C3==1
fprintf(‘OLD BARKEEP:”A traveler, huh?”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”You best not stick around…”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Things have been odd as of late.”\n’)
elseif C3==2
fprintf(‘OLD BARKEEP:”Here you go.”\n’)
pause = ginput(1);
fprintf(‘As you eat, the barkeep looks at you curiously.\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”…I havent seen you around.”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Or have I?”\n’)
pause = ginput(1);
PlayerMaxHP=PlayerMaxHP+10;
Gold=Gold-10;
end
fprintf(‘”What do you mean?”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Lately, folks around here have been losing thier memories.”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Some fall completely comatose.”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Lovers forget each other, mothers forget thier kids…families, friends…all gone.”\n’)
pause = ginput(1);
fprintf(‘The barkeep goes on, describing an old legend about an ancient and powerful Fae.\n’)
pause = ginput(1);
fprintf(‘During the cycle of the blood moon, this Fae, the Dream Eater, roams the night, feasting on the dreams and memories of man.\n’)
pause = ginput(1);
fprintf(‘The legend says that any one who manages to slay the Dream Eater will restore the dreams and memory lost to it.\n’)
pause = ginput(1);
fprintf(‘Your own state compels you to fulfill this prophecy.\n’)
pause = ginput(1);
fprintf(‘Desperate to know of the life you lost, you resolve to fight the Dream Eater, and ask the keep where you might find supplies.\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”…Not wise to fight a Fae, stranger. But if you insist…”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Theres a Smith down the road. If you have coin, theres plenty of equipment there.”\n’)
pause = ginput(1);
fprintf(‘OLD BARKEEP:”Aside from that, you could visit the apothecary. Hear they have all sorts of useful tonics.”\n’)
pause = ginput(1);
DrawUX(9,PlayerClass,0)
fprintf(‘Bidding the old keep farewell, you walk out into town. You decide where to acquire materials for your journey…\n’)
pause = ginput(1);
DrawUX(10,PlayerClass,0)
fprintf(‘1.)Buy a new weapon from the Smith.(+4 STR, -15 Gold.) 2.)Buy a tonic from the Apothecary.(-15Gold, +1 RG)\n’)
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C4=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C4=2;
else
C4=1;
end
DrawUX(9,PlayerClass,0)
if Gold > 10
if C4==1
fprintf(‘You decide to rearm yourself.\n’)
pause = ginput(1);
fprintf(‘You hand over the gold, and the Smith proudly hands you a new variant of your own weapon, polished to mirror sheen and etched with beautiful patterns.”\n’)
pause = ginput(1);
fprintf(‘Strapping the new equipment to your person, you head back out towards the wilderness, the Dream Eater in your sights.\n’)
PlayerSTR=PlayerSTR+4;
Gold=Gold-15;
elseif C4==2
fprintf(‘You decide to visit the Apothecary.\n’)
pause = ginput(1);
fprintf(‘You hand over the gold, and the physician hands you a vial of effervescent light blue liquid.”\n’)
pause = ginput(1);
fprintf(‘The tonic burns slightly as you drink- you feel yourself straighten, your heart filling with something like courage.\n’)
pause = ginput(1);
fprintf(‘Feeling reinvigorated, you trek out towards the wilderness, in search of the Dream Eater.\n’)
PlayerRG=PlayerRG+1;
Gold=Gold-15;
end
else
fprintf(‘Not enough gold!\n’)
pause = ginput(1);
fprintf(‘Pockets empty, you trek out towards the wilderness, in search of the Dream Eater.\n’)
end

%%###############################ACT III###################################
DrawUX(2,PlayerClass,0)
fprintf(‘Time passes…\n’)
pause = ginput(1);
fprintf(‘Youve been a ascending a forested hill nearby for some time now.\n’)
pause = ginput(1);
fprintf(‘The air grows colder around you. Frost glazes the dormant foliage around you.\n’)
pause = ginput(1);
fprintf(‘As you ascend, you feel your arms grow heavy, your mind drifts and fogs.\n’)
pause = ginput(1);
DrawUX(15,PlayerClass,0)
fprintf(‘You finally reach the summit. Before you is a shifting, amorphous haze. Ominous whispers meld with the howling wind.\n’)
pause = ginput(1);
fprintf(‘Dream Eater: “…”\n’)
pause = ginput(1);
fprintf(‘Dream Eater: “…turn…back…”\n’)
pause = ginput(1);
fprintf(‘Dream Eater: “…you…seek…”\n’)
pause = ginput(1);
fprintf(‘Dream Eater: “…no…more…”\n’)
pause = ginput(1);
fprintf(‘Steeling your nerves, you brace for combat.\n’)
%Initiate BossFight
BossFight

%ENDING
close all
clear all
return

======================================================================

“Combat.m”

function Combat(EnemClass)
global name
global PlayerClass
global PlayerHP
global PlayerMaxHP
global PlayerEnergy
global Gender
global PlayerSTR
global PlayerSPD
global PlayerRG
global Gold
PlayerHP=PlayerMaxHP;
%WATER DRAKON COMBAT
if EnemClass==1
EnemHP=55;
EnemEnergy=0;
EnemSTR=5;
EnemSPD=8;
EnemRG=1;
DrawUX(1,PlayerClass,Gender)
fprintf(‘########################COMBAT START!#####################\n’)
fprintf(‘The Water Drakon writhes and hisses before you!\n’)
fprintf(‘(TUTORIAL: Clicking an option above will select a move.<< Hit ENTER for next, type 1 to skip tutorial.>>\n’)
skip=input(”);
if skip==1
fprintf(‘Tutorial Skipped!\n’)
else
fprintf(‘(TUTORIAL: Attacks [“ATK”] are evaded by Deflecting [“DEF”].<< click for next.>>\n’)
pause = ginput(1);
fprintf(‘(TUTORIAL: Attacks are charged by Focusing [“FCS”].<< click for next.>>\n’)
pause = ginput(1);
fprintf(‘(TUTORIAL: Attacks land if the Combatant chose to Focus that move.<< click for next.>>\n’)
pause = ginput(1);
fprintf(“(TUTORIAL: If Deflect is chosen, the Combatants Speed Stats are compared, with the highest number prevailing.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: Attacks are more powerful the higher a Combatant’s Strength Stat.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: If both Combatants Attack, The higher value of Strength + Energy prevails.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: Focusing charges energy equal to the combatant’s RG stat. With a maximum energy of 5. << click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: The greater the energy, the more powerful the Attack. << click for next.>>\n”)
pause = ginput(1);
fprintf(“( END TUTORIAL. << click for next.>>\n”)
pause = ginput(1);
end
while EnemHP > 0 && PlayerHP > 0

%SELECT ENEMY MOVE
if EnemEnergy < 1
EnemMove=randi(2:3);
else
EnemMove=randi(3);
end

%SELECT PLAYER MOVE
fprintf(‘###############NEW TURN!######################\n’)
fprintf(‘Select a move.\n’)
[clickX, clickY] = ginput(1);

if (clickX > 0 && clickX < 100) && (clickY>30 && clickY<70)%(Attack)
fprintf(‘Selected: Attack!\n’)
PlayerMove=1;
elseif (clickX > 100 && clickX < 200) && (clickY>30 && clickY<70)%(Deflect)
fprintf(‘Selected: Deflect!\n’)
PlayerMove=2;
elseif (clickX > 200 && clickX < 300) && (clickY>30 && clickY<70)%(Focus)
fprintf(‘Selected: Focus!\n’)
PlayerMove=3;
end
%FIGHT CONDITIONS
%Player and Enemy Strike.
if EnemMove==1 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“Both combatants strike!\n”)
EnemAttackPWR= EnemSTR+EnemEnergy;
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
if EnemAttackPWR>PlayerAttackPWR
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Enemy Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR<PlayerAttackPWR
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Player Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR==PlayerAttackPWR
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Neither strike lands…\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player and Enemy Def
elseif EnemMove==2 && PlayerMove==2
fprintf(“Both combatants deflect!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player and Enemy Focus
elseif EnemMove==3 && PlayerMove==3
PlayerEnergy=PlayerEnergy+PlayerRG;
EnemEnergy=EnemEnergy+EnemRG;
fprintf(‘Player Regeneration: %i , Enemy Regeneration: %i\n’,PlayerRG,EnemRG)
fprintf(“Both combatants focus their energy!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Attack and Enemy Focus
elseif EnemMove==3 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
fprintf(‘Strike lands!\n’)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(“The enemy begins to focus…\n”)
EnemEnergy=EnemRG+EnemEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player Focus and Enemy Attack
elseif EnemMove==1 & PlayerMove==3
fprintf(“The Drakon strikes!\n”)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
fprintf(‘Strike lands!\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(“%s begins to focus…\n”,name)
PlayerEnergy=PlayerRG+PlayerEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
%Player Attack and Enemy Defend
elseif PlayerMove==1 & EnemMove==2
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
fprintf(“The Drakon recoils and dodges!\n”)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
if PlayerSPD>EnemSPD
fprintf(‘%s manages to get a hit!\n’,name)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
PlayerEnergy=0;
fprintf(‘The Drakon is too fast,and snakes away from harm.\n’)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end
%Player Defend and Enemy Attack
elseif EnemMove==1 & PlayerMove==2
fprintf(“The Drakon strikes!\n”)
fprintf(“%s attempts to deflect!\n”,name)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
if PlayerSPD>EnemSPD
fprintf(‘The Drakon manages to get a hit!\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
EnemEnergy=0;
fprintf(‘%s is fast enough to deflect the attack unharmed!\n’,name)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end

%Player Focus and Enemy Def
elseif EnemMove==2 & PlayerMove==3
fprintf(“%s focuses thier energy…\n”,name)
fprintf(“The Drakon moves to deflect!\n”)
PlayerEnergy= PlayerEnergy+PlayerRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Def and Enemy Focus
elseif EnemMove==3 & PlayerMove==2
fprintf(“%s moves to deflect!\n”,name)
fprintf(“The Drakon focuses it’s energy..\n”)
EnemEnergy= EnemEnergy+EnemRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
end
if PlayerHP<=0
fprintf(‘You were defeated…\n’)
SplashDraw(3)
pause = ginput(1);
SplashDraw(4)
close all
clear all
return
else
fprintf(“You’ve slain the Drakon!\n”)
PlayerHP=PlayerMaxHP;
PlayerEnergy=0;
fprintf(“+3 STR!\n”)
PlayerSTR= PlayerSTR+3;
fprintf(“+2 SPD!\n”)
PlayerSPD= PlayerSPD+2;
fprintf(“+25 Gold!\n”)
Gold=Gold+25;
end

%#########################################################################

%%KNIGHTMARE COMBAT
elseif EnemClass==2
EnemHP=55;
EnemEnergy=0;
EnemSTR=8;
EnemSPD=5;
EnemRG=1;
DrawUX(11,PlayerClass,Gender)
fprintf(‘########################COMBAT START!#####################\n’)
fprintf(‘The Knightmare tenses, preparing for battle!\n’)
fprintf(‘(TUTORIAL: Clicking an option above will select a move.<< Hit ENTER for next, type 1 to skip tutorial.>>\n’)
skip=input(”);
if skip==1
fprintf(‘Tutorial Skipped!\n’)
else
fprintf(‘(TUTORIAL: Attacks [“ATK”] are evaded by Deflecting [“DEF”].<< click for next.>>\n’)
pause = ginput(1);
fprintf(‘(TUTORIAL: Attacks are charged by Focusing [“FCS”].<< click for next.>>\n’)
pause = ginput(1);
fprintf(‘(TUTORIAL: Attacks land if the Combatant chose to Focus that move.<< click for next.>>\n’)
pause = ginput(1);
fprintf(“(TUTORIAL: If Deflect is chosen, the Combatants Speed Stats are compared, with the highest number prevailing.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: Attacks are more powerful the higher a Combatant’s Strength Stat.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: If both Combatants Attack, The higher value of Strength + Energy prevails.<< click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: Focusing charges energy equal to the combatant’s RG stat. With a maximum energy of 5. << click for next.>>\n”)
pause = ginput(1);
fprintf(“(TUTORIAL: The greater the energy, the more powerful the Attack. << click for next.>>\n”)
pause = ginput(1);
fprintf(“( END TUTORIAL. << click for next.>>\n”)
pause = ginput(1);
end
while EnemHP > 0 && PlayerHP > 0
%SELECT ENEMY MOVE
if EnemEnergy < 1
EnemMove=randi(2:3);
else
EnemMove=randi(3);
end

%SELECT PLAYER MOVE
fprintf(‘###############NEW TURN!######################\n’)
fprintf(‘Select a move.\n’)
[clickX, clickY] = ginput(1);

if (clickX > 0 && clickX < 100) && (clickY>30 && clickY<70)%(Attack)
fprintf(‘Selected: Attack!\n’)
PlayerMove=1;
elseif (clickX > 100 && clickX < 200) && (clickY>30 && clickY<70)%(Deflect)
fprintf(‘Selected: Deflect!\n’)
PlayerMove=2;
elseif (clickX > 200 && clickX < 300) && (clickY>30 && clickY<70)%(Focus)
fprintf(‘Selected: Focus!\n’)
PlayerMove=3;
end
%FIGHT CONDITIONS
%Player and Enemy Strike.
if EnemMove==1 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“Both combatants strike!\n”)
EnemAttackPWR= EnemSTR+EnemEnergy;
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
if EnemAttackPWR>PlayerAttackPWR
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Enemy Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR<PlayerAttackPWR
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Player Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR==PlayerAttackPWR
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Neither strike lands…\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player and Enemy Def
elseif EnemMove==2 && PlayerMove==2
fprintf(“Both combatants deflect!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player and Enemy Focus
elseif EnemMove==3 && PlayerMove==3
PlayerEnergy=PlayerEnergy+PlayerRG;
EnemEnergy=EnemEnergy+EnemRG;
fprintf(‘Player Regeneration: %i , Enemy Regeneration: %i\n’,PlayerRG,EnemRG)
fprintf(“Both combatants focus their energy!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Attack and Enemy Focus
elseif EnemMove==3 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
fprintf(‘Strike lands!\n’)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(“The enemy begins to focus…\n”)
EnemEnergy=EnemRG+EnemEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player Focus and Enemy Attack
elseif EnemMove==1 & PlayerMove==3
fprintf(“The Knightmare strikes!\n”)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
fprintf(‘Strike lands!\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(“%s begins to focus…\n”,name)
PlayerEnergy=PlayerRG+PlayerEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
%Player Attack and Enemy Defend
elseif PlayerMove==1 & EnemMove==2
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
fprintf(“The Knightmare recoils and dodges!\n”)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
if PlayerSPD>EnemSPD
fprintf(‘%s manages to get a hit!\n’,name)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
PlayerEnergy=0;
fprintf(‘The Knightmare is too fast,and shifts away from harm.\n’)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end
%Player Defend and Enemy Attack
elseif EnemMove==1 & PlayerMove==2
fprintf(“The Knightmare strikes!\n”)
fprintf(“%s attempts to deflect!\n”,name)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
if PlayerSPD>EnemSPD
fprintf(‘The Knightmare manages to get a hit!\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
EnemEnergy=0;
fprintf(‘%s is fast enough to deflect the attack unharmed!\n’,name)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end

%Player Focus and Enemy Def
elseif EnemMove==2 & PlayerMove==3
fprintf(“%s focuses thier energy…\n”,name)
fprintf(“The Knightmare moves to deflect!\n”)
PlayerEnergy= PlayerEnergy+PlayerRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Def and Enemy Focus
elseif EnemMove==3 & PlayerMove==2
fprintf(“%s moves to deflect!\n”,name)
fprintf(“The Knightmare focuses it’s energy..\n”)
EnemEnergy= EnemEnergy+EnemRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
end
if PlayerHP <= 0
fprintf(‘You were defeated…\n’)
SplashDraw(3)
pause = ginput(1);
SplashDraw(4)
close all
clear all
return
else
fprintf(“You’ve slain the Knightmare!\n”)
PlayerHP=PlayerMaxHP;
PlayerEnergy=0;
fprintf(“+4 STR!\n”)
PlayerSTR=PlayerSTR+4;
fprintf(“+1 SPD!\n”)
PlayerSPD=PlayerSPD+1;
fprintf(“+25 Gold\n”)
Gold=Gold+25;
end

end

end

======================================================================

“choice1.m”

function choice1(A)
%First option
if A==1
DrawUX(4,0,0)
fprintf(‘You make your way towards the east, following the sound of rushing water.\n’)
pause = ginput(1);
fprintf(‘Soon, you find yourself in front of a river.\n’)
pause = ginput(1);
C1=1;
%Second Option
elseif A==2
DrawUX(5,0,0)
fprintf(‘You make your way towards the north, following the flickering light.\n’)
pause = ginput(1);
fprintf(‘You find yourself before a flickering torch.\n’)
pause = ginput(1);
C1count=2;
else

end
end

======================================================================

“choice2a.m”

function choice2a(X,A)
global PlayerSTR
global PlayerClass
global Gender
%First option
if X==1
fprintf(‘Mustering all your courage, you fjord the river.\n’)
pause = ginput(1);
fprintf(“Incredibly,it’s very shallow, and you make it to the otherside fairly unscathed!\n”)
pause = ginput(1);
fprintf(‘+2 STR!\n’)
%Stat change
PlayerSTR=PlayerSTR+2;
pause = ginput(1);
%Second option
elseif X==2
fprintf(‘Making your way through the darkness, you attempt to find a bridge.\n’)
pause = ginput(1);
fprintf(“You notice a shadow looming in the water as you walk.\n”)
pause = ginput(1);
fprintf(“The figure begins to grow ominously close. You dash away from the bank, and a great serpentine monster erupts from the water- a Drakon!\n”)
pause = ginput(1);
fprintf(“You hastily draw your weapon and prepare to fight…\n”)
pause = ginput(1);
%Initiate combat
Combat(1)
else

end
end

======================================================================

“choice2b.m”

function choice2b(X,PlayerClass)
global PlayerClass
global Gender
if X==1
%First option
fprintf(‘You decide to leave the torch, following the deer by moonlight.\n’)
pause = ginput(1);
choice1(1)
fprintf(‘The water appears fairly calm, with pale mist rolling off the banks of the stream.\n’)
pause = ginput(1);
fprintf(‘What do you do? (Select (1) to try and swim across, (2) to try and find a bridge.):\n’);
DrawUX(7,PlayerClass,0)
[clickX, clickY] = ginput(1);
if (clickX > 0 && clickX < 100) && (clickY>130 && clickY<160)
C2=1;
elseif (clickX > 200 && clickX < 300) && (clickY>130 && clickY<160)
C2=2;
end
choice2a(C2,PlayerClass)
%######################################
elseif X==2
%second Choice
fprintf(‘You reach out to try and take the torch.\n’)
pause = ginput(1);
fprintf(“Suddenly, a great burst of flame leaps into the air.\n”)
pause = ginput(1);
fprintf(“The flames coalece into a skeletal centaur, its bones burned black as charcoal.\n”)
pause = ginput(1);
fprintf(“The apparition levels its great sword at you. You hastily draw your weapon and take a stance, ready to defend yourself.\n”)
pause = ginput(1);
%initiate combat
Combat(2)
else

end
end

======================================================================

“DrawUX.m”

function DrawUX(Situation,PlayerClass,Gender)
global PlayerClass
global Gender
%##VARIABLE SETUP###############################################%

%BlankSpace
blank = 3*32+0;

%Player
if strcmp(‘Axeman’,PlayerClass)& Gender==2 %Female Axeman
player= 1*32+1;
elseif strcmp(‘Axeman’,PlayerClass) & Gender==1 %Male Axeman
player= 1*32+0;
elseif strcmp(‘Hunter’,PlayerClass) & Gender==2 %Female Hunter
player= 1*32+4;
elseif strcmp(‘Hunter’,PlayerClass) & Gender==1 %Male Hunter
player= 1*32+2;
elseif strcmp(‘Healer’,PlayerClass)& Gender==2 %Female Phys
player= 1*32+6;
elseif strcmp(‘Healer’,PlayerClass)& Gender==1 %Male Phys
player= 1*32+5;
else

end

%BG
emptysky = 4*32+8;
moonsky = 4*32+7;
forestGround = 5*32+7;
riverGround = 5*32+6;
townGround = 5*32+5;
POVGround= 4*32+4;
POVRiver= 5*32+3;
POVStreet= 5*32+2;
POVTrees= 4*32+3;
POVBar=6*32+6;
BarLow=7*32+5;
empty_room_sprite = 17;

%Buttons
Faxeman= 3*32+9;
Maxeman= 2*32+10;
Fhunter= 3*32+10;
Mhunter= 2*32+11;
Fphy= 3*32+11;
Mphy= 2*32+12;
Attack= 1*32+8;
Deflect=1*32+9;
Focus=1*32+10;
One=3*32+6;
Two=3*32+7;

%Prop Sprites
Torch=2*32+14;
OldMan=3*32+13;

%Enemies
WaterSnakeTop=3*32+4;
WaterSnakeBottom=3*32+5;
CentaurTop= 2*32+13;;
CentaurBottom= 3*32+12;
BossTop=2*32+4;
BossLeft=2*32+5;
BossBottom=3*32+3;

%##SITUATIONS################################################%

%COMBAT FOREST WATERDRAGON
if Situation==1
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [emptysky,emptysky,moonsky;emptysky,emptysky,emptysky;forestGround,forestGround,riverGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [Attack,Deflect,Focus;blank,blank,WaterSnakeTop; player,blank,WaterSnakeBottom] ;
drawScene(my_scene,rooms_display,gameboard_display)

%POV FOREST
elseif Situation==2
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; blank,blank,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)

%CHAR SELECT
elseif Situation==3
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [Faxeman,Fhunter,Fphy;Maxeman,Mhunter,Mphy] ;
drawScene(my_scene,rooms_display,gameboard_display)

%POV RIVER
elseif Situation==4
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVRiver,POVRiver,POVRiver];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; blank,blank,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)

%POV TORCH
elseif Situation==5
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; blank,Torch,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)
%CHOICE TORCH
elseif Situation==6
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; One,Torch,Two] ;
drawScene(my_scene,rooms_display,gameboard_display)
%CHOICE RIVER
elseif Situation==7
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVRiver,POVRiver,POVRiver];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; One,blank,Two] ;
drawScene(my_scene,rooms_display,gameboard_display)
%CHOICE GROUND
elseif Situation==8
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; One,blank,Two] ;
drawScene(my_scene,rooms_display,gameboard_display)
%POV Street
elseif Situation==9
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [townGround,townGround,townGround;POVStreet,POVStreet,POVStreet];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; blank,blank,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)
%CHOICE STREET
elseif Situation==10
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [townGround,townGround,townGround;POVStreet,POVStreet,POVStreet];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,blank,blank; One,blank,Two] ;
drawScene(my_scene,rooms_display,gameboard_display)

%COMBAT FOREST KM
elseif Situation==11
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [emptysky,emptysky,moonsky;emptysky,emptysky,emptysky;forestGround,forestGround,forestGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [Attack,Deflect,Focus;blank,blank,CentaurTop; player ,blank,CentaurBottom] ;
drawScene(my_scene,rooms_display,gameboard_display)
%BAR
elseif Situation==12
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,1);

% Display empty screen
rooms_display = [POVBar,POVBar,POVBar;BarLow,BarLow,BarLow];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,OldMan,blank;blank,blank,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)
%BOSS COMBAT
elseif Situation==13
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [emptysky,emptysky,moonsky;emptysky,emptysky,emptysky;forestGround,forestGround,forestGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [Attack,Deflect,Focus;blank,BossTop,BossLeft; player,BossBottom,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)
%CHOICE BAR
elseif Situation==14
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVBar,POVBar,POVBar;BarLow,BarLow,BarLow];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,OldMan,blank; One,blank,Two] ;
drawScene(my_scene,rooms_display,gameboard_display)

%CHOICE GROUND
elseif Situation==15
% Initialisation
clf
my_scene = simpleGameEngine(‘packSDP.png’,35,33,3);

% Display empty screen
rooms_display = [POVTrees,POVTrees,POVTrees;POVGround,POVGround,POVGround];
drawScene(my_scene,rooms_display)

%Second Screen Layer
gameboard_display = [blank,BossTop,BossLeft; blank,BossBottom,blank] ;
drawScene(my_scene,rooms_display,gameboard_display)

end
end

======================================================================

“SplashDraw.m”

function SplashDraw(A)
%Presentation
if A==1
clf
img = imread(‘Title 1.png’);
imshow(img);
%Title
elseif A==2
img = imread(‘Title2.png’);
clf
imshow(img);
%Death
elseif A==3
img = imread(‘DScreen.png’);
clf
imshow(img);
%End
elseif A==4
img = imread(‘EndCard.png’);
clf
imshow(img);
%lol
elseif A==5
img = imread(‘Sequel Art.png’);
clf
imshow(img);
end

======================================================================

“Soundtrack.m”

function Soundtrack
%%LOAD AND LOOP THROUGH SOUNDTRACK%%
clear sound
[y, Fs] = audioread(‘Memory Quest.m4a’);
player = audioplayer(y,Fs);
[y2,Fs2]= audioread(‘IdleALT.m4a’);
player2 = audioplayer(y2,Fs2)
[y3,Fs3]= audioread(‘CombatALT.m4a’);
player3 = audioplayer(y3,Fs3)
while true
playblocking(player);
playblocking(player2);
playblocking(player3);
playblocking(player3);
playblocking(player);
end

end

======================================================================

“BossFight.m”

function BossFight(PlayerClass,Gender)
global name
global PlayerClass
global PlayerHP
global PlayerMaxHP
global PlayerEnergy
global Gender
global PlayerSTR
global PlayerSPD
global PlayerRG
global Gold
PlayerHP=PlayerMaxHP;
EnemHP=105;
EnemEnergy=2;
EnemSTR=9;
EnemSPD=9;
EnemRG=2;
DrawUX(13,PlayerClass,Gender)
fprintf(‘########################COMBAT START!#####################\n’)
fprintf(‘Dream Eater:”…feed…more…”\n’)
while EnemHP > 0 && PlayerHP > 0

%SELECT ENEMY MOVE
if EnemEnergy < 1
EnemMove=randi(2:3);
else
EnemMove=randi(3);
end

%SELECT PLAYER MOVE
fprintf(‘###############NEW TURN!######################\n’)
fprintf(‘Select a move.\n’)
[clickX, clickY] = ginput(1);

if (clickX > 0 && clickX < 100) && (clickY>30 && clickY<70)%(Attack)
fprintf(‘Selected: Attack!\n’)
PlayerMove=1;
elseif (clickX > 100 && clickX < 200) && (clickY>30 && clickY<70)%(Deflect)
fprintf(‘Selected: Deflect!\n’)
PlayerMove=2;
elseif (clickX > 200 && clickX < 300) && (clickY>30 && clickY<70)%(Focus)
fprintf(‘Selected: Focus!\n’)
PlayerMove=3;
else
fprintf(‘Selected: Attack!\n’)
PlayerMove=1;
end
%FIGHT CONDITIONS
%Player and Enemy Strike.
if EnemMove==1 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“Both combatants strike!\n”)
EnemAttackPWR= EnemSTR+EnemEnergy;
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
if EnemAttackPWR>PlayerAttackPWR
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Enemy Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR<PlayerAttackPWR
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Player Prevails!\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif EnemAttackPWR==PlayerAttackPWR
fprintf(‘Player Attack Power: %i , Enemy Attack Power: %i\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘Neither strike lands…\n’,PlayerAttackPWR,EnemAttackPWR)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player and Enemy Def
elseif EnemMove==2 && PlayerMove==2
fprintf(“Both combatants deflect!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player and Enemy Focus
elseif EnemMove==3 && PlayerMove==3
PlayerEnergy=PlayerEnergy+PlayerRG;
EnemEnergy=EnemEnergy+EnemRG;
fprintf(‘Player Regeneration: %i , Enemy Regeneration: %i\n’,PlayerRG,EnemRG)
fprintf(“Both combatants focus their energy!\n”)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Attack and Enemy Focus
elseif EnemMove==3 && PlayerMove==1
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
fprintf(‘Strike lands!\n’)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(“The enemy begins to focus…\n”)
EnemEnergy=EnemRG+EnemEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end

%Player Focus and Enemy Attack
elseif EnemMove==1 & PlayerMove==3
fprintf(“The Dream Eater strikes!\n”)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
fprintf(‘Strike lands!\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(“%s begins to focus…\n”,name)
PlayerEnergy=PlayerRG+PlayerEnergy;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
%Player Attack and Enemy Defend
elseif PlayerMove==1 & EnemMove==2
if PlayerEnergy ~=0
fprintf(“%s strikes!\n”,name)
fprintf(“The dusky wraith recoils and dodges!\n”)
PlayerAttackPWR=PlayerSTR+PlayerEnergy;
fprintf(‘Player Attack Power: %i \n’,PlayerAttackPWR)
if PlayerSPD>EnemSPD
fprintf(‘%s manages to get a hit!\n’,name)
EnemHP=EnemHP-PlayerAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
PlayerEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
PlayerEnergy=0;
fprintf(‘The Dream Eater phases apart, and evades the blow.\n’)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
elseif PlayerEnergy == 0
fprintf(“Can’t attack with zero energy!!\n”)
end
%Player Defend and Enemy Attack
elseif EnemMove==1 & PlayerMove==2
fprintf(“The Dream Eater strikes!\n”)
fprintf(“%s attempts to deflect!\n”,name)
EnemAttackPWR=EnemSTR+EnemEnergy;
fprintf(‘Enemy Attack Power: %i \n’,EnemAttackPWR)
if PlayerSPD<EnemSPD
fprintf(‘The Dream Eater snakes between your steps, breaking your guard.\n’)
PlayerHP=PlayerHP-EnemAttackPWR;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
EnemEnergy=0;
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
else
EnemEnergy=0;
fprintf(‘%s is fast enough to deflect the attack unharmed!\n’,name)
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end

%Player Focus and Enemy Def
elseif EnemMove==2 & PlayerMove==3
fprintf(“%s focuses thier energy…\n”,name)
fprintf(“The Dream Eater moves to deflect!\n”)
PlayerEnergy= PlayerEnergy+PlayerRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)

%Player Def and Enemy Focus
elseif EnemMove==3 & PlayerMove==2
fprintf(“%s moves to deflect!\n”,name)
fprintf(“The Dream Eater focuses it’s energy..\n”)
EnemEnergy= EnemEnergy+EnemRG;
fprintf(‘PlayerHP: %i, EnemyHP: %i\n’,PlayerHP,EnemHP)
fprintf(‘Player Energy: %i, Enemy Energy: %i\n’,PlayerEnergy,EnemEnergy)
end
end
if PlayerHP <=0
fprintf(‘You were defeated…\n’)
SplashDraw(3)
pause = ginput(1);
SplashDraw(4)
pause = ginput(1);
close all
clear all
return
else
DrawUX(2,PlayerClass,0)
fprintf(‘The Dream Eater begins to withe and dissolve on the ground…\n’)
pause = ginput(1);
fprintf(‘As it does, trapped memories float off from it.\n’)
pause = ginput(1);
fprintf(‘Memories fall like snow around the mountain, as your past returns to you.\n’)
pause = ginput(1);
fprintf(‘Day breaks on the mountainside.\n’)
pause = ginput(1);
fprintf(‘You remember…\n’)
pause = ginput(1);
clc
SplashDraw(4)
pause = ginput(1);
SplashDraw(5)
pause = ginput(1);
return
end