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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
| while(continuer)
{
tempsEcoule = SDL_GetTicks();
if(SDL_PollEvent(&event) == NULL)
{
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelA == persoA[PERSOA3])
{
persoAactuelA = persoA[PERSOA0];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelA == persoA[PERSOA0])
{
persoAactuelA = persoA[PERSOA1];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelA == persoA[PERSOA1])
{
persoAactuelA = persoA[PERSOC2];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelA == persoA[PERSOA2])
{
persoAactuelA = persoA[PERSOA3];
tempsPrecedent = tempsEcoule +70;
}
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
SDL_BlitSurface(persoAactuelA, NULL, ecran, &position);
SDL_Flip(ecran);
}
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
continuer = 0;
break;
case SDLK_RIGHT:
tempsEcoule = SDL_GetTicks();
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC5])
{
persoAactuelL = persoCL[PERSOC0];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC0])
{
persoAactuelL = persoCL[PERSOC1];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC1])
{
persoAactuelL = persoCL[PERSOC2];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC2])
{
persoAactuelL = persoCL[PERSOC3];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC3])
{
persoAactuelL = persoCL[PERSOC4];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelL == persoCL[PERSOC4])
{
persoAactuelL = persoCL[PERSOC5];
tempsPrecedent = tempsEcoule +70;
}
position.x ++;
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
SDL_BlitSurface(persoAactuelL, NULL, ecran, &position);
SDL_Flip(ecran);
break;
case SDLK_LEFT:
tempsEcoule = SDL_GetTicks();
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC5])
{
persoAactuelR = persoCR[PERSOC0];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC0])
{
persoAactuelR = persoCR[PERSOC1];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC1])
{
persoAactuelR = persoCR[PERSOC2];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC2])
{
persoAactuelR = persoCR[PERSOC3];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC3])
{
persoAactuelR = persoCR[PERSOC4];
tempsPrecedent = tempsEcoule +70;
}
if((tempsEcoule - tempsPrecedent > 55) && persoAactuelR == persoCR[PERSOC4])
{
persoAactuelR = persoCR[PERSOC5];
tempsPrecedent = tempsEcoule +70;
}
position.x --;
SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 0, 0, 0));
SDL_BlitSurface(persoAactuelR, NULL, ecran, &position);
SDL_Flip(ecran);
break;
}
break;
}
} |
Partager