我试图在C和SDL中创建一个小型游戏,以有趣的方式开始使用SDL。我会粘贴我的计时器结构和函数,将用于在我的主要游戏循环中封顶fps。在总共约25个错误地狱般的语法错误
这是的,但我得到了很多的“预期‘(’跟随‘T’错误C2054”:?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
struct Timer {
int startTicks;
int pausedTicks;
int paused;
int started;
};
void Init(Timer *t)
{
t->startTicks = 0;
t->pausedTicks = 0;
t->paused = 0;
t->started = 0;
}
void StartTimer(Timer *t)
{
t->started = 1;
t->paused = 0;
t->startTicks = SDL_GetTicks();
}
void StopTimer(Timer *t)
{
t->started = 0;
t->paused = 0;
}
void PauseTimer(Timer *t)
{
if(t->started == 1 && t->paused == 0)
{
t->paused = 1;
t->pausedTicks = SDL_GetTicks() - t->startTicks;
}
}
void UnpauseTimer(Timer *t)
{
if(t->paused == 1)
{
t->paused = 0;
t->startTicks = SDL_GetTicks() - t->pausedTicks;
t->pausedTicks = 0;
}
}
int GetTicks(Timer *t)
{
if(t->started == 1)
{
return t->pausedTicks;
}
else
{
return SDL_GetTicks() - t->startTicks;
}
return 0;
}
请告诉我错在这里先感谢!
是否找到了所有包含的文件? –
请仔细阅读错误信息 - 哪一行是“错误C2054”?我会开始寻找错误:) – kol