Page 1 sur 1

Fluidité des touches

Publié : ven. 13/déc./2024 16:02
par SPH
Salut,

utilisez les touches C et V (pour gauche et droite). Cela déplace la croix.
Mais le code attend qu'on appuie puis lâche la touche.
Et je ne sais plus comment je faisais dans le temps pour que la croix se déplace
librement sans qu'il y ai la fameuse pause après l'appuie de la touche.

Code : Tout sélectionner

If InitSprite() And InitKeyboard() And OpenScreen(800,600,32,"")
  xx=400
  
  Repeat
      FlipBuffers()
      ClearScreen(RGB(0, 0, 0))
      
      ExamineKeyboard()
       a$=KeyboardInkey()
       If a$="v"
         xx+5
       EndIf
       If a$="c"
         xx-5
       EndIf
       
      If StartDrawing(ScreenOutput())
        ;DrawingMode(1)
        FrontColor(RGB(128, 255, 0))
        DrawText(xx,300, "X")
        StopDrawing()
      EndIf
    Until KeyboardPushed(#PB_Key_Escape)
  EndIf
Merci d'avance :idea:

Re: Fluidité des touches

Publié : ven. 13/déc./2024 16:39
par falsam
KeyboardPushed(#PB_Key_V) et KeyboardPushed(#PB_Key_C)

Code : Tout sélectionner

If InitSprite() And InitKeyboard() And OpenScreen(800,600,32,"")
  xx=400
  
  Repeat
    FlipBuffers()
    ClearScreen(RGB(0, 0, 0))
    
    ExamineKeyboard()
    If KeyboardPushed(#PB_Key_V)
      xx+5  
    EndIf
    
    If KeyboardPushed(#PB_Key_C)
      xx-5
    EndIf
    
    If StartDrawing(ScreenOutput())
      ;DrawingMode(1)
      FrontColor(RGB(128, 255, 0))
      DrawText(xx,300, "X")
      StopDrawing()
    EndIf
  Until KeyboardPushed(#PB_Key_Escape)
EndIf
[/code]

Re: Fluidité des touches

Publié : ven. 13/déc./2024 18:12
par SPH
Hooo, merci :!:

C'est exactement ce que je voulais ! :wink:

THX A LOT