A little #program that lets you move a Smiley Face around the screen using #QB64
Source (Also in ALT text):
'-----------------------------------------
' Moving a face around the screen!
' Phillip J Rhoades - 2026-04-05
'-----------------------------------------
'Initializing some variables and the screen
Let Row = 1
Let Col = 1
Dim PrevRow
Dim PrevCol
Locate Row, Col
Print Chr$(2)
'Start of the main loop
Do
'Get the Keypress
TheKey$ = InKey$
'If there's no Keypress, there's no need to do all this
'so skip it all
If TheKey$ <> "" Then
'Record the Row and Col before changing
PrevRow = Row
PrevCol = Col
'Take note of which arrow key is pressed for movement.
Select Case TheKey$
Case Chr$(0) + Chr$(77): Col = Col + 1 'Left
Case Chr$(0) + Chr$(75): Col = Col - 1 'Right
Case Chr$(0) + Chr$(80): Row = Row + 1 'Down
Case Chr$(0) + Chr$(72): Row = Row - 1 'Up
End Select
'Keep the character on the screen
If Row < 1 Or Row > 23 Then
Row = PrevRow
End If
If Col < 1 Or Col > 79 Then
Col = PrevCol
End If
'Blank the old and print the new location
'to move the character.
Locate PrevRow, PrevCol 'Move cursor to old place
Print " " 'Blank the old character
Locate Row, Col 'Move cursor to new place
Print Chr$(2) 'Print the character to move on screen
End If 'This loop was mostly skipped if no Keypress
Loop Until TheKey$ = "q"
'End of the main loop
