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

📄 ball.h

📁 C人工智能游戏开发的一些实例源代码 C Game development in artificial intelligence source code of some examples
💻 H
字号:
//----------------------------------------------------------------------------------------------
// Sequential Prediction Demo: The positioning pattern
// 
// Author:  Fri Mommersteeg
// Date:    10-09-2001
// File:    Ball.h
//----------------------------------------------------------------------------------------------

#ifndef __TENNISBALL_H
#define __TENNISBALL_H

//----------------------------------------------------------------------------------------------
// Include files
//----------------------------------------------------------------------------------------------

#include "directdraw.h"
#include "observer.h"

//----------------------------------------------------------------------------------------------
// Defined constants
//----------------------------------------------------------------------------------------------

#define GROUND_ACCELERATION		0.1f
#define GROUND_FRICTION			1.5f
#define BALL_SIZE				5
#define OWNER_SERVICE			0
#define UPWARD_BOUNCE_FORCE		3

//----------------------------------------------------------------------------------------------
// CTennisBall: Represents the tennis ball
//----------------------------------------------------------------------------------------------

class CTennisBall : public CSubject {
public:
				CTennisBall() { 
					px = py = pz = vx = vy = vz = 0;
				}

				~CTennisBall() {
				}

	void		Update();
	void		SetPosition(float x, float y, float z) { px = x; py = y; pz = z; }
	void		SetVelocity(float x, float y, float z) { vx = x; vy = y; vz = -z; }
	void		Paint(LPDDS lpdds);
	void		GetBoundingRect(RECT * lpRect);
	int			GetHeight() { return (int)pz; }
	void		GetPosition(POINT & pt) { pt.x = (int)px; pt.y = (int)py; }
	void		SetOwner(int BallOwner) { owner = BallOwner; }
	int			GetOwner() { return owner; }	
	void		GetBouncePosition(POINT & pt) { pt = BouncePosition; } // used by AI
	void		BounceBall(float x, float y);

protected:
	
	void		ApplyVelocity();
	void		ApplyGroundForce();
	void		InterpolateToBouncePosition(POINT & pt); 

protected:
	int			owner;
	float		px, py, pz;
	float		vx, vy, vz;	
	POINT		BouncePosition;
};

//----------------------------------------------------------------------------------------------
#endif // __TENNISBALL_H

⌨️ 快捷键说明

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