10-27-2024, 10:23 PM
Hi Pete
thank you for your feedback.
I find it very useful and it pulls over the development of this demo.
Here the adding for proof of user Siam Tupid.
thanks to let me go on with this demo
thank you for your feedback.
I find it very useful and it pulls over the development of this demo.
Here the adding for proof of user Siam Tupid.
Code: (Select All)
Rem selfdefinition of input from keyboard
DefStr S
Dim sKeyUP, sKeyDOWN, sKeyLeft, sKeyRight
_Title "Self Assignment Input Key Demo"
Print "inizialization"
KeyInit sKeyUP, sKeyDOWN, sKeyLeft, sKeyRight
Print "keys' setup done"
_Delay 2
Xc% = 2
Yc% = 1
Cls
Locate 1, 1
sInput = sKeyUP + sKeyDOWN + sKeyLeft + sKeyRight
Print "Move the character using these keys "; sInput
Print "°";
Do
sInp = InKey$
If InStr(sInput, sInp) Then
If sInp = sKeyUP Then
If Xc% > 1 Then
Printstring Xc%, Yc%, " "
Xc% = Xc% - 1
Printstring Xc%, Yc%, "°"
End If
ElseIf sInp = sKeyDOWN Then
If Xc% < 25 Then
Printstring Xc%, Yc%, " "
Xc% = Xc% + 1
Printstring Xc%, Yc%, "°"
End If
ElseIf sInp = sKeyLeft Then
If Yc% > 1 Then
Printstring Xc%, Yc%, " "
Yc% = Yc% - 1
Printstring Xc%, Yc%, "°"
End If
ElseIf sInp = sKeyRight Then
If Yc% < 80 Then
Printstring Xc%, Yc%, " "
Yc% = Yc% + 1
Printstring Xc%, Yc%, "°"
End If
End If
End If
Loop
End
Sub Printstring (X%, Y%, sS)
Locate X%, Y%
Print sS;
End Sub
Sub KeyInit (sUp, sDown, sLeft, sRight)
Do
Print "Press the key for going UP"
sUp = ""
' for dummy user or accidental wrong choice
sUsed = ""
Do
sUp = InKey$
If sUp <> "" And AlreadyUsed(sUsed, sUp) Then sUp = ""
Loop While sUp = ""
Print " you have choosen "; sUp
Loop Until Confirm$ = "y"
' for dummy user or accidental wrong choice
sUsed = sUp
Do
Print "Press the key for going DOWN"
sDown = ""
Do
sDown = InKey$
If sDown <> "" And AlreadyUsed(sUsed, sDown) Then sDown = ""
Loop While sDown = ""
Print " you have choosen "; sDown
Loop Until Confirm$ = "y"
' for dummy user or accidental wrong choice
sUsed = sUp + sDown
Do
Print "Press the key for going Left"
sLeft = ""
Do
sLeft = InKey$
If sLeft <> "" And AlreadyUsed(sUsed, sLeft) Then sLeft = ""
Loop While sLeft = ""
Print " you have choosen "; sLeft
Loop Until Confirm$ = "y"
' for dummy user or accidental wrong choice
sUsed = sUp + sDown + sLeft
Do
Print "Press the key for going Right"
sRight = ""
Do
sRight = InKey$
If sRight <> "" And AlreadyUsed(sUsed, sRight) Then sRight = ""
Loop While sRight = ""
Print " you have choosen "; sRight
Loop Until Confirm$ = "y"
End Sub
Function AlreadyUsed (sUsed, sNew)
AlreadyUsed = InStr(sUsed, sNew)
End Function
Function Confirm$
Print "Do you confirm your choice? Y/N"
sInp = ""
While sInp = ""
sInp = LCase$(InKey$)
If sInp <> "" And InStr("yn", sInp) = 0 Then sInp = ""
Wend
Confirm$ = sInp
End Function
thanks to let me go on with this demo