Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Revision 1:679d7ada8de7, committed 2019-05-12
- Comitter:
- el17ph
- Date:
- Sun May 12 13:43:27 2019 +0000
- Parent:
- 0:8fb740fa6356
- Commit message:
- el17ph
Changed in this revision
--- a/Maintank/MainTank.cpp Sat May 11 14:58:43 2019 +0000 +++ b/Maintank/MainTank.cpp Sun May 12 13:43:27 2019 +0000 @@ -1,11 +1,7 @@ #include "MainTank.h" -/** MainTank Class -* @brief Set and update the value of tank in the game -* @author Pengxi Huang -* @date may,2019 -*/ + /** Constructor */ MainTank::MainTank()
--- a/Maintank/MainTank.h Sat May 11 14:58:43 2019 +0000
+++ b/Maintank/MainTank.h Sun May 12 13:43:27 2019 +0000
@@ -1,3 +1,4 @@
+///////// pre-processor directives ////////
#ifndef __MAIN_TANK__
#define __MAIN_TANK__
@@ -5,6 +6,11 @@
#include "N5110.h"
#include "Gamepad.h"
+/** MainTank Class
+ * @brief Set and update the value of tank in the game
+ * @author Pengxi Huang
+ * @date may,2019
+ */
class MainTank
{
--- a/Rocket/Rocket.cpp Sat May 11 14:58:43 2019 +0000
+++ b/Rocket/Rocket.cpp Sun May 12 13:43:27 2019 +0000
@@ -1,26 +1,17 @@
#include "Rocket.h"
-/** Rocket Class
-* @brief Set and update the value of rocket in the game
-* @author Pengxi Huang
-* @date may,2019
-*/
-
-/** Constructor */
Rocket::Rocket()
{
}
-/** Destructor */
+
Rocket::~Rocket()
{
}
-/** Inital the postion
- * @param the X and y of the class(int)
- */
+
//init the postion of the rocket
void Rocket::init()
{
@@ -47,18 +38,14 @@
}
-/** Set the new position
- * @param the value of the new position(Vector2D)
- */
+
//update its y position base on speed
void Rocket::update()
{
m_y += m_speed;
}
-/** Get the position of rocket 1
- * @return the current poition in 2d
- */
+
//get the x and y value for rocket 1
Vector2D Rocket::get_pos1()
{
@@ -66,9 +53,7 @@
return p1;
}
-/** Get the position of rocket 2
- * @return the current poition in 2d
- */
+
//get the x and y value for rocket 2
Vector2D Rocket::get_pos2()
{
--- a/Rocket/Rocket.h Sat May 11 14:58:43 2019 +0000
+++ b/Rocket/Rocket.h Sun May 12 13:43:27 2019 +0000
@@ -5,16 +5,35 @@
#include "N5110.h"
#include "Gamepad.h"
+/** Rocket Class
+* @brief Set and update the value of rocket in the game
+* @author Pengxi Huang
+* @date may,2019
+*/
+
class Rocket
{
public:
+ /** Constructor */
Rocket();
+ /** Destructor */
~Rocket();
+ /** Inital the postion
+ * @param the X and y of the class(int)
+ */
void init();
void draw(N5110 &lcd);
+ /** Set the new position
+ * @param the value of the new position(Vector2D)
+ */
void update();
- /// accessors and mutators
+ /** Get the position of rocket 1
+ * @return the current poition in 2d
+ */
Vector2D get_pos1();
+ /** Get the position of rocket 2
+ * @return the current poition in 2d
+ */
Vector2D get_pos2();
private:
int m_speed;
--- a/TankEngine/TankEngine.cpp Sat May 11 14:58:43 2019 +0000
+++ b/TankEngine/TankEngine.cpp Sun May 12 13:43:27 2019 +0000
@@ -1,26 +1,18 @@
#include "TankEngine.h"
-/** TankEngine Class
-* @brief Set and update the engine of game(include rocket and tank)
-* @author Pengxi Huang
-* @date may,2019
-*/
-/** Constructor */
+
TankEngine::TankEngine()
{
}
-/** Destructor */
+
TankEngine::~TankEngine()
{
}
-/** Inital the every value
- * @param the all value of the class(int)
- */
//init value of tank and rocket
void TankEngine::init()
{
@@ -28,9 +20,7 @@
_r.init();
}
-/** Set the Value of direction and magnitude
- * @param the value of the new position(Vector2D)
- */
+
//get the input value from gamepad
void TankEngine::read_input(Gamepad &pad)
{
@@ -38,9 +28,7 @@
_mag = pad.get_mag();//read joystick movement
}
-/** Set the new position and do collaps detect
- * @param the value of the new position(Vector2D)
- */
+
//update the status of tank and rocket
void TankEngine::update(Gamepad &pad)
{
@@ -189,9 +177,6 @@
}
-/** Get the score
- * @return the current score
- */
//Get the value of score
int TankEngine::hello_score()
{
@@ -199,9 +184,6 @@
return score;
}
-/** Get the life
- * @return the current life
- */
//Get the value of life
int TankEngine::get_life()
{
--- a/TankEngine/TankEngine.h Sat May 11 14:58:43 2019 +0000
+++ b/TankEngine/TankEngine.h Sun May 12 13:43:27 2019 +0000
@@ -7,18 +7,39 @@
#include "MainTank.h"
#include "Rocket.h"
+/** TankEngine Class
+ * @brief Set and update the engine of game(include rocket and tank)
+ * @author Pengxi Huang
+ * @date may,2019
+ */
class TankEngine
{
public:
-
+ /** Constructor */
TankEngine();
+ /** Destructor */
~TankEngine();
-
+ /** Inital the every value
+ * @param the all value of the class(int)
+ */
void init();
+ /** Set the Value of direction and magnitude
+ * @param the value of the new position(Vector2D)
+ */
void read_input(Gamepad &pad);
+ /** Set the new position and do collaps detect
+ * @param the value of the new position(Vector2D)
+ */
void update(Gamepad &pad);
+ /// accessors and mutators
void Draw(N5110 &lcd);
+ /** Get the life
+ * @return the current life
+ */
int get_life();
+ /** Get the score
+ * @return the current score
+ */
int hello_score();
private:
--- a/main.cpp Sat May 11 14:58:43 2019 +0000
+++ b/main.cpp Sun May 12 13:43:27 2019 +0000
@@ -14,11 +14,13 @@
Date:11.05.2019
*/
+/////////////// structs /////////////////
struct UserInput {
Direction d;
float mag;
};
+///////////// prototypes ///////////////
void init();
void update_game(UserInput input);
void render();
@@ -27,9 +29,11 @@
void print_level();
int quite();
+/////////////// objects ///////////////
N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
Gamepad pad;
TankEngine Tank;
+///////////// functions ////////////////
//main function
int main()
{