📄 cprojectile.cpp
字号:
//Tanks
//Copyright John Manslow
//29/09/2001
#include "stdafx.h"
#include "CProjectile.h"
#include "math.h"
const double dGravity=0.1;
const double dFriction=0.997;
CProjectile::CProjectile(const double dNewxPosition,
const double dNewyPosition,
const double dNewHeadingX,
const double dNewHeadingY)
{
TRACE("\t\tCreating projectile...");
//Record the parameters of the projectile:
//Its current position,
dxPosition=dNewxPosition;
dyPosition=dNewyPosition;
//its position at the end of the previous time step,
dPreviousxPosition=dxPosition;
dPreviousyPosition=dyPosition;
//and the x and y components of its velocity.
dSpeedx=dNewHeadingX;
dSpeedy=dNewHeadingY;
TRACE("successful.\n");
}
CProjectile::~CProjectile()
{
TRACE("\t\tDestroying projectile...");
TRACE("successful.\n");
}
void CProjectile::TimeStep(const double dWindSpeed)
{
//Record its current position as its old position
dPreviousxPosition=dxPosition;
dPreviousyPosition=dyPosition;
//Update the projectile's position
dxPosition+=dSpeedx;
dyPosition+=dSpeedy;
//Update the projectile's velocity. If this model changes, the neural network may have to
//be retrained
dSpeedy-=dGravity;
dSpeedy*=dFriction;
dSpeedx+=(dWindSpeed-dSpeedx)*(1.0-dFriction);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -