j'ai repris son code que j'ai a peine modifié pour que celui-ci accepte les data
ben parcequ'il y a un temps certain j'avais fait un enregistreur de chemin pour sprite 2D
voici qui est reparé ; j'ai utilise le programme du soldat pour servir de cobaye niark ! niaark !
et voila comment on ne se prend pas la tete a faire un tableau avec des sprite au chemins "precalculé"
Code : Tout sélectionner
; Auteur : Le Soldat Inconnu
; Version de PB : 3.90
;
; Explication du programme :
; Dessiner un serpent de boule qui suit la souris
; Dimension du screen
#EcranX = 1024
#EcranY= 768
#NbBoule = 100 ; Nombre de boule
compteur=#NbBoule*4
#RayonBoule = 17 ; diamètre des boules
#Vitesse.f = 0.2 ; Vitesse de déplacement des boules
Restore label
Structure BouleInfo ; Contient la position de chaque boule
x.f
y.f
EndStructure
Dim Boule.BouleInfo(#NbBoule)
Procedure DessineBoule(id, Couleur)
; ID : Identifiant du sprite
; Couleur : Couleur RGB de la boule
CreateSprite(id, #RayonBoule * 2 + 1, #RayonBoule * 2 + 1)
StartDrawing(SpriteOutput(id))
Circle(#RayonBoule, #RayonBoule, #RayonBoule, Couleur) ; On dessine une boule
StopDrawing()
EndProcedure
InitSprite()
InitKeyboard()
InitMouse()
OpenScreen(#EcranX, #EcranY, 32, "")
; On crée les sprites qui représentent des boules de couleur de plus en plus claires
For n = 0 To #NbBoule
Coef.f = n / #NbBoule
DessineBoule(n, RGB(255, 165 + (255 - 165) * Coef, 255 * Coef))
Next
; On place la souris au point de départ
;MouseLocate(#RayonBoule, #RayonBoule)
Repeat
ExamineMouse()
ExamineKeyboard()
ClearScreen(0, 0, 0) ; On efface l'écran
; Position de la première boule que l'on calcule avec la souris
; Il s'agit de la boule 0
; Boule(0)\x = MouseX() - #RayonBoule
; Boule(0)\y = MouseY() - #RayonBoule
If fin=0
Read x_dob
EndIf
If x_dob <> 8888
Read y_dob
Else
fin=1
EndIf
;:x_dob =x_dob - #RayonBoule
;:y_dob =y_dob - #RayonBoule
Boule(0)\x =x_dob-#RayonBoule
Boule(0)\y =y_dob-#RayonBoule
For n = #NbBoule To 1 Step -1 ; Pour chaque boule
; On part de la fin afin que la dernière boule soit en dessous des autres
; On calcul la vitesse de déplacement en x de la boule à partir de la distance entre cette boule et la précédente
; Le but est de permettre à cette boule de suivre la précédente
; Et plus la distance entre ces 2 boules est grande et plus elle ira vite pour la rattraper
VitesseX.f = (Boule(n - 1)\x - Boule(n)\x) * #Vitesse
; De même sur les y
VitesseY.f = (Boule(n - 1)\y - Boule(n)\y) * #Vitesse
; On détermine la nouvelle position de la boule
Boule(n)\x + VitesseX
Boule(n)\y + VitesseY
; On affiche la boule
DisplayTransparentSprite(n, Boule(n)\x, Boule(n)\y)
Next
DisplayTransparentSprite(0, Boule(0)\x, Boule(0)\y) ; On affiche la boule qui représente la souris
;DisplayTransparentSprite(2000, x_dob, y_dob) ; On affiche la boule qui représente la souris
; Elle est affiché en dernier pour être au dessus des autres
FlipBuffers()
If fin=1
compteur-1
If compteur=0
End
EndIf
EndIf
Until KeyboardPushed(#PB_Key_Escape)
DataSection
label:
Data.l 6,758,6,758,6,758,6,758,6,758,6,758,6,758,6,758,7,756,7,755
Data.l 7,755,7,754,8,753,8,752,8,750,9,749,9,749,9,748,10,747,10,747
Data.l 10,746,11,745,11,743,12,742,13,741,14,740,14,739,15,737,16,736,17,735
Data.l 18,734,18,733,19,733,20,732,20,731,21,730,22,729,23,728,24,727,25,725
Data.l 27,724,27,723,29,722,30,721,31,720,33,719,34,718,35,716,36,715,38,713
Data.l 40,711,41,710,42,708,43,708,44,706,45,704,46,704,47,702,48,701,50,699
Data.l 52,697,53,695,55,693,56,692,58,688,60,686,61,684,62,681,63,680,66,676
Data.l 68,673,69,671,71,667,73,665,75,661,79,655,81,653,83,648,84,645,86,641
Data.l 88,636,88,634,90,630,92,625,93,623,94,619,94,617,95,613,95,609,96,607
Data.l 96,602,96,599,97,593,98,586,99,583,101,575,103,571,105,562,108,553,109,548
Data.l 111,539,113,535,115,526,117,517,117,513,118,506,119,501,121,494,124,486,125,482
Data.l 127,475,127,471,128,463,129,456,129,452,130,445,131,441,132,434,132,426,133,422
Data.l 134,414,134,410,136,402,137,394,137,390,138,382,139,377,140,368,141,358,142,353
Data.l 143,342,143,337,144,328,145,317,146,312,147,302,148,292,149,288,150,278,151,274
Data.l 152,265,153,256,153,251,155,242,155,238,156,230,159,221,160,217,162,209,163,205
Data.l 165,197,167,189,169,186,171,178,172,175,174,168,176,162,177,158,179,153,180,150
Data.l 183,145,185,141,187,139,189,136,190,135,192,132,194,131,195,130,199,128,201,127
Data.l 205,125,208,123,209,123,213,123,215,122,220,122,225,122,228,122,233,122,236,122
Data.l 241,122,244,122,247,123,252,125,255,125,257,126,257,126,258,126,260,127,261,128
Data.l 262,129,263,130,265,132,267,133,269,135,270,135,272,138,274,140,277,143,280,146
Data.l 281,147,283,150,284,151,287,154,290,156,292,158,295,161,296,162,297,164,298,165
Data.l 300,168,301,170,303,173,305,176,306,178,307,181,308,182,309,184,310,188,310,189
Data.l 311,193,312,195,312,197,312,198,312,199,312,201,312,203,313,208,312,213,312,215
Data.l 312,220,312,223,312,228,312,233,312,236,312,242,312,244,311,250,310,256,310,259
Data.l 309,265,309,267,308,273,306,277,305,279,304,283,303,285,302,289,299,293,298,295
Data.l 295,298,294,300,291,303,287,307,285,309,282,312,281,313,281,313,281,313,281,313
Data.l 280,313,279,315,279,315,278,315,276,316,276,316,276,316,276,316,275,316,274,316
Data.l 273,316,272,316,271,316,271,316,271,316,270,316,269,316,268,316,265,317,262,317
Data.l 260,317,255,317,253,317,251,317,248,317,248,317,246,317,245,317,241,317,240,317
Data.l 237,316,234,317,233,317,231,317,229,316,226,316,223,316,221,316,218,316,216,316
Data.l 212,316,209,316,207,315,204,315,202,315,202,315,202,315,201,315,200,315,198,315
Data.l 197,315,195,315,193,315,191,315,190,315,189,315,187,315,186,315,185,315,184,315
Data.l 183,315,181,315,179,315,178,315,178,315,177,315,176,315,175,315,174,316,174,316
Data.l 173,317,172,317,171,318,170,318,169,319,168,319,168,319,167,320,166,320,166,321
Data.l 165,322,164,322,164,323,164,323,163,323,163,324,162,324,162,324,161,325,161,325
Data.l 160,326,159,326,159,326,158,326,158,327,158,327,158,327,157,327,157,328,157,328
Data.l 157,328,156,329,156,329,155,330,155,330,155,331,155,332,155,332,155,333,154,333
Data.l 154,335,154,336,153,338,153,340,152,342,152,344,150,347,149,351,149,353,148,356
Data.l 148,358,148,359,146,362,146,363,146,364,145,365,145,367,145,368,144,370,143,373
Data.l 143,374,142,377,142,378,141,382,140,385,140,386,139,389,138,390,137,393,137,396
Data.l 136,398,135,401,135,402,134,406,132,410,131,412,130,415,130,417,129,421,128,425
Data.l 127,427,126,430,125,432,125,435,124,438,123,440,122,443,121,446,121,448,121,451
Data.l 121,452,121,455,120,458,120,460,120,464,120,466,119,470,119,474,118,476,118,480
Data.l 117,482,117,487,116,491,116,493,115,498,115,500,114,504,114,507,114,508,113,511
Data.l 113,513,113,516,112,519,112,520,112,523,111,524,110,527,110,529,109,531,109,534
Data.l 109,535,109,538,109,540,109,542,109,545,109,547,109,550,109,553,109,555,109,558
Data.l 109,559,110,562,110,565,111,567,111,569,112,571,113,573,114,576,115,578,117,581
Data.l 119,584,120,585,122,587,123,588,125,590,128,593,130,594,133,597,136,598,141,601
Data.l 147,603,150,605,158,606,161,607,168,609,175,611,179,611,186,612,190,612,196,612
Data.l 203,611,207,609,214,605,217,602,223,597,228,592,230,589,233,583,236,579,239,573
Data.l 241,567,242,564,244,558,245,554,246,549,247,542,247,539,248,533,248,531,248,526
Data.l 248,523,248,521,248,519,248,518,248,517,248,517,248,516,248,516,248,516,248,516
Data.l 248,516,247,516,246,516,245,518,244,522,244,524,244,530,244,533,244,539,244,546
Data.l 245,549,246,555,246,558,247,565,249,572,250,576,252,582,255,587,257,588,259,591
Data.l 261,592,264,595,268,599,269,600,272,603,273,604,276,606,280,609,282,610,286,612
Data.l 287,613,290,614,294,615,296,615,302,615,304,615,309,614,314,612,316,611,320,609
Data.l 322,607,325,605,328,602,330,601,333,596,336,593,339,588,342,583,343,581,345,577
Data.l 346,575,347,571,348,567,349,565,350,561,350,559,351,555,351,550,351,548,352,544
Data.l 352,542,352,537,352,533,352,531,351,526,351,525,351,522,351,520,351,519,351,519
Data.l 351,518,350,518,350,518,350,518,350,518,350,518,350,518,350,518,350,518,350,518
Data.l 350,518,350,518,350,518,350,519,350,520,350,521,349,522,349,523,349,525,349,528
Data.l 349,529,349,531,349,532,349,534,349,537,349,538,349,540,349,541,349,545,349,548
Data.l 350,549,350,553,351,555,352,560,355,566,356,569,359,575,360,577,362,582,365,586
Data.l 367,589,370,592,372,594,376,597,380,601,383,602,389,604,392,606,397,607,400,608
Data.l 402,608,405,608,407,608,412,606,418,604,421,602,429,599,432,597,442,593,450,589
Data.l 455,586,464,580,472,574,476,572,484,565,487,562,493,555,499,549,501,547,505,541
Data.l 508,537,511,531,514,524,515,521,518,514,518,510,520,502,521,494,521,490,523,484
Data.l 523,482,521,476,520,471,519,469,517,466,515,465,512,462,509,459,508,458,504,455
Data.l 503,454,500,452,496,450,492,449,487,447,485,447,482,447,480,447,479,447,478,447
Data.l 477,448,477,449,476,450,476,453,477,454,477,457,479,458,482,461,486,464,488,465
Data.l 493,468,495,468,501,470,507,472,510,472,517,474,520,474,526,474,531,475,534,475
Data.l 543,476,546,477,554,477,559,475,562,474,566,472,568,471,571,468,575,465,576,464
Data.l 580,461,583,458,584,456,588,453,590,452,595,450,598,447,600,446,604,444,606,444
Data.l 612,442,617,441,619,440,626,438,629,437,636,435,643,433,645,433,649,431,650,431
Data.l 652,430,654,428,655,427,657,425,658,424,660,422,660,420,660,419,658,416,657,416
Data.l 653,414,647,413,644,413,637,413,634,413,627,413,620,413,618,414,613,415,612,415
Data.l 608,415,605,417,603,418,601,420,599,422,599,424,597,428,597,430,596,434,595,436
Data.l 595,441,596,445,596,446,596,450,597,454,598,455,599,459,599,461,600,465,601,469
Data.l 601,471,602,475,602,478,603,482,603,486,604,488,605,493,605,495,606,498,606,502
Data.l 607,504,608,508,608,510,609,514,611,519,612,521,613,525,614,527,615,530,617,534
Data.l 617,536,619,539,620,541,622,545,624,550,625,552,626,555,627,556,628,559,630,561
Data.l 630,563,632,565,633,566,635,568,637,571,638,572,639,574,641,576,642,577,643,578
Data.l 645,579,647,581,648,582,652,583,657,584,659,585,664,586,668,586,670,586,675,586
Data.l 677,586,682,585,687,583,689,582,694,579,696,577,701,574,705,571,707,569,710,564
Data.l 711,562,714,556,716,550,716,547,717,542,717,540,717,535,717,531,717,529,717,525
Data.l 717,523,716,519,714,515,714,513,713,509,712,508,711,505,710,502,710,501,710,501
Data.l 710,501,710,501,710,501,710,501,710,501,710,501,711,501,712,502,717,504,724,507
Data.l 728,508,736,512,740,512,747,515,754,517,757,517,764,519,767,520,773,522,779,523
Data.l 783,523,790,524,794,524,802,525,810,525,813,525,820,523,823,522,830,520,835,517
Data.l 837,516,840,512,842,510,844,507,845,503,846,501,846,498,846,495,846,494,846,491
Data.l 846,489,846,486,844,484,843,482,841,479,840,478,837,476,834,473,832,472,828,469
Data.l 826,468,821,465,817,463,815,462,810,461,808,460,803,459,797,459,794,459,788,459
Data.l 785,459,779,459,774,459,771,459,766,461,763,462,759,463,755,465,752,466,748,468
Data.l 746,469,743,471,739,474,738,475,734,478,733,480,730,483,728,487,727,488,725,493
Data.l 725,495,724,500,723,504,723,506,723,510,723,512,724,516,725,520,726,523,727,528
Data.l 729,533,731,536,733,540,735,543,737,547,740,550,741,552,743,555,744,556,747,560
Data.l 749,563,750,565,753,569,754,571,756,574,759,577,759,578,762,580,763,581,766,583
Data.l 767,584,771,586,775,588,777,589,782,590,784,592,790,593,796,594,799,595,804,597
Data.l 809,598,812,599,818,599,822,600,828,600,834,601,837,601,843,602,846,602,852,604
Data.l 858,605,862,606,870,608,873,608,881,609,888,610,892,610,900,611,903,612,911,613
Data.l 919,613,923,614,929,615,933,615,938,616,943,616,945,616,949,616,951,616,955,616
Data.l 959,616,961,616,965,616,968,616,971,616,975,616,976,616,979,615,980,615,983,615
Data.l 986,615,988,614,990,614,991,613,993,612,996,612,997,612,1000,612,1002,611,1004,611
Data.l 1007,610,1008,610,1010,609,1012,609,1013,609,1014,608,1015,608,1017,608,1018,608,1022,606
Data.l 1023,606,8888
EndDataSection