📄 object.h
字号:
// Object.h: interface for the CObject class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_OBJECT_H__1144D1A2_517B_4E0D_A6D3_7F0C44FFAE4A__INCLUDED_)
#define AFX_OBJECT_H__1144D1A2_517B_4E0D_A6D3_7F0C44FFAE4A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "Vector.h"
#include "Circle.h"
#include "Line.h"
#include <afxtempl.h>
#include <Mmsystem.h>
class CDebugDlg;
class Object
{
public:
Object(){};
virtual ~Object(){};
inline void Set_Width( double w ){ m_Width = w; };
inline void Set_Length( double l ){ m_Length = l; };
inline void Set_vPos( Vector pos ){ m_vPos = pos; }
inline void Set_bIsLive( BOOL bIsLive ){ m_bIsLive = bIsLive; };
inline double Get_Width(){ return m_Width; };
inline double Get_Length(){ return m_Length; };
inline Vector Get_vPos(){ return m_vPos; };
inline BOOL Get_bIsLive(){ return m_bIsLive; };
double m_Width;
double m_Length;
Vector m_vPos;//
BOOL m_bIsLive;
};
class Ball : public Object
{
public:
Ball(){};
virtual ~Ball(){};
};
typedef struct field
{
CRect m_Field;//整个场地
CRect m_ForbiddenArea;
Vector m_MyGoal;//我方球门位置
double Goal_Width;
Vector m_TheirGoal;//对方球门位置
}FieldStruct;
enum Where {center,left,right,top,bottom} ;
//typedef struct BeyondInfo
//{
// BOOL IsBeyond;
// Where where;
// BOOL IsForwardOutSide;
//}BeyondInfo;
typedef struct Diff//差补
{
float delta_L;
float delta_R;
}Diff;
//extern void PASCAL MMTimerProc(UINT wTimerID, UINT msg,DWORD dwUser,DWORD dwl,DWORD dw2);
class CRobocupView;
class Player;
//typedef CMap <UINT,UINT,Player*,Player*> CTimerMap;
class Player : public Object
{
public:
int lastbehavior;
int losttime;
void slxSimpleAction(int vl,int vr,int time);
static void SendSingleCommand3(const unsigned char,const unsigned char,const unsigned char);
static unsigned char MoveToExact( Vector dest );
static unsigned char TurnToExact( Vector vec );
static void SendSingleCommand2(const unsigned char,const unsigned char,const unsigned char);
Vector ChooseGoaliePSecondHalf(Ball &ball);
BOOL bShootSecondHalf();
static void AllStop();
void SimpleActionTest();
Vector dest;
BOOL bShoot();
BOOL TurnTo(Vector dest,UINT para_depth=1);
Vector ChooseDP2SecondHalf(Ball ball);
Vector ChooseDP1SecondHalf(Ball ball);
Vector ChooseSPSecondHalf(Ball ball);
Vector ChooseFPSecondHalf(Ball ball);
Vector ChooseGoalieP(Ball ball);
Vector ChooseDP2(Ball ball);
Vector ChooseDP1(Ball ball);
Vector ChooseSP(Ball ball);
Vector ChooseFP(Ball ball);
BOOL HaveObstacleBall(Vector des);
// void IntegrateAction();
BOOL HaveObstacle(Vector des);
BOOL TurnAngle(double angle);
// double Time1;
void SimpleAction(int);
static void InitDiffMatrix();
// int EAPFMove( Vector &goal );
// Vector makePoint( Vector&, Vector&, double, BOOL );
// Vector makePoint( Line& l, Vector& v, double L, BOOL d );
// int makeRoot( Line& l, Circle& c, Vector& v1, Vector& v2 );
// int SmartMove(Vector &v, double ang );
// Vector& judgeRoot( Vector& v1, Vector& v2 );
// BOOL Turn(Vector );
// BOOL MoveToNoOA2(Vector destPos);
// void DPosition2(Vector dest);
Diff diff[128];
static UINT depth[5];
//多媒体Timer
// static void KillMMTimer(UINT);
static UINT SetMMTimer(UINT nElapse,DWORD dwUser,LPTIMECALLBACK TimeProc,UINT fuEvent=TIME_CALLBACK_FUNCTION,UINT wAccuracy=Player::wAccuracy);
static void InitMMTimer(UINT accuracy=1);
static UINT wAccuracy;
//边界判断函数
// BOOL PtInRect(CRect,CPoint);
// void BoundaryProc(CRect rect=CRect(30,30,30,30) ,UINT time=150);
// void IsMeBeyondTheField(BeyondInfo &,CRect);
//轮速的差补控制
int Diffrence;
//动作集合
// double DPosition(Vector dest);
// void ShootPeterDeffense( Vector p);
// double ShootPeter( Vector p);
// void RealShoot(double dist);
void BasicAct(double,BOOL,BOOL,double,DWORD=0);
// void Shoot4Debug();
// BOOL MoveToWithAngleOA( Vector destPos, double destAngle);
// BOOL MoveToWithAngle(Vector destPos, double destAngle);
Vector lable;
// static FILE * pFile;
//communicate methods
void SendCommand(DWORD time=0);//另一种形式的命令
static void SendSingleCommand(const unsigned char,const unsigned char,const unsigned char);
static HANDLE m_hComm;
static int InitComm(int Comm_num, int baud); //此处用静态函数
static BOOL WriteABuffer(char * lpBuf, DWORD dwToWrite);
static void SendCommandofAll();
BOOL MoveTo(Vector destPos);
// BOOL TurnTo4Debug(double );
// BOOL TurnTo4Debug(Vector );
// BOOL TurnTo(Vector dest,UINT depth=1);
double DistToBall;
Player(){};
virtual ~Player(){};
static FieldStruct FieldStruct;
static BOOL My_Side; //0代表我方在左边,1代表我方在右边
BOOL m_bIsLeft;//是否在左半场
Vector m_MyGoal;//我方球门位置
Vector m_OpponentGoal;//对方球门位置
Vector m_LeftBackPoint;//左后卫位置
Vector m_RightBackPoint;//右后卫位置
Vector m_LeftForwardPoint;//左前锋位置
Vector m_RightForwardPoint;//右前锋位置
double m_Angle;//小车的朝向角
void Set_m_Angle( double angle );
inline void Set_vL( double v ){ m_vL = v; };
inline void Set_vR( double v ){ m_vR = v; };
inline void Set_Num( int n ){ m_Num = n; };
inline void Set_bIsLeft( BOOL bIsLeft ){ m_bIsLeft = bIsLeft; };
inline void Set_MyGoal( Vector MyGoal ){ m_MyGoal = MyGoal; };
inline void Set_OpponentGoal( Vector OpponentGoal ){ m_OpponentGoal = OpponentGoal; };
inline void Set_LeftBackPoint(Vector LeftBackPoint){ m_LeftBackPoint = LeftBackPoint; };
inline void Set_RightBackPoint(Vector RightBackPoint){ m_RightBackPoint = RightBackPoint; };
inline void Set_LeftForwardPoint(Vector LeftForwardPoint){ m_LeftForwardPoint = LeftForwardPoint; };
inline void Set_RightForwardPoint(Vector RightForwardPoint){ m_RightForwardPoint = RightForwardPoint; };
inline double Get_m_Angle(){ return m_Angle; };//得到朝向角
inline double Get_vL(){ return m_vL; };
inline double Get_vR(){ return m_vR; };
inline int Get_Num(){ return m_Num; };
inline BOOL Get_bIsLeft(){ return m_bIsLeft; };
inline Vector Get_MyGoal(){ return m_MyGoal; };
inline Vector Get_OpponentGoal(){ return m_OpponentGoal; };
inline Vector Get_LeftBackPoint(){ return m_LeftBackPoint; };
inline Vector Get_RightBackPoint(){ return m_RightBackPoint; };
inline Vector Get_LeftForwardPoint(){ return m_LeftForwardPoint; };
inline Vector Get_RightForwardPoint(){ return m_RightForwardPoint; };
double DistFromPointToLine(Vector point, Vector pt1, Vector pt2);
// void BasicAct(double R, BOOL bIsRightHand, BOOL bIsLine, double V);
BOOL bIsHaveObstacle(Vector obstacle, Vector destPos );
BOOL AvoidObstacle(Vector obstacle, Vector destPos, Vector& TurnPt);
// BOOL TurnAngle(double angle);
// BOOL TurnAngle2(double angle);
// BOOL TurnTo(Vector v);
// BOOL TurnTo2(Vector v);
// BOOL MoveTo(Vector destPos);
// BOOL GoalKeep(double dist);
// BOOL Shoot(double dist);
// BOOL SendBall(double dist, Vector dest);
private:
int m_Num;//队员标示
double m_vL;//左轮速度
double m_vR;//右轮速度
};
#endif // !defined(AFX_OBJECT_H__1144D1A2_517B_4E0D_A6D3_7F0C44FFAE4A__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -