#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <string.h>
#include <math.h>
#include <SDL_draw.h>
int main(){
SDL_Surface *screen = SDL_SetVideoMode(640,640,16,SDL_SWSURFACE);
int x,i;
x=0;
double y;
if(screen == NULL){
fprintf(stderr,"SDL_SetVideoMode error %s\n",SDL_GetError());
exit(1);
}
if(SDL_Init(SDL_INIT_VIDEO) < 0){
fprintf(stderr,"SDL_INIT_VIDEO error %s\n",SDL_GetError());
exit(1);
}
atexit(SDL_Quit);
for (i=0;i<120;i++,x=x+3,y=y+sin(x-80))
{
Draw_Circle(screen,x,y,15,SDL_MapRGB(screen->format, 255,0,0));
SDL_Delay(100);
Draw_Circle(screen,x,y,15,SDL_MapRGB(screen->format, 255,255,255));
Draw_Line(screen,x,y,x+3,y=y+sin(x-80),SDL_MapRGB (screen->format, 255,0,0));
SDL_UpdateRect(screen, 0, 0, 0, 0); /*更新整个屏幕*/ }
return 0;
}
成功运行,实现画一个圆,此圆沿着正弦曲线运动
你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答
本次提问扣除的有问必答次数,已经为您补发到账户,我们后续会持续优化,扩大我们的服务范围,为您带来更好地服务。