player.h
来自「一本关于OPenGL的很好的电子书」· C头文件 代码 · 共 61 行
H
61 行
#ifndef __PLAYER_H
#define __PLAYER_H
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include "object.h"
#include "vector.h"
#include "table.h"
#include "puck.h"
static float playerData[32][3] =
// bottom points
{ { 0.0, 0.01, 1.0 }, { 0.3827, 0.01, 0.9239 },
{ 0.7071, 0.01, 0.7071 }, { 0.9239, 0.01, 0.3827 }, { 1.0, 0.01, 0.0 },
{ 0.9239, 0.01, -0.3827 }, { 0.7071, 0.01, -0.7071 }, { 0.3827, 0.01, -0.9239 },
{ 0.0, 0.01, -1.0 }, { -0.3827, 0.01, -0.9239 }, { -0.7071, 0.01, -0.7071 },
{ -0.9239, 0.01, -0.3827 }, { -1.0, 0.01, 0.0 }, { -0.9237, 0.01, 0.3827 },
{ -0.7071, 0.01, 0.7071 }, { -0.3827, 0.01, 0.9239 },
// top points
{ 0.0, 0.8, 1.0 }, { 0.3827, 0.8, 0.9239 },
{ 0.7071, 0.8, 0.7071 }, { 0.9239, 0.8, 0.3827 }, { 1.0, 0.8, 0.0 },
{ 0.9239, 0.8, -0.3827 }, { 0.7071, 0.8, -0.7071 }, { 0.3827, 0.8, -0.9239 },
{ 0.0, 0.8, -1.0 }, { -0.3827, 0.8, -0.9239 }, { -0.7071, 0.8, -0.7071 },
{ -0.9239, 0.8, -0.3827 }, { -1.0, 0.8, 0.0 }, { -0.9237, 0.8, 0.3827 },
{ -0.7071, 0.8, 0.7071 }, { -0.3827, 0.8, 0.9239 } };
class CPlayer : public CObject
{
private:
float radius;
int oldMouseX;
int oldMouseY;
public:
CPlayer()
{
acceleration = CVector(0.0, 0.0, 0.0);
velocity = CVector(0.0, 0.0, 0.0);
position = CVector(150.0, 0.0, -110.0);
oldMouseX = 0;
oldMouseY = 0;
radius = size = 10.0;
}
~CPlayer() {}
void Draw();
void Load();
void Unload();
void Animate(scalar_t deltaTime);
void Move(scalar_t deltaTime, int mouseX, int mouseY, CTable *table, CPuck *puck);
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?