📄 aerocraft.h
字号:
// Aerocraft.h: interface for the CAerocraft class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_AEROCRAFT_H__A86979B7_98AE_47C3_8C0C_48F2BE82CC64__INCLUDED_)
#define AFX_AEROCRAFT_H__A86979B7_98AE_47C3_8C0C_48F2BE82CC64__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include"SVector2D.h"
#include<vector>
#include"2DMatrix.h"
using namespace std;
/*
const SPoint SPAerocraft[30] = {//middle of lander
SPoint(-1, 0),
SPoint(1, 0),
SPoint(1, -0.5),
SPoint(-1, -0.5),
//top of lander
SPoint(-0.5, 0),
SPoint(-1, 0.3),
SPoint(-1, 0.7),
SPoint(-0.5, 1),
SPoint(0.5, 1),
SPoint(1, 0.7),
SPoint(1, 0.3),
SPoint(0.5, 0),
//legs
SPoint(-1, -0.4),
SPoint(-1.3, -0.8),
SPoint(-1.3, -1.2),
SPoint(-1.5, -1.2),
SPoint(-1.1, -1.2),
SPoint(-0.9, -0.5),
SPoint(-1.3, -0.8),
SPoint(1, -0.4),
SPoint(1.3, -0.8),
SPoint(1.3, -1.2),
SPoint(1.5, -1.2),
SPoint(1.1, -1.2),
SPoint(0.9, -0.5),
SPoint(1.3, -0.8),
//rocket
SPoint(-0.2, -0.5),
SPoint(-0.3, -0.8),
SPoint(0.3, -0.8),
SPoint(0.2, -0.5)};
*/
const SPoint SPAerocraft[30] = {//middle of lander
SPoint(1, 5),
SPoint(1, 4),
SPoint(3, 4),
SPoint(4, 3),
SPoint(4, 1),
SPoint(5, 1),
SPoint(5, -1),
SPoint(4, -1),
SPoint(4, -3),
SPoint(3, -4),
SPoint(1, -4),
SPoint(1, -5),
SPoint(-1, -5),
SPoint(-1, -4),
SPoint(-3, -4),
SPoint(-4, -3),
SPoint(-4, -1),
SPoint(-5, -1),
SPoint(-5, 1),
SPoint(-4, 1),
SPoint(-4, 3),
SPoint(-3, 4),
SPoint(-1, 4),
SPoint(-1, 5),
SPoint(1, 5),
SPoint(1, 5),
SPoint(1, 5),
SPoint(1, 5),
SPoint(1, 5),
SPoint(1, 5),
};
const SPoint jet[5] = {SPoint(0.8, 5),
SPoint(0.6, 7),
SPoint(0, 8.5),
SPoint(-0.6, 7),
SPoint(-0.8, 5)};
class CObstacle
{
public:
SPoint center;
double radius;
//SObstacle(int x , int y, double r):x(a),y(b){}
CObstacle(int x = 0,int y = 0,double r = 0)
{
center.x = x;
center.y = y;
radius = r;
}
void init(int x = 0,int y = 0,double r = 0)
{
center.x = x;
center.y = y;
radius = r;
}
};
class CAerocraft
{
public:
CAerocraft(int cxClient, //so we can keep a local record
int cyClient, //of the window dimensions
double rot //starting rotation of lander
);
CAerocraft();
virtual ~CAerocraft();
SPoint m_tempSPAerocraft[30];//用于储存飞船的轮廓(还没有移动时候的状态)
SPoint m_SP[30];//用与存储飞船按照m_vPos向量移动后的状态
void init(int x,int y,double dRotation,double dScale);
void rotation(double dPotation);
void Scale(double dScale);
//position in world
SVector2D m_vPos;
//rotation in the world
double m_dRotation;
//scaling factor for rendering ship
double m_dScale;
//this function transforms the ships vertices so we can display them
void WorldTransform();
public:
void updateTheVector();
SVector2D m_vVelocity;
/*
//ships mass
double m_dMass;
//and velocity
//need to know where landing pad is for collision detection
SVector2D m_vPadPos;
*/
//buffer to store the ships vertices
vector<SPoint> m_vecShipVB;
//buffer to hold our transformed vertices
vector<SPoint> m_vecShipVBTrans;
//and the jets vertices
vector<SPoint> m_vecJetVB;
vector<SPoint> m_vecJetVBTrans;
//we use this to determine whether to render the ships jet or not
//(if the user is pressing thrust then the jet is rendered)
bool m_bJetOn;
//local copy of client window size
int m_cxClient;
int m_cyClient;
//used to flag whether or not we have already tested for success
//or failure
bool m_bCheckedIfLanded;
//tests if any vertex of the ship is below the level of the landing
//platform
bool TestForImpact(vector<SPoint> &ship);
public:
void showTheJet(CDC *pDC,int drawX);
SPoint m_SPJet[10];
void showTheAerocraft(CDC* pDC);
int m_iJetDirection;
void updateTheVelocity5();
void updateTheVelocity4();
void updateTheVelocity3();
void updateTheVelocity2();
void updateTheVelocity1();
void updateThePosition();
//void Render(HDC &surface);
//resets all relevant variables for the start of a new attempt
//void Reset(SVector2D &NewPadPos);
//updates the ship from a keypress
//void UpdateShip(double TimeElapsed);
};
#endif // !defined(AFX_AEROCRAFT_H__A86979B7_98AE_47C3_8C0C_48F2BE82CC64__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -