linux制作SDL小游戏,(下载)SDL小游戏:打鼹鼠 BeatMole

# re: (下载)SDL小游戏:打鼹鼠 BeatMole 2008-06-07 08:18 tan

#include

#include

SDL_Surface *screen;

void Init_SDL()

{

if(SDL_Init(SDL_INIT_VIDEO) < 0)

{

fprintf(stderr,"cannot init SDL: %s",SDL_GetError());

exit(1);

}

screen=SDL_SetVideoMode(640,480,16,SDL_SWSURFACE);

if(screen==NULL)

{

fprintf(stderr,"Error:%s\n",SDL_GetError());

exit(1);

}

//atexit(SDL_Quit);

}

int main()

{

SDL_Surface *text;

SDL_Rect dest_rect;

TTF_Font *font;

SDL_Color green={0,255,0,0};

int fontsize=38;

Init_SDL();

if(TTF_Init()!=0)

{

fprintf(stderr,"cannot init ttf font!\n");

exit(1);

}

font=TTF_OpenFont("/usr/share/fonts/simsum.ttf",fontsize);

TTF_SetFontStyle(font,TTF_STYLE_NORMAL);

text=TTF_RenderUTF8_Blended(font,"Turetype 中文文字显示",green);

if(text==NULL)

{

fprintf(stderr,"cannot render ttf text\n");

exit(1);

TTF_CloseFont(font);

TTF_Quit();

dest_rect.x=100;

dest_rect.y=200;

dest_rect.w=text->w;

dest_rect.h=text->h;

SDL_BlitSurface(text,NULL,screen,&dest_rect);

SDL_UpdateRect(screen,0,0,0,0);

SDL_FreeSurface(text);

SDL_Delay(5000);

}

}

这是linux下的一段小代码,实现ttf显示中文,我装了ttf库(我也装了ttf的开发工具)

[root@localhost sdl]# gcc a.c -lSDL

/tmp/ccEFNb8t.o: In function `main':

a.c:(.text+0xba): undefined reference to `TTF_Init'

a.c:(.text+0xf0): undefined reference to `TTF_OpenFont'

a.c:(.text+0x102): undefined reference to `TTF_SetFontStyle'

a.c:(.text+0x113): undefined reference to `TTF_RenderUTF8_Blended'

collect2: ld 返回 1

是不是i386的工具rpm包,在x86_86机器上不行阿,如果不行还望提示一个下载地址。  回复  更多评论

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值