求高手指教用c语言和sdl写的游戏代码出现的问题,急急急!!!
#include "SDL/SDL.h"
const int SCREEN_WIDTH=800;
const int SCREEN_HEIFHT=750;
const int SCREEN_CPP=32;
const int PICTUREWIDTH=320;
const int PICTUREHEIGHT=240;
SDL_Surface *backgroundPtr=NULL;
SDL_Surface *screen=NULL;
SDL_Surface *brickptr=NULL;
typedef struct
{
short brick_x[4];
short brick_y[4];
}BRICK;
BRICK brick;
/************************************************************************/
/* 初始化sdl */
/************************************************************************/
bool InitSDL()
{
if(SDL_Init (SDL_INIT_EVERYTHING)==-1)
{
return false;
}
screen=SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIFHT,SCREEN_CPP,SDL_SWSURFACE|SDL_DOUBLEBUF);
if(screen==NULL)
{
return false;
}
SDL_WM_SetCaption("Tetris Game","software");
return true;
}
/************************************************************************/
/* 加载图片 */
/************************************************************************/
void InitImages()
{
SDL_Surface *temp;
char fileName[20];
/*int i;*/
//加载背景图片
sprintf(fileName,"bg.bmp");
temp=SDL_LoadBMP(fileName);
if (temp==NULL)
{
fprintf(stderr,"%s,%s\n",fileName,SDL_GetError());
return;
}
backgroundPtr=SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
//加载砖块的图片
sprintf(fileName,"1.bmp");
temp=SDL_LoadBMP(fileName);
if (temp==NULL)
{
fprintf(stderr,"%s,%s\n",fileName,SDL_GetError());
return;
}
backgroundPtr=SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
}
/************************************************************************/
/* show images */
/************************************************************************/
void ShowImage(SDL_Surface *source,int left,int top,int width,int height,SDL_Surface *destination)
{
SDL_Rect picPosition;
picPosition.x=left;
picPosition.y=top;
picPosition.w=(width==0)?source-> w:width;
picPosition.h=(height==0)?source->h:height;
SDL_BlitSurface(source,NULL,destination,&picPosition);
}
/************************************************************************/
/* 显示砖块和背景 */
/************************************************************************/
void showPic()
{
ShowImage (backgroundPtr,0,0,0,0,screen);
SDL_Flip(screen);
};
int main(int argc,char*arg[])
{
/*SDL_Event event;*/
showPic();
InitSDL();
InitImages();
}
以上的代码不知道哪里出错了,请大牛帮忙看一下,万分感谢!
1>------ 已启动生成: 项目: sdl, 配置: Debug Win32 ------
1>正在编译...
1>sdl.cpp
1>d:\c语言\code\代码\sdl\sdl\sdl.cpp(51) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\vs\vc\include\stdio.h(366) : 参见“sprintf”的声明
1>d:\c语言\code\代码\sdl\sdl\sdl.cpp(61) : warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> d:\vs\vc\include\stdio.h(366) : 参见“sprintf”的声明
1>d:\c语言\code\代码\sdl\sdl\sdl.cpp(110) : error C4716: “SDL_main”: 必须返回一个值
1>生成日志保存在“file://d:\c语言\code\代码\sdl\sdl\Debug\BuildLog.htm”
1>sdl - 1 个错误,2 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========