Code archives/User Input/Use bitmap fonts with user input

This code has been declared by its author to be Public Domain code.

Download source code

Use bitmap fonts with user input by slenkar2005
Allows you to get the players name or other input while using bitmap fonts,(use your own bitmap font code!)
Graphics 800,600
Global player_name$
Global name_chosen=no

While Not name_chosen
Cls
FlushKeys()

While Not player_input
player_input=GetKey()
Text (400,200,"Enter name (max 7 characters)",True,True)
Text (400,300,player_name+"$",True,True)
Flip
Wend

actual_character$=0
actual_character=Chr(player_input)
If player_input<>13 And player_input<>8 And Len(player_name)<7
player_name$=player_name$+actual_character
Else
If player_input=13 And Len (player_name)>0
name_chosen=True
EndIf
If player_input=8
player_name=delete_letter(player_name)
EndIf
EndIf
player_input=0
Wend
Print "your name is: "+player_name+" press a key to start game"
WaitKey
End

Function delete_letter$(St$)

  If Len(St$) = 0 Then Return ""

  Return Left$(St$, Len(St$) - 1)


End Function

Comments

None.

Code Archives Forum