1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include <stdio.h>
#include <SDL/SDL.h>
SDL_Surface *ecran, *image1, *image2;
void init(void)
{
SDL_Init(SDL_INIT_VIDEO);
ecran = SDL_SetVideoMode(800, 600, 32, SDL_HWSURFACE);
image1 = SDL_LoadBMP("image1.bmp");
imege2 = SDL_LoadBMP("image2.bmp");
}
void deplacer(void)
{
SDL_Rect positionimage1, positionimage2;
int dX = 1, dY = 1;
positionimage1.x = 0;
positionimage1.y = 0;
positionimage2.x = 0;
positionimage2.y = 200;
while (1) {
SDL_BlitSurface(image1, NULL, ecran, &positionZozor);
SDL_BlitSurface(image2, NULL, ecran, &positionZozor);
if (dX) {
positionimage1.x++;
positionimage2.x++;
} else {
positionimage1.x--;
positionimage2.x++;
}
if (avanceY) {
positionimage1.y++;
positionimage2.y++;
} else {
positionimage1.y--;
positionimage2.y--;
}
SDL_Flip(ecran);// affichage à l'ecran
}
}
int main(void)
{
init();
deplacer();
return 0;
} |
Partager