我試圖在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