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
| #include <allegro.h>
#include <math.h>
int main(void)
{
/* BITMAP *bmp;*/
const int x1=150;
const int y1=50;
const int x2=490;
const int y2=200;
int y3=440;
int y4=455;
int c1=320;
/* int c2=430;*/
const int L=640;
const int H=480;
int i,j,noir,blanc,rouge,degrade,e,f,raquette,x,x3,x4,I,J,ab,or;
/*float r;*/
e=150;
f=50;
allegro_init();
install_keyboard();
/*jpgalleg_init();*/
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED,L,H,0,0);
blanc=makecol(255,255,255);
noir=makecol(0,0,0);
rouge=makecol(255,0,0);
clear_to_color(screen,blanc);
/* bmp = load_jpg("jpgalleg.jpg", NULL);*/
for(I=150;I<470;I++)//degrade de couleur dans le cadre
{
for(J=50;J<180;J++)
{
degrade=makecol(or,ab,0);
rectfill(screen,I,J,I+20,J+20,degrade);// établissement de la zone a atteindre
ab=(255*I)/320;
or=(255*J)/240;
ab=ab+138;
or=or+205;
}
}
for(i=0;i<10;i++)//lignes horizontales
{
line(screen,e,y1,e,y2,blanc);
e=e+34;
}
for(j=0;j<5;j++)//lignes verticales, avec celle d'avant, ça forme des carrés
{
line(screen,x1,f,x2,f,blanc);
f=f+30;
}
raquette=140; // taille de la raquette
x=raquette;
x3=c1-(x/2);
x4=c1+(x/2);
rectfill(screen,x3,y3,x4,y4,noir); // positionnement de la raquette
while(!key[KEY_ENTER])
{
if(key[KEY_LEFT])//faire translater la raquette a gauche
{
if(x3>0)
{
rectfill(screen,x3,y3,x4,y4,noir);
rest(10);
rectfill(screen,x3,y3,x4,y4,blanc);
x3--;
x4--;
}
}
if(key[KEY_RIGHT])//faire translater la raquette a droite
{
if(x4<L)
{
rectfill(screen,x3,y3,x4,y4,noir);
rest(10);
rectfill(screen,x3,y3,x4,y4,blanc);
x3++;
x4++;
}
}//a enlever pr bouger rakette + balle simultanément
rectfill(screen,x3,y3,x4,y4,noir);
/*blit(bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h);
destroy_bitmap(bmp);
*/
}
readkey();
return 0;
}
//END_OF_MAIN() |
Partager