⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clander.h

📁 基于遗传算法实现的人工控制的登月工程的模拟程序
💻 H
字号:
#ifndef CLANDER_H
#define CLANDER_H

//-----------------------------------------------------------------------
//
//  Name: CLander.h
//
//  Author: Mat Buckland 2002
//
//	Desc: A class to define a lunar lander object
//
//-----------------------------------------------------------------------

#include "windows.h"
#include <vector>

#include "utils.h"
#include "defines.h"
#include "CTimer.h"
#include "SVector2D.h"
#include "C2DMatrix.h"

using namespace std;


class CLander
{
private:
	
	//position in world
	SVector2D		        m_vPos;
	
  //rotation in the world
	double			        m_dRotation;

	//scaling factor for rendering ship
  double			        m_dScale;
	
	//ships mass
  double			        m_dMass;

  //and velocity
  SVector2D		        m_vVelocity;
        
  //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;


	//returns true if the user has satisfied all the conditions for landing
  bool    LandedOK();

	//tests if any vertex of the ship is below the level of the landing
  //platform
  bool	  TestForImpact(vector<SPoint> &ship);

  //this function transforms the ships vertices so we can display them
  void WorldTransform(vector<SPoint> &ship);



public:

	CLander(int       cxClient, //so we can keep a local record 
          int       cyClient, //of the window dimensions
          double    rot,      //starting rotation of lander
          SVector2D pos,      //starting position of lander
          SVector2D pad);     //landing pad position
  
	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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -