标签:
观看正月点灯笼的SDL教程,地址http://www.tudou.com/listplay/9eG9tkk91oQ.html
#include <stdio.h> #include <stdlib.h> #include <SDL.h> #include <SDL_image.h> int main(int argc, char *argv[]) { SDL_Init(SDL_INIT_VIDEO); { SDL_Window * window = SDL_CreateWindow("First Window Program", //标题 SDL_WINDOWPOS_UNDEFINED, //窗口距离屏幕左边的长度 SDL_WINDOWPOS_UNDEFINED, //窗口距离屏幕上边的长度 800,600, // width ,height SDL_WINDOW_SHOWN ); SDL_Rect rect; int i; SDL_Surface *surface = SDL_GetWindowSurface(window); //SDL_Surface *image = SDL_LoadBMP("sample.bmp"); SDL_Surface *image = IMG_Load("peo.png"); rect.x = 0; rect.y = 0; for (i=1; i<=3; i++){ SDL_BlitSurface(image, //要贴的图片 NULL, //拷贝矩形的高度和宽度由这个参数确定 surface, //贴在哪个的表面 &rect); //图片和窗口左上角的相对距离 rect.x += 200; } SDL_UpdateWindowSurface(window); SDL_Delay(5000); //让窗口存在多久 SDL_FreeSurface(surface); SDL_FreeSurface(image); SDL_DestroyWindow(window); SDL_Quit(); } return 0; }
标签:
原文地址:http://www.cnblogs.com/jiasheng/p/5434687.html