Code : Tout sélectionner
;*****************************************************************************
; creation d'une table de trajectoire
;*****************************************************************************
;
InitSprite()
InitMouse()
InitKeyboard()
;*****************************************************************************
NewList table.Point()
;*****************************************************************************
OpenScreen(800,600,32,"")
;*****************************************************************************
; creation du réticule
;*****************************************************************************
reticule=CreateSprite(#PB_Any,8,8,0)
StartDrawing(SpriteOutput(reticule))
Line(0,3,8,0,$FFFFD3)
Line (3,0,0,8,$FFFFD3)
StopDrawing()
;*****************************************************************************
bulle=CreateSprite(#Pb_Any,16,16,0)
StartDrawing(SpriteOutput(bulle))
Circle(8,8,5,RGB($D5,$99,$2A))
StopDrawing()
;*****************************************************************************
Repeat
ClearScreen(0,0,0)
ForEach table()
DisplayTransparentSprite(bulle,table()\x-8,table()\y-8)
Next
DisplayTransparentSprite(reticule,MouseX(),MouseY())
FlipBuffers(1)
ExamineMouse()
If MouseButton(1)
AddElement(table())
table()\x=MouseX()
table()\y=MouseY()
EndIf
If MouseButton(2)
LastElement(table())
DeleteElement(table())
EndIf
;------------------------------------------------------------------------------
; on examine les touches du clavier
ExamineKeyboard()
If KeyboardPushed(#PB_Key_S) Or KeyboardPushed(#PB_Key_s)
ResetList(table())
CreateFile(0,"Trajectoire.Dta")
ForEach table()
WriteLong(table()\x)
WriteLong(table()\y)
Next
CloseFile(0)
EndIf
If KeyboardPushed(#PB_Key_t) Or KeyboardPushed(#PB_Key_T)
ResetList(table())
ClearList(table())
OpenFile(0,"Trajectoire.Dta")
While Eof(0)=0
AddElement(table())
table()\x=ReadLong()
table()\y=ReadLong()
Wend
CloseFile(0)
ResetList(table())
n=1
Repeat
ClearScreen(0,0,0)
SelectElement(table(),n)
DisplayTransparentSprite(bulle,table()\x,table()\y)
FlipBuffers(1)
n+1
n=(n % CountList(table()))+1
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
;------------------------------------------------------------------------------
; on sort de la bouche principale si la touche ESC est préssée
Until KeyboardPushed(#PB_Key_Escape)
End
Eric