ball.cpp

来自「一本关于OPenGL的很好的电子书」· C++ 代码 · 共 25 行

CPP
25
字号
#include "ball.h"

// Draw()
// desc: draws the ball at its current location
void CBall::Draw()
{
	glPushMatrix();
		glTranslatef(position.x, position.y, position.z);
		glColor3f(0.5, 0.5, 0.5);
		auxSolidSphere(radius);
	glPopMatrix();
}

// Animate()
// desc: handles the physics calculations
void CBall::Animate(scalar_t deltaTime)
{
	acceleration = CVector(0.0, -9.8, 0.0);
	velocity = velocity + (acceleration * deltaTime);
	position = position + (velocity * deltaTime);
}

//void CBall::Animate(scalar_t deltaTime, 

⌨️ 快捷键说明

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