(Solved) : Lunar Lander One Many Influential Early Video Games Released Atari 1979 Precursor Release Q32431000 . . .
Lunar Lander was one of many influential early video gamesreleased by Atari in 1979, and was a precursor to their release ofAsteroids (which we will also implement this semester). The objectof the game is to safely navigate a lunar module to land on a flatportion of the moon’s surface. To pilot the lander, horizontalthrusters can be activated to maneuver the ship left and right, andvertical thrusters can be fired to slow its descent.
The Challenge
First, you need to set up your environment for OpenGL projects.Then, your assignment is to create a Moon Lander game that is abased on this classic arcade game. In the game, a random groundconfiguration is drawn, with a single safe landing platform. Thelander begins at a random location along the top of the screen andbegins falling according to gravity. The user can fire left, right,and bottom thrusters to guide the craft safely to the landingplatform before the fuel is exhausted. The lander will crash if ittouches the ground or approaches the platform with too muchspeed.
The entire program will need to be implemented using theprinciples of encapsulation. Thus, you need to think about thedifferent components (classes) that you will need in the game, andtheir various actions (methods) and properties (member variables).Before you start programing, you will need to produce UML classdiagrams for each of the classes you will be using. Please payspecial attention to the design of these components, so they can beas general-purpose as possible. You will want to reuse some of themin future projects.
To assist you in your project, you will be given animplementation of a Point class that stores an x and y coordinate,and a Ground class that generates random terrain (including thelanding platform), and has methods to identify the location of theplatform (getPlatformPosition()), the elevation of an object abovethe ground (getGround(Point)), and if a point is above ground (notcrashed) (isAboveGround(Point)). The following UML defines theseclasses:
Point
-x : float
-y: float
+Point()
+Point(float, float)
+getX() : float
+getY() : float
+setX(float) : void
+setY(float) : void
+addX(float) : void
+addY(float): void
Ground
-platform : Point
-xSize : int
-ground : float*
-topLeft : Point
-bottomRight : Point
+Ground(Point, Point)
+draw() : void
+isAboveGround(Point) : bool
+getGround(Point) : Point
+generateGround() : void
+getPlatformPosition() : Point
+getPlatformWidth() : int
Game Play and Rules
The following describes the rules and game play of MoonLander:
The dimensions of the screen are: (-200, -200) to (200,200).
The lander begins with 500 units of fuel.
To land successfully, the lander must:
have its center within the horizontal boundaries of theplatform.
be within 4 pixels vertically, above the platform.
arrive at the platform with a velocity of no more than 3 pixelsper frame in any direction.
Gravity on the moon can be modeled as 0.1 pixels per frame.
The left arrow key causes thrust on the left of the lander whichpropels it to the right (and similar for the right and downarrows).
The left and right thrust amounts are 0.1 pixels per frame, andconsume 1 unit of fuel.
The upward thrust (caused by the down arrow) amount is 0.3pixels per frame, and consumes 3 units of fuel.
The lander should have inertia, in other words, once it beginsmoving left, it should continue moving left unless additionalthrust is made.
The lander should not continue to move after crashing orlanding.
After successfully landing, the game should display, “You havesuccessfully landed!”
After crashing, the game should display, “You have crashed.”
After running out of fuel, the lander should not be able toapply thrusters (but can continue falling).
Any other contact with the ground or platform results in acrash.
Error Handling
As usual, your classes and the game itself will need to berobust to any type of user or file input. Extensive error handlingshould also be built into each class to ensure that clients of theclass will use them correctly. Similarly, there should be no waythe user can cause the program to malfunction due to incorrectlyformed input.
Using the Provided Files
The graphics and game play will be done with OpenGL. Asimplified interface to this library is provided.
Essentially there are two sets of files, those that handle thedetails of the graphics and drawing, and those that relate to theMoon Lander part of the game. You are welcome to look through thefirst set of files, but you will likely not need to change anythingthere.
Set 1 – The Graphics interface
The part of graphics interface files that is important for youto know, is that it provides the following functions:
-drawLander(Point p)
Draws a lander (i.e., ship) atthe provided point.
-drawLanderFlames(Point p, bool bottom, bool left, boolright)
Draws the flames for the lander at anydirection set to true.
-drawText(Point p, const char * text)
Puts the provided text on the screen atpoint p.
-drawNumber(Point p, unsigned int number)
Puts the provided number on the screenat point p.
The files that compose this interface to the library are:(again, you should not need to worry about the details ofthem):
/home/cs165new/moonLander/uiInteract.h — Header file describingthe OpenGL interface
/home/cs165new/moonLander/uiInteract.cpp — Source foruiInteract.h. Should not change
/home/cs165new/moonLander/uiDraw.h — Header file with drawingfunction prototypes
/home/cs165new/moonLander/uiDraw.cpp — All the drawingfunctions.
/home/cs165new/moonLander/point.h — Ultra simple classdescribing a single point
/home/cs165new/moonLander/point.cpp — Implementation of thePoint class
Set 2 – Files Relating to Moon Lander
The next set of files relate directly to the Moon Lander. First,we have a makefile and a Ground class.
The makefile contains rules to build compile all of the filesprovided, but YOU WILL NEED TO UPDATE IT to compile any new files /classes you create.
-/home/cs165new/moonLander/makefile — Instructions to build thegame
The Ground class is used to draw the terrain of the world andthe platform. It also contains methods that allow you to know howclose a point is to the ground, etc.
-/home/cs165new/moonLander/ground.h — Header file for theGround
-/home/cs165new/moonLander/ground.cpp — Implementation for theGround class
(Here is the repository I’ve made for all the files):
https://github.com/phi1ny3/Moon-Lander
Thanks in advance!
Expert Answer
Answer to Lunar Lander One Many Influential Early Video Games Released Atari 1979 Precursor Release Q32431000 . . .
OR