tank.h
来自「坦克小游戏源码」· C头文件 代码 · 共 57 行
H
57 行
//class for tank
#include "Globe.h"
class CTank
{
public:
float speed; //tank speed
float x,y; //tank poz
float dx,dy;
float friction;
float rotation;
hgeSprite *tank_spr;
CTank(float x,float y,float speed,float friction) //tank construct method
{
this->x = x;
this->y = y;
this->speed = speed;
this->friction = friction;
dx = dy = 0.0;
}
void Forward()
{
dx*=friction; dy*=friction; x+=dx; y+=dy;
}
void Fire() //tank fire method
{
}
void Move(int direction,float dt) //tank move method
{
switch(direction)
{
case 1:
dy -= speed*dt;
rotation = 2*M_PI;
break;
case 2:
dx += speed*dt;
rotation = 2*M_PI*0.25f;
break;
case 3:
dy += speed*dt;
rotation = 2*M_PI*0.5f;
break;
case 4:
dx -= speed*dt;
rotation = 2*M_PI*0.75f;
break;
}
}
void Draw() //tank draw method
{
tank_spr->RenderEx(x,y,rotation);
}
};
CTank *ptank;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?