#include #include "Images_etc.h" #define USE_TI89 // Main Function void _main(void) { char h1=0, h2=110, moov, mv, yb, xb=0, yya, h1a, h2a, fact, fact2, bon, v1, v2, scr1=0, scr2=0, puis, puissa, puis2, puiss2a, alea=0, ch=0, mot[10]; char LCD_BUFFER[LCD_SIZE], result; unsigned char puiss, puiss2, nn=0, nn2=0; short cpt, dur, fin, dur2, dur3, n, xxa, intel, vitesse; float vx, vy, xx, yy; int *pp, pref[5]; short *prefe=&pref; if (pref[4]!=1) {pref[0]=1; pref[1]=1; pref[2]=3; pref[3]=1; pref[4]=1;} INT_HANDLER save_int_1; save_int_1 = GetIntVec (AUTO_INT_1); // désactive les interruptions du clavier SetIntVec (AUTO_INT_1, DUMMY_HANDLER); // Balle rebondissante ! =) deb: xx=45; yy=10; vx=.5; vy=.5; xxa=200; yya=110; for (n=0;n<=500;n++) { if (yy<=1 || yy>=88) vy=-vy; if (xx<=0 || xx>=158) vx=-vx; xx=xx+vx; yy=yy+vy; for (cpt=0 ; cpt<=500 ; cpt++) {} Sprite8(xxa, yya, 5, &balle, LCD_MEM, SPRT_XOR); Sprite8(xx, yy, 5, &balle, LCD_MEM, SPRT_XOR); xxa=xx; yya=yy; } // Menu menu: GrayOn(); for (n=1;n<=25;n++) { GraySetAMSPlane(LIGHT_PLANE); BitmapPut(160-n*6.4, n*4-100, &menu2, ScrRect, A_REPLACE); GraySetAMSPlane(DARK_PLANE); BitmapPut(160-n*6.4, n*4-100, &menu1, ScrRect, A_REPLACE); } FontSetSys(F_4x6); for (n=159;n>=0;n--) { for (cpt=0 ; cpt<=1590-n*10 ; cpt++) {} ScrRectFill(&(SCR_RECT){{n,94,159,99}},&(SCR_RECT){{0, 93, 159, 99}},A_REVERSE); Sprite8(n, 94, 5, &balle, LCD_MEM, SPRT_OR); } DrawStr (n+7,95,"Palet ~ Louis DURAND (c) 2011 ",A_REPLACE); h1=0; h2=110; while (1) { if (_keytest(RR_2ND) || _keytest(RR_ENTER)) { while (_keytest(RR_2ND) || _keytest(RR_ENTER)){} GrayOff(); if (ch==0) goto mode; else if (ch==1) goto options; else goto approp; } else if (_keytest(RR_UP)) {while (_keytest(RR_UP)){} if (ch==0) ch=2; else ch--;} else if (_keytest(RR_DOWN)) {while (_keytest(RR_DOWN)){} ch=fmod(ch+1,3);} else if (_keytest(RR_PLUS)) {OSContrastUp(); while (_keytest(RR_PLUS)){}} else if (_keytest(RR_MINUS)) {OSContrastDn(); while (_keytest(RR_MINUS)){}} else if (_keytest(RR_ESC)) { while (_keytest(RR_ESC)){} GrayOff(); goto quit; } if (ch==0) {xx=20; yy=30; xxa=35; yya=10;} else if (ch==1) {xx=80; yy=40; xxa=48; yya=10;} else {xx=61; yy=62; xxa=16; yya=10;} for (cpt=0 ; cpt<=5000 ; cpt++) {} Sprite8(h1, h2, 5, &balle, LCD_MEM, SPRT_XOR); h1=xx+random(xxa); h2=yy+random(yya); Sprite8(h1, h2, 5, &balle, LCD_MEM, SPRT_XOR); } // Choix mode multijoueur mode: for (cpt=0;cpt<=159;cpt++) {DrawLine(cpt,0,cpt,99,A_XOR); DrawLine(159-cpt,0,159-cpt,99,A_XOR);} SetIntVec (AUTO_INT_1, save_int_1); HANDLE menu_p = PopupNew ("~ M o d e ~", 50); PopupAddText(menu_p, -1, "Contre calculette", 1); PopupAddText(menu_p, -1, "2 joueurs on calc", 2); result = PopupDo (menu_p, CENTER, CENTER, 0); HeapFree (menu_p); SetIntVec (AUTO_INT_1, DUMMY_HANDLER); if (result==0) goto menu; // Jeu jeu: vitesse=(pref[2]-1)*1500; scr1=0; scr2=0; while (scr1<5 && scr2<5) { ClrScr(); DrawLine(0,0,159,0,A_NORMAL); DrawLine(0,93,159,93,A_NORMAL); for (n=0 ; n<=4 ; n++) { DrawClipEllipse(3+n*6,97,2,2,&(SCR_RECT){{0, 93, 159, 99}},A_NORMAL); if (n0)) {if (yy>3 && yy<86) {yy=yy+random(5)-2;xx=xx+random(5)-2;}} } if (cpt==dur3) { dur3=0; Sprite8(96,94,6,&tibon7,LCD_MEM,SPRT_XOR); } else if (dur3!=0) { if ((mv==1 && vx<0) || (mv==2 && vx>0)) vy=vy+0.1; } if (bon!=0) // test des bonus { if (abs(xb+5-xx)<=7 && abs(yb+5-yy)<=7) { if (bon==1) { if (vx<0) moov=1; else moov=2; dur=fmod(cpt+50+random(60),600)+1; Sprite8(60,94,6,&tibon1,LCD_MEM,SPRT_OR); } else if (bon==2) { if (vx<0) {v1=7; v2=3;} else {v1=3; v2=7;} dur=cpt; Sprite8(69,94,6,&tibon2,LCD_MEM,SPRT_OR); } else if (bon==3) { if (vx<0) h1=random(75)+1; else h2=random(75)+1; } else if (bon==4) { yy=random(87)+1; vy=random(7)-3; if (vx>0) vx=random(2)+1; else vx=-random(2)-1; } else if (bon==5) { BitmapPut(78, 1, &mur, ScrRect, A_XOR); fin=fmod(cpt+random(10)*50+100,600)+1; Sprite8(78,94,6,&tibon5,LCD_MEM,SPRT_OR); } else if (bon==6) { if (vx<0) mv=1; else mv=2; dur2=fmod(cpt+random(10)*50+100,600)+1; Sprite8(87,94,6,&tibon6,LCD_MEM,SPRT_OR); } else if (bon==7) { if (vx<0) mv=1; else mv=2; dur3=fmod(cpt+random(10)*50+100,600)+1; Sprite8(96,94,6,&tibon7,LCD_MEM,SPRT_OR); } bon=0; Sprite16(xb, yb, 15 , pp, LCD_MEM, SPRT_XOR); } } if (nn>7) fact=3; else fact=1; if (moov!=1) { if (_keytest(RR_UP) && h1>1) { h1=h1-fact; nn++; } else if (_keytest(RR_DOWN) && h1<76) { h1=h1+fact; nn++; } else nn=0; if (_keytest(RR_2ND) && puiss>20 && pref[3]==1) {puis=puis+3; puiss=puiss-20; DrawLine(55,97,35+puiss/10,97,A_REVERSE);} } // puissance dans le palet [2ND] if (puis!=0) puis--; if (puiss!=200) puiss++; DrawLine(35,97,35+puiss/10,97,A_NORMAL); if (moov!=2) { if (result!=2) { intel = yy+vy*(146-xx)/vx; if (intel >= h2+7 && intel < 88) h2=h2+random(3); else if (intel <= h2+7 && intel > 0) h2=h2-random(3); else if (yy > h2+7) h2=h2+1; else if (yy < h2+7) h2=h2-1; if (xx<100) alea=0; if (xx>120 && random(10)==1) alea=1; if (alea==1 && puiss2>20 && pref[3]==1) {puis2=puis2+3; puiss2=puiss2-20; DrawLine(104,97,124-puiss2/10,97,A_REVERSE);} } else // Joueur 2 humain { if (nn2>7) fact2=3; else fact2=1; if ((_keytest(RR_MINUS) || _keytest(RR_MULTIPLY)) && h2>1) { h2=h2-fact2; nn2++; } else if (_keytest(RR_PLUS) && h2<76) { h2=h2+fact2; nn2++; } else nn2=0; if (_keytest(RR_NEGATE) && puiss2>20 && pref[3]==1) {puis2=puis2+3; puiss2=puiss2-20; DrawLine(104,97,124-puiss2/10,97,A_REVERSE);} } } // puissance dans le palet de l'adversaire if (puis2!=0) puis2--; if (puiss2!=200) puiss2++; DrawLine(124,97,124-puiss2/10,97,A_NORMAL); if (xx<=8+puis && xx>=puis && abs(yy-h1-7)<=12) { vy=(yy-h1-7)/v1; vx=(11-abs((yy-h1-7)/2))/v1; vy=vy+puis*vy/30; vx=vx+puis*vx/30; } else if (xx>=146-puis2 && xx<=159-puis2 && abs(yy-h2-7)<=12) { vy=(yy-h2-7)/v2; vx=-(11-abs((yy-h2-7)/2))/v2; vy=vy+puis2*vy/30; vx=vx+puis2*vx/30; } if (yy<=1 || yy>=88) vy=-vy; if (xx<=0 || xx>=158) goto fin; if (_keytest(RR_ESC)) { LCD_save(&LCD_BUFFER); while (_keytest(RR_ESC)){} SetIntVec (AUTO_INT_1, save_int_1); HANDLE menu_p = PopupNew ("~ P a u s e ~", 50); PopupAddText(menu_p, -1, "Continuer", 1); PopupAddText(menu_p, -1, "Recommencer", 2); PopupAddText(menu_p, -1, "Éteindre", 3); PopupAddText(menu_p, -1, "Quitter", 4); short result = PopupDo (menu_p, CENTER, CENTER, 0); HeapFree (menu_p); SetIntVec (AUTO_INT_1, DUMMY_HANDLER); if (result==2) goto jeu; else if (result==3) off(); else if (result==4) goto deb; LCD_restore(&LCD_BUFFER); message("Prêt ? =)",45,70); } xx=xx+vx; yy=yy+vy; Sprite8(xxa, yya, 5, &balle, LCD_MEM, SPRT_XOR); Sprite8(xx, yy, 5, &balle, LCD_MEM, SPRT_XOR); xxa=xx; yya=yy; Sprite8(puissa, h1a, 17, &palet1, LCD_MEM, SPRT_XOR); Sprite8(puis, h1, 17, &palet1, LCD_MEM, SPRT_XOR); h1a=h1; puissa=puis; Sprite8(151-puiss2a, h2a, 17, &palet2, LCD_MEM, SPRT_XOR); Sprite8(151-puis2, h2, 17, &palet2, LCD_MEM, SPRT_XOR); h2a=h2; puiss2a=puis2; for (n=0 ; n<=vitesse ; n++) { } } bon=random(7)+1; yb=random(80); xb=random(105)+20; if (bon==1) pp=&bon1; else if (bon==2) pp=&bon2; else if (bon==3) pp=&bon3; else if (bon==4) pp=&bon4; else if (bon==5) pp=&bon5; else if (bon==6) pp=&bon6; else if (bon==7) pp=&bon7; Sprite16(xb, yb, 15 , pp, LCD_MEM, SPRT_XOR); } fin: if (xx>80) { DrawClipEllipse(3+scr1*6,97,1,1,&(SCR_RECT){{0, 93, 159, 99}},A_NORMAL); message("Gagné !",10,random(80)); scr1++; } else { DrawClipEllipse(156-scr2*6,97,1,1,&(SCR_RECT){{0, 93, 159, 99}},A_NORMAL); message("Gagné !",90,random(80)); scr2++; } } FontSetSys(F_8x10); if (scr1==5) DrawStr(20,45,"Bravo Joueur 1 !",A_XOR); else DrawStr(20,45,"Bravo Joueur 2 !",A_XOR); message("=)",72,65); goto deb; options: SetIntVec (AUTO_INT_1, save_int_1); HANDLE opt = DialogNewSimple(150,75); HANDLE fond = PopupNew(NULL,0); HANDLE neg = PopupNew(NULL,0); HANDLE vit = PopupNew(NULL,0); HANDLE imp = PopupNew(NULL,0); PopupAddText(fond,-1,"Classique",1); PopupAddText(fond,-1,"Bienheureux",2); PopupAddText(fond,-1,"Sableux",3); PopupAddText(fond,-1,"Rien",4); PopupAddText(neg,-1,"Blanc",1); PopupAddText(neg,-1,"Noir",2); PopupAddText(vit,-1,"Lente",5); PopupAddText(vit,-1,"Moyenne",4); PopupAddText(vit,-1,"Normale",3); PopupAddText(vit,-1,"Rapide",2); PopupAddText(vit,-1,"Très rapide",1); PopupAddText(imp,-1,"Autoriser",1); PopupAddText(imp,-1,"Ne pas autoriser",2); DialogAddTitle(opt,"Options de jeu",BT_SAVE,BT_NONE); DialogAddPulldown(opt,5,15,"Terrain :",fond,0); DialogAddPulldown(opt,5,24,"Négatif ?",neg,1); DialogAddPulldown(opt,5,33,"Vitesse :",vit,2); DialogAddPulldown(opt,5,42,"Impulsions palet :",imp,3); DialogDo(opt,CENTER,CENTER,NULL,prefe); HeapFree(opt); HeapFree(fond); HeapFree(neg); HeapFree(vit); HeapFree(imp); SetIntVec (AUTO_INT_1, DUMMY_HANDLER); goto menu; approp: SetIntVec (AUTO_INT_1, save_int_1); HANDLE dial = DialogNewSimple(135,80); DialogAddTitle(dial,"~o Palet o~",BT_NONE,BT_NONE); DialogAddText(dial,25,15,"Louis DURAND (c) 2011"); DialogAddText(dial,40,30,"FRANCE 54"); DialogAddText(dial,0,45,"S'il y a un souci :"); DialogAddText(dial,0,53,"Rendez-vous sur le forum de TI BANK !"); DialogAddText(dial,3,63,"Programmé en C grâce à TIGCC v0.95"); DialogDo(dial,CENTER,CENTER,NULL,NULL); HeapFree(dial); HANDLE dial2 = DialogNewSimple(135,80); DialogAddTitle(dial2,"~o Les touches o~",BT_NONE,BT_NONE); DialogAddText(dial2,0,15,"> Haut et Bas pour bouger"); DialogAddText(dial2,0,23,"> [2nd] pour donner des impulsions !"); DialogAddText(dial2,0,35," Pour le joueur 2 :"); DialogAddText(dial2,0,43,"> [+] et ([-] ou [*]) pour bouger"); DialogAddText(dial2,0,51,"> [(-)] pour donner des impulsions !"); DialogAddText(dial2,0,63,"et [MAJ] pour passer les messages"); DialogDo(dial2,CENTER,CENTER,NULL,NULL); HeapFree(dial2); DlgMessage("~o Palet o~"," Amusez-vous bien ! =)",BT_YES,BT_YES); SetIntVec (AUTO_INT_1, DUMMY_HANDLER); goto menu; quit: for (cpt=0;cpt<=258;cpt++) { DrawClipLine(&(WIN_RECT){0,cpt,cpt,0},ScrRect,A_XOR); DrawClipLine(&(WIN_RECT){0,258-cpt,258-cpt,0},ScrRect,A_XOR); } SetIntVec (AUTO_INT_1, save_int_1); //réactive les interruptions clavier }