$COLOR:32
SCREEN _NEWIMAGE(1024, 720, 32)
CLS
result = LogIn(Detail$)
PRINT Detail$
FUNCTION LogIn (Detail$)
CONST True = -1, False = 0
DIM DC AS _UNSIGNED LONG, BGC AS _UNSIGNED LONG
D = _DEST: Disp = _AUTODISPLAY
DC = _DEFAULTCOLOR: BGC = _BACKGROUNDCOLOR
BG = _COPYIMAGE(D)
'DO
' count = count + 1
' Client = _OPENCLIENT("TCP/IP:7993:172.93.60.23") 'attempt to join as client
' _LIMIT 10
'LOOP UNTIL Client <> 0 OR count > 100
'OK$ = Verify$
'IF LEFT$(OK$, 4) <> "[OK]" THEN LogIn = 0: EXIT FUNCTION
LogInScreen = _NEWIMAGE(200, 240, 32)
_DEST LogInScreen
_KEYCLEAR 'clear the buffer before we start accepting stray input as being part of our login
Xoffset = (_WIDTH(D) - _WIDTH(LogInScreen)) / 2
Yoffset = (_HEIGHT(D) - _HEIGHT(LogInScreen)) / 2
DO
CLS , DarkGray
LINE (3, 3)-(_WIDTH - 4, _HEIGHT - 4), LightGray, BF
LINE (20, 40)-(180, 200), DarkGray, BF
LINE (23, 68)-(177, 92), DarkGray, BF
LINE (23, 128)-(172, 152), DarkGray, BF
LINE (25, 70)-(175, 90), Black, BF
LINE (25, 130)-(175, 150), Black, BF
LINE (20, 210)-(100, 230), DarkGray, BF
LINE (22, 212)-(98, 228), Green, BF
LINE (101, 210)-(180, 230), DarkGray, BF
LINE (103, 212)-(178, 228), Red, BF
COLOR DarkBlue, 0
_PRINTSTRING (100 - _PRINTWIDTH("CHECKERS") / 2, 15), "CHECKERS"
_PRINTSTRING (100 - _PRINTWIDTH("User Name") / 2, 95), "User Name"
_PRINTSTRING (100 - _PRINTWIDTH("Password") / 2, 155), "Password"
COLOR Yellow
_PRINTSTRING (60 - _PRINTWIDTH("LOG IN") / 2, 212), "LOG IN"
_PRINTSTRING (141 - _PRINTWIDTH("REGISTER") / 2, 212), "REGISTER"
count = (count + 1) MOD 30
IF count MOD 15 = 0 THEN blink = NOT blink
k = _KEYHIT
SELECT CASE k
CASE 9, 13 'tab or enter to toggle between the two fields.
S = NOT S
CASE 8 'backspace
IF S THEN p$ = LEFT$(p$, LEN(p$) - 1) ELSE n$ = LEFT$(n$, LEN(n$) - 1)
CASE 27 'Escape quits before we login
'Detail$ = "[ERROR]User Exited Log In Manually"
GOTO function_exit
CASE 32 TO 255 'visable characters
IF S THEN p$ = p$ + CHR$(k) ELSE n$ = n$ + CHR$(k)
END SELECT
COLOR White
_PRINTSTRING (27, 72), RIGHT$(n$, 18): _PRINTSTRING (27, 132), RIGHT$(p$, 18)
IF blink THEN
IF S THEN l = _PRINTWIDTH(p$) ELSE l = _PRINTWIDTH(n$)
_PRINTSTRING (27 + l, 72 - 60 * S), "_"
END IF
_PUTIMAGE (Xoffset, Yoffset), LogInScreen, D
WHILE _MOUSEINPUT: WEND
mb = _MOUSEBUTTON(1): mx = _MOUSEX - Xoffset: my = _MOUSEY - Yoffset
IF mb = True AND oldmouse = False THEN
IF my >= 210 AND my <= 230 THEN 'we're in the right X/Y position
IF mx >= 20 AND mx <= 100 THEN
'Run log in code
'Send Client, "[LOG IN]" + n$ + "," + p$ 'Register a new account
'OK$ = Verify$
'Detail$ = OK$
'IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit 'Success
Detail$ = "User: " + n$ + CHR$(13) + "Password: " + p$
LogIn = 0
GOTO function_exit 'Failure
END IF
IF mx >= 101 AND mx <= 180 THEN
'Run register code
'Send Client, "[REGISTER]" + n$ + "," + p$ 'Login from an existing account
'OK$ = Verify$
'Detail$ = OK$
'IF LEFT$(OK$, 4) = "[OK]" THEN LogIn = -1: GOTO function_exit
Detail$ = "User: " + n$ + CHR$(13) + "Password: " + p$
LogIn = 0
GOTO function_exit
END IF
ELSEIF my >= 70 AND my <= 90 AND mx >= 20 AND mx <= 180 THEN
S = 0
ELSEIF my >= 130 AND my <= 150 AND mx >= 20 AND mx <= 180 THEN
S = -1
END IF
END IF
'_DISPLAY
_LIMIT 30
oldmouse = mb
LOOP
function_exit: 'Safely restore our settings.
_DEST D
IF Disp THEN _AUTODISPLAY
_PUTIMAGE , BG, D 'restore the background
COLOR DC, BGC
_FREEIMAGE BG
END FUNCTION
This is exciting to be able to code games everyone can play, wow!
Also maybe run demo visual programs without having to download or workup gifs?
but I guess they would have to be compatible versions of QB64.
I'm just in the habit of being lazyBut why lazyness? I imagine that game on server must reduce to minimum the amount of data to exchange on the connection so that the server must be not so hardly overloaded. So in this my imagination in a game online the client part works for sound, music and graphics on the local machine and send string message events to the server that must cohordinate the several clients connected... with a strong structure based on timedconnection and a strong structured map of the game. In a wide world I think it is spending / wasting resources and time to search a collision with standard method used for a single player local game. Think just 100 connected players to a Minecraft server, Unreal arena, Age of Empire arena, or modern FortNite! Or a chess server to play online!