Question
In C++ The goal of this assignment is to simulate game objects in a scene, and move them around on a 1-D number line Create
In C++ The goal of this assignment is to simulate game objects in a scene, and move them around on a 1-D number line
Create a base class named GameObject
- All GameObject objects have an X-position on the number line
- All GameObject objects have a speed value (how fast they should move when their Update() function is called
- All GameObject objects have a virtual function Update() which adds their speed value to their position value
- All GameObject objects have a pure virtual function Print() which prints out their "vital" information shown below
Create a derived class called SpaceShip
- Give it a position and speed upon creation
- Also give it a "ready for battle" value in the range of 0-100
- Upon call of Update(), the position is moved via the speed variable
- Upon call of Update(), the battle readiness is incremented by 1 (don't go past 100)
- Upon call of Print(), its "vital" information consists of its position, speed and battle readiness
Create a derived class called SpaceShipCaptain
- Give it a position and speed upon creation
- Also give it a string name
- Also give it a "rested" value in the range of 0-100
- Upon call of Update(), the position is moved via the speed variable
- Upon call of Update(), the rested value reduces by 1 (don't go negative)
- Upon call of Print(), its "vital" information consists of its name, position, speed and rested value
Using your main function loop, do the following:
1) Create a vector of GameObject pointers
2) Create a menu system that allows the user the following functionality options:
a) Display all GameObjects currently in the vector
- Display all objects and the "vital" information for each
- Make sure to include the vector index number in each listing
b) Create a SpaceShip object and put it in the vector
- User inputs initial values for position, speed, and battle-readiness
c) Create a SpaceShipCaptain object and put it in the vector
- User inputs initial values for name, position, speed, and restedness
d) Delete an object out of the vector
- User supplies the index value
- Make sure the index value is valid
- Make sure you don't cause a memory leak!
e) Call function Update() on all objects in the vector
- All objects move around a bit
- Some objects do other things
f) Sort all objects in the vector
- Sort first by position, then by speed
g) Quit program
- Make sure you don't cause a memory leak!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started