0
我收到错误:
错误C2440:初始化:不能从“诠释”转化为“const的球员
错误C2628:‘球员’,然后‘廉政’是非法的(没你忘了';'?)
从第5行,const int WIDTH = 1280
但我不明白我做错了什么。播放器结构产生C2440错误
我声明:
#include <allegro5\allegro.h>
#include <allegro5\allegro_primitives.h>
#include "objects.h"
const int WIDTH = 1280;
const int HEIGHT = 720;
const float GRAVITY = 1.5;
const float FORCE = 1.4;
const float K = 0.25;
enum KEYS{UP, DOWN, LEFT, RIGHT, SPACE};
bool keys[5] = {false, false, false, false, false};
void InitPlayer();
void DrawPlayer();
Player player;
InitPlayer功能:
void InitPlayer() {
player.x = 0;
player.y = HEIGHT - 20;
player.vy = 0;
player.vx = 0;
player.fx = 0;
player.jumping = false;
}
播放器的结构:
struct Player {
float x;
float y;
float fx;
float vx;
float vy;
int direction;
bool jumping;
void Jump() {
if(!jumping) {
vy = -15;
jumping = true;
}
}
}