l'objectif de ce soir est de rejoindre un point A( départ: X=512 Y=128, d'un disque rouge menaçant) à un point B( une innocente raquette). Et oui, j'ai un peu honte de faire une telle demande

Et voici le joyeux code, avec listes chainées, où j'ai essayé de débrousailler le terrain: la raquette peut être déplacé avec les touche fléchés gauche ou droite.
Pour les disques rouge, ils descendent simplement, car ils ne sont pas orientés correctement en direction de la raquette lors de leur création:
Code : Tout sélectionner
; sprite d'un point A à un point B
If InitMouse ()=0 Or InitKeyboard ()=0 Or InitSprite ()=0 Or InitSprite3D ()=0
MessageRequester ( "Error" , "Can't open DirectX 7 or later" , 0)
End
EndIf
If InitSound()=0 Or InitMovie()=0
MessageRequester("Error", "Can't open DirectX 7 Or Sound Card is not present", 0)
End
EndIf
UsePNGImageDecoder()
; °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
Enumeration ; ici, on donne un petit nom à nos sprites( non, chuis pas un numéro !):
#raquette
#vilaintir
EndEnumeration
If OpenWindow ( 0 , 0, 0, 1024, 768, "tir orienté" , #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar| #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered | #PB_Window_ScreenCentered )
OpenWindowedScreen ( WindowID ( 0 ), 0, 0, 1024, 768, 0, 1, 1) ; un ecran graphique dans la fenêtre.
SetWindowColor(0, RGB (236,216,234))
EndIf
KeyboardMode(#PB_Keyboard_International)
CreateSprite ( #raquette , 64, 16, 0 )
StartDrawing ( SpriteOutput ( #raquette )) ; image pour la raquette
BackColor ( RGB (0,0,0))
Box (0,0, 64, 16, RGB (255, 255, 255))
StopDrawing ()
CreateSprite ( #vilaintir , 32, 32, 0 )
StartDrawing ( SpriteOutput ( #vilaintir )) ; image pour le tir
BackColor ( RGB (0,0,0))
Circle(16, 16, 16 , RGB (255, 0, 0))
StopDrawing ()
Structure objet
objetetat.b
objetx.l
objety.f
objetdirY.l
objetdirX.l
Tempo1.w
Tempo2.w
EndStructure
Global NewList trait.objet() ; -> #raquette
Global NewList tir.objet() ; -> #vilaintir
Global etape.b, tempoA.w=100
; ******************************************************************************************************
Repeat ; Boucle principale
; ******************************************************************************************************
Event= WindowEvent ()
Start3D() ; on place cette commande dès le début de la boucle principale.
ExamineMouse()
ExamineKeyboard ()
If etape=0
;- fabrication de la raquette
LastElement(trait())
AddElement(trait())
trait()\objetetat=1
trait()\objetx=512
trait()\objety=640
etape=1
EndIf
If etape=1
ForEach trait()
If trait()\objetetat=1;- raquette
DisplayTransparentSprite ( #raquette , trait()\objetx, trait()\objety)
If KeyboardPushed ( #PB_Key_Right ):trait()\objetx+5:EndIf ; droite.
If KeyboardPushed ( #PB_Key_Left ):trait()\objetx-5:EndIf ; gauche.
EndIf
Next
;-
tempoA+1
If tempoA>150:tempoA=0 ;- fabrication tir
LastElement(tir())
AddElement(tir())
tir()\objetetat=1
tir()\objetx=512
tir()\objety=128
;- là, il faut placer la formule mathématique qui manque:
; tir()\objetdirY=
; tir()\objetdirX=
EndIf
ForEach tir()
If tir()\objetetat=1;- tir
DisplayTransparentSprite ( #vilaintir , tir()\objetx, tir()\objety)
tir()\objety+1
EndIf
Next
EndIf
Stop3D(); on place cette commande à la fin de la boucle principale.
FlipBuffers()
ClearScreen(RGB(0, 42, 255))
; ******************************************************************************************************
If Event= #PB_Event_CloseWindow Or KeyboardPushed ( #PB_Key_Escape ):End:EndIf; si clique coin haut droit ou touche Esc, alors ferme fenêtre.
ForEver