讲解program header、C++程序调试、辅导C++、讲解program留学生
- 首页 >> 其他 Assignment 2: Choose your boss and then fight them!
Due: Sunday, April 14, 2019, 11:59pm
Aim
By working on this assignment you should be able to:
● Use variables
● Accept and process user input
● Implement decision making in C++
Points
In addition to the points for each part of this assignment, there are 20 pts for Program
Style & Comments.
To gain these points, make sure that you include a program header (10 pts) in your
code, in addition to proper indentation/spacing and other comments (10 pts) for each
major thing that you are doing in your function.
Make sure you review the style guidelines [0] for this class, and begin trying to follow
them, i.e. don’t align everything on the left or put everything on one line!
[0]https://oregonstate.instructure.com/courses/1725107/files/74623886/download?
wrap=1
Below is an example of how we expect your program to be styled:
/******************************************************
** Program: wingardium_leviosa.cpp
** Author: Hermione Granger
** Date: 07/04/1776
** Description: Makes a C++ object from the heap float in air and prints
where it floated
** Input: None
** Output: The height at which the object floated will be printed on thescreen
******************************************************/
//this library allows us to print and get input from user
#include
int main() { //this is the main function which will be executed
int myObjectNumber; //variable to store our object's number
//send the object number to the fly function which returns how high it
flew and the print the object number
std::cout << "The object flew up at " << fly(myObjectNumber)<<" feet";
return 0;
}Part A: (80 points)
About this assignment
The Beaver Games development company has been working on developing a textbased
adventure game where a character travels in a world full of magicians, ogres,
elves and Gummi Bears[0]. But the only two game developers working for the company
have gone on paternity leave and you, the bright and promising intern, have been
tasked to write the boss fight part of the game.
The requirements of the game
It is left to your skill, judgement and imagination what bosses the character fights and
what powers the bosses have but the company requires that:
a. the character fights for at least FOUR action scenes ( 1 action scene = one attack
by the boss and one counter attack by the character which the user gets to select)
with a boss (see the Example algorithm at the end) and,
b. there be at least TWO different bosses which the character would encounter by
pure chance element and,
c. There must be an element of chance associated with at least one action scene
which can bring a twist in the fight.
An example run of the game written by one looks like this:
Welcome to the boss fight level!
You see two doors. Do you want to open the GREEN door or the RED door?
Enter 1 to open the GREEN door or 2 to open the RED door:
1
You chose to open the GREEN door and go inside.
The door shuts behind you and it’s pitch dark. You see a small flicker
of light in the dark room. As you start walking towards it you hear a
cackling laughter followed by a bone-chilling voice saying “Hello Z! I
have been waiting for you. Now you face the the greatest magician in
the BinaryLand!”You shoot an arrow in the direction of the voice. But you hear the
same laughter from another direction! You aim towards that direction
and just as you are about to shoot -- BOOM! A fireball comes hurtling
towards you from yet another direction!
You crouch down to avoid it but your hairs are singed.
What do you want to do next? Enter 1 to cast the Infrared Eye spell so
that you can see where the boss is or Enter 2 to cast the Stone Curse
spell to petrify the boss for 2 seconds:
2
You chose to cast the Stone Curse. You hear a gasp from the magician
as he freezes. You hear a small mutter from the magician and suddenly
winds come out of nowhere to lift you high up until it seems like you
are almost in the space and then you drop to the floor with a sudden
and heavy thud. You recognize that the magician casted a Winds of Fury
spell. You manage to land safely thanks to your magical boots but your
right ankle is hurt. You cast the Infrared Eye spell as you land and
you can see the magician in one corner of the room crouching down like
an old man with his magical staff.
What do you want to do next? Enter 1 to shoot an arrow or enter 2 to
cast a Lightning Spell on the magician.
1
You shoot an arrow towards the direction you last saw the magician.
But unfortunately, as the fates (and the Holy PseudoRandom Number
Generator of the BinaryLand) have turned against you -- the best
archer in the Binary Land, your arrow misses the magician and you hear
the magician laugh out loud:
“YOU FOOL! You think mere arrows can hurt the greatest magician? Well,
well, well. Let me teach you how to shoot arrows!”
And arrows come shooting towards from all the directions! It’s like a
shower of arrows. They scrape your face but thanks to your Cloak of
Invincibility you are saved from greater damage.
What do you want to do next ? Enter 1 to shoot an arrow or enter 2 to
cast a Fireball on the magician:2
You cast a Fireball in the general direction of the magician. And you
hear the cackling laughter again as the Fireball boomerangs back
towards you.
The Fireball engulfs you and you become a pile of dust. This is the
end of your adventure in BinaryLand.
The boss fight storyline writing and game programming is up to you but try to make
your game as clean and attractive to play as possible.
More specifications by the company:
The company also specified:
1. All choices presented to the user should be only single digit numbers.
2. If the user makes a choice that isn’t given, you can handle it by either
displaying an error message and asking for input again OR making a random
choice for them.
3. Since the game is already being written in C++, you must use C++ too.
4. You can use if/else and/or switch statements.
5. There should be at least 3 nested if statements and at least 2 paths.
6. The boss fight is a do or die stage of the game. The character doesn’t have a
choice of leaving the fight. Either the boss dies or the character does.
Example algorithm for encounter with the magician boss:
Give a choice of fighting Boss1 or Boss2
If user chooses to fight with Boss 1: //Boss1
Give a choice of doing Action 1 or Action 2
If user selects Action 1: //action scene 1
... //do something
Give a choice to user or let the random fate decide
If choice 1: //action scene 2
// do something
Give a choice to user or let random fate decide
If choice 1: //action scene 3
// do something
Give a choice to user or let fates choose
If choice 1: // action scene 4
// do somethingElse if choice 2
// do something else
...
Else if choice 2:
// do something
...
If user selects Action 2:
… //do something else
Give a choice to user or let the random fate decide
If choice 1:
// do something
Give a choice to user or let the random fate decide
If choice 1:
// do something
[0] https://en.wikipedia.org/wiki/Disney%27s_Adventures_of_the_Gummi_Bears
How to work on this assignment?
First write your story.
Then convert it into an algorithm.
Finally, draw a flowchart for it.
Let this flowchart guide your programming.
Figure out how to do each small thing from your algorithm in C++.
For example:
Find out how to take input and store it.
Find out how to decide the flow of the game based on this input condition.
You will need to implement the chance element. Find out how to program luck in C++.
You will need to also decide how to actually use this luck element for your story’s
progress. (eg. What will happen if the coin lands head side up versus when it lands
tailside)
This will require a bit of modification to your algorithm and that’s fine. Algorithms
aren’t set in stone but they can change as new strategies are discovered.
Due: Sunday, April 14, 2019, 11:59pm
Aim
By working on this assignment you should be able to:
● Use variables
● Accept and process user input
● Implement decision making in C++
Points
In addition to the points for each part of this assignment, there are 20 pts for Program
Style & Comments.
To gain these points, make sure that you include a program header (10 pts) in your
code, in addition to proper indentation/spacing and other comments (10 pts) for each
major thing that you are doing in your function.
Make sure you review the style guidelines [0] for this class, and begin trying to follow
them, i.e. don’t align everything on the left or put everything on one line!
[0]https://oregonstate.instructure.com/courses/1725107/files/74623886/download?
wrap=1
Below is an example of how we expect your program to be styled:
/******************************************************
** Program: wingardium_leviosa.cpp
** Author: Hermione Granger
** Date: 07/04/1776
** Description: Makes a C++ object from the heap float in air and prints
where it floated
** Input: None
** Output: The height at which the object floated will be printed on thescreen
******************************************************/
//this library allows us to print and get input from user
#include
int main() { //this is the main function which will be executed
int myObjectNumber; //variable to store our object's number
//send the object number to the fly function which returns how high it
flew and the print the object number
std::cout << "The object flew up at " << fly(myObjectNumber)<<" feet";
return 0;
}Part A: (80 points)
About this assignment
The Beaver Games development company has been working on developing a textbased
adventure game where a character travels in a world full of magicians, ogres,
elves and Gummi Bears[0]. But the only two game developers working for the company
have gone on paternity leave and you, the bright and promising intern, have been
tasked to write the boss fight part of the game.
The requirements of the game
It is left to your skill, judgement and imagination what bosses the character fights and
what powers the bosses have but the company requires that:
a. the character fights for at least FOUR action scenes ( 1 action scene = one attack
by the boss and one counter attack by the character which the user gets to select)
with a boss (see the Example algorithm at the end) and,
b. there be at least TWO different bosses which the character would encounter by
pure chance element and,
c. There must be an element of chance associated with at least one action scene
which can bring a twist in the fight.
An example run of the game written by one looks like this:
Welcome to the boss fight level!
You see two doors. Do you want to open the GREEN door or the RED door?
Enter 1 to open the GREEN door or 2 to open the RED door:
1
You chose to open the GREEN door and go inside.
The door shuts behind you and it’s pitch dark. You see a small flicker
of light in the dark room. As you start walking towards it you hear a
cackling laughter followed by a bone-chilling voice saying “Hello Z! I
have been waiting for you. Now you face the the greatest magician in
the BinaryLand!”You shoot an arrow in the direction of the voice. But you hear the
same laughter from another direction! You aim towards that direction
and just as you are about to shoot -- BOOM! A fireball comes hurtling
towards you from yet another direction!
You crouch down to avoid it but your hairs are singed.
What do you want to do next? Enter 1 to cast the Infrared Eye spell so
that you can see where the boss is or Enter 2 to cast the Stone Curse
spell to petrify the boss for 2 seconds:
2
You chose to cast the Stone Curse. You hear a gasp from the magician
as he freezes. You hear a small mutter from the magician and suddenly
winds come out of nowhere to lift you high up until it seems like you
are almost in the space and then you drop to the floor with a sudden
and heavy thud. You recognize that the magician casted a Winds of Fury
spell. You manage to land safely thanks to your magical boots but your
right ankle is hurt. You cast the Infrared Eye spell as you land and
you can see the magician in one corner of the room crouching down like
an old man with his magical staff.
What do you want to do next? Enter 1 to shoot an arrow or enter 2 to
cast a Lightning Spell on the magician.
1
You shoot an arrow towards the direction you last saw the magician.
But unfortunately, as the fates (and the Holy PseudoRandom Number
Generator of the BinaryLand) have turned against you -- the best
archer in the Binary Land, your arrow misses the magician and you hear
the magician laugh out loud:
“YOU FOOL! You think mere arrows can hurt the greatest magician? Well,
well, well. Let me teach you how to shoot arrows!”
And arrows come shooting towards from all the directions! It’s like a
shower of arrows. They scrape your face but thanks to your Cloak of
Invincibility you are saved from greater damage.
What do you want to do next ? Enter 1 to shoot an arrow or enter 2 to
cast a Fireball on the magician:2
You cast a Fireball in the general direction of the magician. And you
hear the cackling laughter again as the Fireball boomerangs back
towards you.
The Fireball engulfs you and you become a pile of dust. This is the
end of your adventure in BinaryLand.
The boss fight storyline writing and game programming is up to you but try to make
your game as clean and attractive to play as possible.
More specifications by the company:
The company also specified:
1. All choices presented to the user should be only single digit numbers.
2. If the user makes a choice that isn’t given, you can handle it by either
displaying an error message and asking for input again OR making a random
choice for them.
3. Since the game is already being written in C++, you must use C++ too.
4. You can use if/else and/or switch statements.
5. There should be at least 3 nested if statements and at least 2 paths.
6. The boss fight is a do or die stage of the game. The character doesn’t have a
choice of leaving the fight. Either the boss dies or the character does.
Example algorithm for encounter with the magician boss:
Give a choice of fighting Boss1 or Boss2
If user chooses to fight with Boss 1: //Boss1
Give a choice of doing Action 1 or Action 2
If user selects Action 1: //action scene 1
... //do something
Give a choice to user or let the random fate decide
If choice 1: //action scene 2
// do something
Give a choice to user or let random fate decide
If choice 1: //action scene 3
// do something
Give a choice to user or let fates choose
If choice 1: // action scene 4
// do somethingElse if choice 2
// do something else
...
Else if choice 2:
// do something
...
If user selects Action 2:
… //do something else
Give a choice to user or let the random fate decide
If choice 1:
// do something
Give a choice to user or let the random fate decide
If choice 1:
// do something
[0] https://en.wikipedia.org/wiki/Disney%27s_Adventures_of_the_Gummi_Bears
How to work on this assignment?
First write your story.
Then convert it into an algorithm.
Finally, draw a flowchart for it.
Let this flowchart guide your programming.
Figure out how to do each small thing from your algorithm in C++.
For example:
Find out how to take input and store it.
Find out how to decide the flow of the game based on this input condition.
You will need to implement the chance element. Find out how to program luck in C++.
You will need to also decide how to actually use this luck element for your story’s
progress. (eg. What will happen if the coin lands head side up versus when it lands
tailside)
This will require a bit of modification to your algorithm and that’s fine. Algorithms
aren’t set in stone but they can change as new strategies are discovered.