12-14-2025, 08:42 PM
(12-14-2025, 08:16 PM)bplus Wrote: I will try something from primitive Sound command a one-liner with no need for assets.
Update:
Code: (Select All)While _KeyDown(27) = 0
'test click
Sound 2000, .015
_Delay .8
Wend
I kinda like it, thank you, Actually doing Programmatic sounds is always kind of a chore for me, I often just resort to PCM samples ! But this is what I have so far for my Button Library.
Not bad I think for just an hour or so of work in it ! I have some other chores but when I come back to this I'm going to add Buttons with Images too !.
Code: (Select All)
Type BUTTONTYPE
Height As Integer
Width As Integer
X As Integer
Y As Integer
Image As Long
PushImage As Long
OldImage As Long
CREATED As Integer
ONSCREEN As Integer
End Type
Dim B(0 To 2) As BUTTONTYPE
Screen _NewImage(800, 600, 256)
MAKEBUTTON_LABELBTN 16, B(0), 8, "BUTTON 0"
MAKEBUTTON_LABELBTN 16, B(1), 8, "BUTTON 1"
MAKEBUTTON_LABELBTN 16, B(2), 8, "BUTTON 2"
BUTTONPUT_XY B(0), 220, 60
BUTTONPUT_XY B(1), 220, 120
BUTTONPUT_XY B(2), 220, 190
Dim J As Integer
Do
For J = 0 To 2
PUSH_BUTTON B(J)
Next
_Limit 30
Loop Until InKey$ = Chr$(27)
End
Sub PUSH_BUTTON (BTarget As BUTTONTYPE)
_PutImage (BTarget.X, BTarget.Y), BTarget.PushImage
Sound 2000, .015
_Delay .5
_PutImage (BTarget.X, BTarget.Y), BTarget.Image
End Sub
Sub BUTTONPUT_XY (BTarget As BUTTONTYPE, X As Integer, Y As Integer)
BTarget.X = X
BTarget.Y = Y
_PutImage (X, Y), BTarget.Image
BTarget.ONSCREEN = _TRUE
End Sub
Sub MAKEBUTTON_LABELBTN (bFont As Long, NEWBUTTON As BUTTONTYPE, BorderWidth As Integer, Label As String)
Dim CImage As Long
Dim SaveHandle As Long
Dim SavePMode As Integer
Dim C As Integer
Dim X As Integer
Dim I As Integer
Dim TWidth As Integer
Dim THeight As Integer
SaveHandle = _Font
_Font bFont
NEWBUTTON.Height = _FontHeight(bFont) + 8 + (BorderWidth * 2)
NEWBUTTON.Width = _PrintWidth(Label) + 12 + (BorderWidth * 2)
_Font SaveHandle
SaveHandle = _Dest
NEWBUTTON.Image = _NewImage(NEWBUTTON.Width, NEWBUTTON.Height, 256)
NEWBUTTON.OldImage = _NewImage(NEWBUTTON.Width, NEWBUTTON.Height, 256)
C = 0
For I = 16 To 31
_PaletteColor I, _RGB32(C, C, C, 255), NEWBUTTON.Image
C = C + 16
Next
_Dest NEWBUTTON.Image
TWidth = NEWBUTTON.Width
THeight = NEWBUTTON.Height
X = 0
Y = 0
I = 1
If BorderWidth > 0 Then
C = &H11
Do
Line (X, Y)-(X + (TWidth - 1), Y + (THeight - 1)), C, BF
C = C + 1
I = I + 1
TWidth = TWidth - 2
THeight = THeight - 2
X = X + 1
Y = Y + 1
Loop Until I = BorderWidth
Else
C = &H15
Line (X, Y)-(X + (TWidth - 1), Y + (THeight - 1)), C, BF
End If
NEWBUTTON.PushImage = _CopyImage(NEWBUTTON.Image)
_Font bFont, NEWBUTTON.Image
_PrintMode _KeepBackground , NEWBUTTON.Image
Color 0
_PrintString (0 + BorderWidth + 8, 0 + BorderWidth + 6), Label, NEWBUTTON.Image
_Dest NEWBUTTON.PushImage
_PrintMode _KeepBackground
Color 15
_PrintString (0 + BorderWidth + 8, 0 + BorderWidth + 6), Label, NEWBUTTON.PushImage
_Dest NEWBUTTON.Image
Color 15
_PrintString (0 + BorderWidth + 6, 0 + BorderWidth + 4), Label, NEWBUTTON.Image
_Dest SaveHandle
End Sub

