Author Topic: Pretentious not-yet-a-clone clone of Among Us in QB64  (Read 10066 times)

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #30 on: October 22, 2020, 03:10:36 pm »
The messages sent earlier by SierraKen were registered to you when you joined, because you used up his free slot.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #31 on: October 22, 2020, 03:14:06 pm »
It is possible. I ran the first version without chat.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #32 on: October 23, 2020, 03:20:15 am »
GREAT JOB!!! :D
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline qbkiller101

  • Newbie
  • Posts: 73
    • View Profile
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #33 on: October 23, 2020, 10:18:38 am »
Added choosing the dimensions, working on wasd mode and arrow keys mode:
Code: QB64: [Select]
  1. 'Find the Gold! by SierraKen
  2. 'October 21, 2020
  3. 'Thanks for the great mapping code by FellipeHeitor and help from B+!
  4. 'This is mostly an example game, I hope to expand on it sometime soon.
  5. 'October 22, 2020
  6. 'Edits by Omer H., or qbkiller101 in the forums
  7. 'Added wasd support, fast and normal mode (see 113), and choosing
  8. 'dimensions for people with small screens (like me)
  9.  
  10.  
  11. SCREEN _NEWIMAGE(500, 400, 256)
  12. LINE (125, 100)-(375, 175), 15, BF
  13. LINE (125, 225)-(375, 300), 15, BF
  14. _PRINTSTRING (150, 0), "Choose the dimensions:"
  15. _PRINTSTRING (210, 125), "800 x 600"
  16. _PRINTSTRING (175, 250), "Default (1000 x 800)"
  17. dimx% = 800
  18. dimy% = 600
  19. ischosen = false
  20. WHILE ischosen = false
  21.         IF _MOUSEX > 125 AND _MOUSEX < 375 THEN
  22.             IF _MOUSEY > 100 AND _MOUSEY < 175 THEN
  23.                 IF _MOUSEBUTTON(1) = -1 THEN
  24.                     dimx% = 800
  25.                     dimy% = 600
  26.                     ischosen = true
  27.                     EXIT WHILE
  28.                 END IF
  29.             END IF
  30.         END IF
  31.         IF _MOUSEX > 125 AND _MOUSEX < 375 THEN
  32.             IF _MOUSEY > 225 AND _MOUSEY < 300 THEN
  33.                 IF _MOUSEBUTTON(1) = -1 THEN
  34.                     dimx% = 1000
  35.                     dimy% = 800
  36.                     ischosen = true
  37.                     EXIT WHILE
  38.                 END IF
  39.             END IF
  40.         END IF
  41.  
  42.     LOOP
  43. SCREEN _NEWIMAGE(dimx%, dimy%, 32)
  44.  
  45. TYPE object
  46.     x AS SINGLE
  47.     y AS SINGLE
  48.  
  49. DIM SHARED player AS object
  50. DIM SHARED camera AS object
  51. DIM playerSpeed AS SINGLE
  52.  
  53. _TITLE "Find The Gold! One gold bar per map. Use your arrow keys."
  54.  
  55. start:
  56. player.x = _WIDTH / 2
  57. player.y = _HEIGHT / 2
  58.  
  59. map = _NEWIMAGE(_WIDTH * 7, _HEIGHT * 7, 32)
  60.  
  61. _DEST map
  62. PAINT (2, 2), _RGB32(0, 200, 0)
  63.  
  64. FOR blocks = 1 TO 400
  65.     blocks:
  66.     xx = (RND * _WIDTH)
  67.     yy = (RND * _HEIGHT)
  68.     sz = INT(RND * 50) + 10
  69.     c1 = INT(RND * 155) + 100
  70.     c2 = INT(RND * 155) + 100
  71.     c3 = INT(RND * 155) + 100
  72.     LINE (xx, yy)-(xx + sz, yy + sz), _RGB32(c1, c2, c3), BF
  73.     IF POINT(_WIDTH / 2, _HEIGHT / 2) = _RGB32(c1, c2, c3) THEN GOTO blocks:
  74. FOR lakes = 1 TO 10
  75.     w = RND
  76.     h = RND
  77.     sze = (RND * 150) + 50
  78.     FOR sz = .25 TO sze STEP .25
  79.         CIRCLE (w * _WIDTH, h * _HEIGHT), sz, _RGB32(0, 0, 255)
  80.     NEXT sz
  81. NEXT lakes
  82. w2 = INT(RND * _WIDTH) - 15
  83. h2 = INT(RND * _HEIGHT) - 10
  84. IF w2 < 15 THEN w2 = 15
  85. IF h2 < 10 THEN h2 = 10
  86.  
  87. 'Gold
  88. COLOR _RGB32(0, 0, 0), _RGB32(255, 255, 128)
  89. _PRINTSTRING (w2, h2), "GOLD"
  90.  
  91.  
  92.  
  93. playerSpeed = 10
  94.  
  95. CONST keyUP = 18432
  96. CONST keyDOWN = 20480
  97. CONST keyLEFT = 19200
  98. CONST keyRIGHT = 19712
  99.  
  100.     CLS
  101.  
  102.     _PUTIMAGE (camera.x, camera.y), map
  103.  
  104.     IF _KEYDOWN(keyUP) THEN player.y = player.y - playerSpeed
  105.     IF _KEYDOWN(keyDOWN) THEN player.y = player.y + playerSpeed
  106.     IF _KEYDOWN(keyLEFT) THEN player.x = player.x - playerSpeed
  107.     IF _KEYDOWN(keyRIGHT) THEN player.x = player.x + playerSpeed
  108.     IF _KEYDOWN(119) THEN player.y = player.y - playerSpeed 'Omer Hijazi
  109.     IF _KEYDOWN(115) THEN player.y = player.y + playerSpeed 'Omer Hijazi
  110.     IF _KEYDOWN(97) THEN player.x = player.x - playerSpeed 'Omer Hijazi
  111.     IF _KEYDOWN(100) THEN player.x = player.x + playerSpeed 'Omer Hijazi
  112.  
  113.  
  114.     IF player.x < 0 THEN player.x = 0
  115.     IF player.x > _WIDTH(map) THEN player.x = _WIDTH(map)
  116.     IF player.y < 0 THEN player.y = 0
  117.     IF player.y > _HEIGHT(map) THEN player.y = _HEIGHT(map)
  118.  
  119.     adjustCamera
  120.  
  121.     'Draw Head
  122.     FOR sz = .25 TO 10 STEP .25
  123.         CIRCLE (player.x + camera.x, player.y + camera.y), sz, _RGB32(255, 166, 127)
  124.     NEXT sz
  125.     'Draw Smile
  126.     CIRCLE (player.x + camera.x, player.y + camera.y + 2), 7, _RGB32(255, 0, 0), _PI, 2 * _PI, .5
  127.     'Draw Eyes
  128.     CIRCLE (player.x + camera.x - 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  129.     CIRCLE (player.x + camera.x + 4, player.y + camera.y - 2), 1, _RGB32(0, 0, 255)
  130.     'hat
  131.     LINE (player.x + camera.x - 10, player.y + camera.y - 10)-(player.x + camera.x + 10, player.y + camera.y - 9), _RGB32(155, 0, 0), BF
  132.     LINE (player.x + camera.x - 5, player.y + camera.y - 9)-(player.x + camera.x + 5, player.y + camera.y - 15), _RGB32(155, 0, 0), BF
  133.     FOR check = -15 TO 15
  134.         IF POINT(player.x + check, player.y + check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  135.         IF POINT(player.x + check, player.y - check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  136.         IF POINT(player.x - check, player.y + check) = _RGB32(255, 255, 128) THEN SOUND 500, .5: score = score + 100: score$ = STR$(score): _TITLE "Score: " + score$: GOTO start:
  137.     NEXT check
  138.  
  139.     _DISPLAY
  140.     _LIMIT 60
  141.  
  142. SUB adjustCamera
  143.     IF player.x + camera.x > _WIDTH / 2 OR player.x + camera.x < _WIDTH / 2 THEN
  144.         camera.x = _WIDTH / 2 - player.x
  145.     END IF
  146.     IF camera.x > 0 THEN camera.x = 0
  147.     IF camera.x < -(_WIDTH(map) - _WIDTH) THEN camera.x = -(_WIDTH(map) - _WIDTH)
  148.  
  149.     IF player.y + camera.y > _HEIGHT / 2 OR player.y + camera.y < _HEIGHT / 2 THEN
  150.         camera.y = _HEIGHT / 2 - player.y
  151.     END IF
  152.     IF camera.y > 0 THEN camera.y = 0
  153.     IF camera.y < -(_HEIGHT(map) - _HEIGHT) THEN camera.y = -(_HEIGHT(map) - _HEIGHT)
  154.  
« Last Edit: October 23, 2020, 11:01:21 am by qbkiller101 »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #34 on: October 24, 2020, 02:33:47 pm »
Hi Guys
Hi Fellippe

1. I think that this your project that you share and let be our is wonderful!!!!!!!!!!!

2.  I find wonderful also your video that brings the audience with you along the developing of the first version of the game

3. some feedback (I hope these are useful!)
I have tryed to run the first online version and I got a strange result ( I have used US server but trying also on Australia server it is the same result)  after a while I run happy on the map I lost connection to the server. And I'm the one on that map. It happens also when I do a double connection (as you have suggested I have run two instances of the same .EXE).
Another strange result is this showed into this screenshot.
 
amongst0.jpg


Now I try to donwload the version with chat from your github!

Thanks to share!!!!
Programming isn't difficult, only it's  consuming time and coffee

FellippeHeitor

  • Guest
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #35 on: October 24, 2020, 02:37:17 pm »
The client in this thread is slightly outdated now. We're working on getting the servers updated with the latest version and will update you guys here too.

FellippeHeitor

  • Guest
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #36 on: October 24, 2020, 02:38:14 pm »
In the meantime, you can get the new server+client files from the repository and run a local instance. Just run the server then run the client and choose "local host".

https://github.com/FellippeHeitor/amongus
« Last Edit: October 24, 2020, 02:39:56 pm by FellippeHeitor »

FellippeHeitor

  • Guest
Re: Pretentious not-really-a-clone clone of Among Us in QB64
« Reply #37 on: October 24, 2020, 04:17:55 pm »
Server in Brazil updated. Here's the latest client:

Code: QB64: [Select]
  1.  
  2. DIM SHARED gameVersion AS INTEGER
  3. 'this is to be increased everytime the client
  4. 'becomes incompatible with previous versions
  5. gameVersion = 2
  6.  
  7. $LET DEBUGGING = FALSE
  8. $IF DEBUGGING = TRUE THEN
  9.     $CONSOLE
  10.  
  11. CONST True = -1, False = 0
  12. CONST mode_freeplay = 0
  13. CONST mode_onlineclient = 1
  14.  
  15. CONST id_SERVERFULL = 1
  16. CONST id_PING = 2
  17. CONST id_ID = 3
  18. CONST id_NEWCOLOR = 4
  19. CONST id_NEWNAME = 5
  20. CONST id_COLOR = 6
  21. CONST id_POS = 7
  22. CONST id_NAME = 8
  23. CONST id_CHAT = 9
  24. CONST id_PLAYERONLINE = 10
  25. CONST id_PLAYEROFFLINE = 11
  26. CONST id_PONG = 12
  27. CONST id_PLAYERQUIT = 13
  28. CONST id_GAMEVERSION = 14
  29. CONST id_SHOOT = 15
  30. CONST id_SIZE = 16
  31. CONST id_UPDATESERVER = 17
  32. CONST id_KICK = 18
  33.  
  34. CONST timeout = 10
  35.  
  36. CONST windowWidth = 800
  37. CONST windowHeight = 600
  38.  
  39. TYPE object
  40.     name AS STRING
  41.     handle AS LONG
  42.     x AS SINGLE
  43.     prevX AS SINGLE
  44.     y AS SINGLE
  45.     prevY AS SINGLE
  46.     xv AS SINGLE
  47.     yv AS SINGLE
  48.     xa AS SINGLE
  49.     ya AS SINGLE
  50.     w AS INTEGER
  51.     h AS INTEGER
  52.     state AS INTEGER
  53.     start AS SINGLE
  54.     duration AS SINGLE
  55.     basicInfoSent AS _BYTE
  56.     broadcastOffline AS _BYTE
  57.     ping AS SINGLE
  58.     id AS INTEGER
  59.     text AS STRING
  60.     size AS INTEGER
  61.     r AS INTEGER
  62.     g AS INTEGER
  63.     b AS INTEGER
  64.  
  65. DIM SHARED particle(1000) AS object
  66. DIM SHARED totalClients AS INTEGER
  67. DIM SHARED serverStream AS STRING
  68. DIM SHARED player(1 TO 10) AS object, me AS INTEGER
  69. 'DIM SHARED playerStream(1 TO 10) AS STRING
  70. DIM SHARED warning(1 TO 30) AS object
  71. DIM SHARED chat(1 TO 14) AS object, hasUnreadMessages AS _BYTE, chatOpen AS _BYTE
  72. DIM idSet AS _BYTE
  73. DIM shipMovement AS _BYTE
  74. DIM serverPing AS SINGLE, currentPing AS SINGLE, waitingForPong AS _BYTE
  75. DIM id AS INTEGER, value$
  76. DIM choice AS STRING
  77. DIM exitSign AS INTEGER
  78. DIM target AS INTEGER
  79. DIM score AS LONG
  80.  
  81. DIM SHARED ui(1 TO 1) AS object, focus AS INTEGER
  82.  
  83. DIM serverList(1 TO 4) AS STRING, chosenServer$
  84. i = 0
  85. i = i + 1: serverList(i) = "localhost Local host"
  86. i = i + 1: serverList(i) = "spriggsyspriggs.ddns.net North America"
  87. i = i + 1: serverList(i) = "alephc.xyz Australia"
  88. i = i + 1: serverList(i) = "187.94.219.178 Brazil"
  89.  
  90. DIM SHARED endSignal AS STRING
  91. endSignal = CHR$(253) + CHR$(254) + CHR$(255)
  92.  
  93. playerColorPalette:
  94. DATA 195,17,16
  95. DATA 14,51,196
  96. DATA 18,125,46
  97. DATA 236,84,187
  98. DATA 239,125,17
  99. DATA 248,245,91
  100. DATA 62,71,77
  101. DATA 216,225,241
  102. DATA 107,48,187
  103. DATA 112,73,28
  104. DATA 93,250,220
  105. DATA 79,240,58
  106.  
  107. RESTORE playerColorPalette
  108. FOR i = 1 TO UBOUND(colors)
  109.     READ r%, g%, b%
  110.     colors(i) = _RGB32(r%, g%, b%)
  111.  
  112. DIM SHARED mainWindow AS LONG
  113. DIM SHARED mapImage AS LONG
  114. DIM SHARED messageIcon AS LONG
  115.  
  116. mainWindow = _NEWIMAGE(windowWidth, windowHeight, 32)
  117.  
  118. mapImage = _NEWIMAGE(windowWidth * 4, windowHeight * 3, 32)
  119. _DEST mapImage
  120. 'FOR i = 1 TO 500
  121. '    CircleFill RND * _WIDTH, RND * _HEIGHT, RND * 2, _RGB32(255, 80)
  122. 'NEXT
  123. FOR i = 1 TO 50
  124.     CircleFill RND * _WIDTH, RND * _HEIGHT, RND * 1000, _RGB32(RND * 255, RND * 255, RND * 255, RND * 150)
  125.  
  126. messageIcon = _NEWIMAGE(32, 32, 32)
  127. _DEST messageIcon
  128. LINE (0, 0)-(31, 31), _RGB32(0), BF
  129. LINE (4, 4)-(27, 27), _RGB32(200), BF
  130. FOR i = 8 TO 23 STEP 5
  131.     LINE (5, i)-(25, i), _RGB32(0)
  132. ui(1).name = "messageicon"
  133. ui(1).x = windowWidth - 50
  134. ui(1).y = 10
  135. ui(1).w = _WIDTH
  136. ui(1).h = _HEIGHT
  137.  
  138.  
  139. DIM userName$, userColor%
  140.     GET #1, , i
  141.     userName$ = SPACE$(i)
  142.     GET #1, , userName$
  143.     GET #1, , userColor%
  144.     CLOSE #1
  145.     choice = "1"
  146.     GOTO clientTemp
  147.     INPUT "Name: ", userName$
  148.     userName$ = LEFT$(userName$, 20)
  149.     DO
  150.         PRINT "Color (1-"; LTRIM$(STR$(UBOUND(colors))); "): ";
  151.         INPUT "", userColor%
  152.     LOOP WHILE userColor% < 1 OR userColor% > UBOUND(colors)
  153.  
  154. start:
  155.     COLOR 15
  156.     PRINT "-------------------------"
  157.     PRINT "(1) Free play"
  158.     PRINT "(2) Connect to server"
  159.  
  160.     DO
  161.         choice = INKEY$
  162.  
  163.         exitSign = _EXIT
  164.         IF exitSign THEN
  165.             SYSTEM
  166.         END IF
  167.  
  168.         _LIMIT 30
  169.     LOOP UNTIL choice >= "1" AND choice <= "3"
  170.  
  171.     DIM SHARED server AS object
  172.     DIM c AS INTEGER, attempt AS INTEGER
  173.     SELECT CASE VAL(choice)
  174.         CASE 1
  175.             mode = mode_freeplay
  176.             EXIT DO
  177.         CASE 2
  178.             COLOR 7
  179.             PRINT "Choose a server: "
  180.             FOR i = 1 TO UBOUND(serverList)
  181.                 PRINT i; " " + MID$(serverList(i), INSTR(serverList(i), " ") + 1)
  182.             NEXT
  183.             DO
  184.                 choice = INKEY$
  185.  
  186.                 exitSign = _EXIT
  187.                 IF exitSign THEN
  188.                     SYSTEM
  189.                 END IF
  190.  
  191.                 _LIMIT 30
  192.             LOOP UNTIL VAL(choice) >= 1 AND VAL(choice) <= UBOUND(serverList)
  193.             clientTemp:
  194.             chosenServer$ = LEFT$(serverList(VAL(choice)), INSTR(serverList(VAL(choice)), " ") - 1)
  195.  
  196.             PRINT "Attempting to connect to server... ";
  197.             r = CSRLIN: c = POS(1)
  198.             CONST maxAttempts = 100
  199.             attempt = 0
  200.             DO
  201.                 server.handle = 0
  202.                 server.handle = _OPENCLIENT("TCP/IP:51512:" + chosenServer$)
  203.                 IF server.handle THEN EXIT DO
  204.                 attempt = attempt + 1
  205.                 LOCATE r, c: PRINT USING "###%"; (attempt / maxAttempts) * 100;
  206.  
  207.                 exitSign = _EXIT
  208.                 IF exitSign THEN
  209.                     SYSTEM
  210.                 END IF
  211.  
  212.                 _LIMIT 30
  213.             LOOP WHILE attempt < maxAttempts
  214.             IF server.handle THEN
  215.                 mode = mode_onlineclient
  216.                 serverStream = ""
  217.                 EXIT DO
  218.             END IF
  219.             CLS
  220.             COLOR 14: PRINT "/\ ";: COLOR 12
  221.             PRINT "Failed to connect to server."
  222.     END SELECT
  223.  
  224. IF mode = mode_onlineclient THEN
  225.     serverPing = TIMER
  226.     DO
  227.         getData server, serverStream
  228.         WHILE parse(serverStream, id, value$)
  229.             SELECT CASE id
  230.                 CASE id_SERVERFULL
  231.                     CLS
  232.                     COLOR 14: PRINT "/\ ";: COLOR 12
  233.                     PRINT "Server full."
  234.                     CLOSE server.handle
  235.                     GOTO start
  236.                 CASE id_GAMEVERSION
  237.                     IF CVI(value$) <> gameVersion THEN
  238.                         CLS
  239.                         COLOR 14: PRINT "/\ ";: COLOR 12
  240.                         PRINT "Server version incompatible."
  241.                         sendData server, id_GAMEVERSION, ""
  242.                         sendData server, id_PLAYERQUIT, ""
  243.                         CLOSE server.handle
  244.                         GOTO start
  245.                     ELSE
  246.                         EXIT DO
  247.                     END IF
  248.             END SELECT
  249.         WEND
  250.         IF TIMER - serverPing > 10 THEN
  251.             CLS
  252.             COLOR 14: PRINT "/\ ";: COLOR 12
  253.             PRINT "No response from server."
  254.             GOTO start
  255.         END IF
  256.         _LIMIT 30
  257.     LOOP
  258.  
  259. SCREEN mainWindow
  260.  
  261. DIM SHARED playerSpeed AS SINGLE
  262. DIM SHARED camera AS object
  263.  
  264.  
  265. CONST keyUP = 18432
  266. CONST keyDOWN = 20480
  267. CONST keyLEFT = 19200
  268. CONST keyRIGHT = 19712
  269. CONST keySPACE = 32
  270.  
  271. CONST cameraWindow = 100
  272.  
  273. CONST minSpeed = 3
  274. CONST maxSpeed = 5
  275.  
  276. playerSpeed = maxSpeed
  277. shipMovement = True
  278.  
  279. IF mode > 0 THEN
  280.     idSet = False
  281.     idSet = True
  282.     me = 1
  283.     player(me).name = userName$
  284.     player(me).x = _WIDTH / 2 + COS(RND * _PI) * (RND * 100)
  285.     player(me).y = _HEIGHT / 2 + SIN(RND * _PI) * (RND * 100)
  286.     player(me).state = True
  287.     player(me).color = userColor%
  288.     player(me).size = 15
  289.     CLS
  290.  
  291.     DIM shipFlotation AS SINGLE, shipFloatAmplitude AS SINGLE
  292.     IF shipMovement THEN
  293.         shipFlotation = shipFlotation + .05
  294.         IF shipFlotation > _PI(2) THEN shipFlotation = shipFlotation - _PI(2)
  295.         shipFloatAmplitude = 1.5
  296.     END IF
  297.  
  298.     _PUTIMAGE (camera.x + COS(shipFlotation) * shipFloatAmplitude, camera.y + SIN(shipFlotation) * shipFloatAmplitude), mapImage
  299.     _BLEND
  300.  
  301.     SELECT CASE mode
  302.         CASE mode_onlineclient
  303.             IF waitingForPong = False THEN
  304.                 serverPing = TIMER
  305.                 sendData server, id_PING, ""
  306.                 waitingForPong = True
  307.             END IF
  308.  
  309.             getData server, serverStream
  310.             DO WHILE parse(serverStream, id, value$)
  311.                 SELECT EVERYCASE id
  312.                     CASE id_ID 'first piece of data sent by server if not full
  313.                         idSet = True
  314.                         me = CVI(value$)
  315.                         player(me).name = userName$
  316.                         player(me).x = _WIDTH / 2 + COS(RND * _PI) * (RND * 100)
  317.                         player(me).y = _HEIGHT / 2 + SIN(RND * _PI) * (RND * 100)
  318.                         player(me).state = True
  319.                         player(me).color = userColor%
  320.                         player(me).size = 15
  321.                     CASE id_NEWCOLOR 'server color changes must always be applied
  322.                         player(me).color = CVI(value$)
  323.                     CASE id_NEWNAME 'server name changes must always be applied
  324.                         player(me).name = value$
  325.                     CASE id_COLOR
  326.                         player(CVI(LEFT$(value$, 2))).color = CVI(RIGHT$(value$, 2))
  327.                     CASE id_SIZE
  328.                         player(CVI(LEFT$(value$, 2))).size = CVI(RIGHT$(value$, 2))
  329.                     CASE id_POS
  330.                         'playerStream(CVI(LEFT$(value$, 2))) = playerStream(CVI(LEFT$(value$, 2))) + MID$(value$, 3)
  331.                         player(CVI(LEFT$(value$, 2))).x = CVS(MID$(value$, LEN(value$) - 7, 4))
  332.                         player(CVI(LEFT$(value$, 2))).y = CVS(RIGHT$(value$, 4))
  333.                     CASE id_NAME
  334.                         player(CVI(LEFT$(value$, 2))).name = MID$(value$, 3)
  335.                     CASE id_CHAT
  336.                         addMessageToChat CVI(LEFT$(value$, 2)), MID$(value$, 3)
  337.                         hasUnreadMessages = True
  338.                     CASE id_SHOOT
  339.                         target = CVI(RIGHT$(value$, 2))
  340.                         IF target = me THEN score = score - 100
  341.                         addParticles player(target).x, player(target).y, 5, _RGB32(255)
  342.                         addParticles player(target).x, player(target).y, 100, colors(player(target).color)
  343.                         thickLine player(CVI(LEFT$(value$, 2))).x + camera.x, player(CVI(LEFT$(value$, 2))).y + camera.y, player(target).x + camera.x, player(target).y + camera.y, 8, _RGB32(227, 78, 6, 80)
  344.                     CASE id_PLAYERONLINE
  345.                         player(CVI(value$)).state = True
  346.                     CASE id_PLAYEROFFLINE
  347.                         IF player(CVI(value$)).state = True THEN
  348.                             player(CVI(value$)).state = False
  349.                             addWarning player(CVI(value$)).name + " left the game."
  350.                         END IF
  351.                     CASE id_PONG
  352.                         waitingForPong = False
  353.                     CASE id_KICK
  354.                         SCREEN 0
  355.                         _AUTODISPLAY
  356.                         COLOR 14: PRINT "/\ ";: COLOR 12
  357.                         PRINT "Kicked from server. Reason: "
  358.                         COLOR 14
  359.                         PRINT "   "; value$
  360.                         CLOSE server.handle
  361.                         GOTO start
  362.                 END SELECT
  363.             LOOP
  364.  
  365.             IF idSet THEN
  366.                 IF player(me).basicInfoSent = False THEN
  367.                     player(me).basicInfoSent = True
  368.                     sendData server, id_COLOR, MKI$(player(me).color)
  369.                     sendData server, id_NAME, player(me).name
  370.                     sendData server, id_SIZE, MKI$(player(me).size)
  371.                 END IF
  372.  
  373.                 IF player(me).x <> player(me).prevX OR player(me).y <> player(me).prevY THEN
  374.                     player(me).prevX = player(me).x
  375.                     player(me).prevY = player(me).y
  376.                     sendData server, id_POS, MKS$(player(me).x) + MKS$(player(me).y)
  377.                 END IF
  378.             END IF
  379.  
  380.             totalClients = 0
  381.             FOR i = 1 TO UBOUND(player)
  382.                 IF player(i).state = True THEN totalClients = totalClients + 1
  383.             NEXT
  384.     END SELECT
  385.  
  386.     IF playerSpeed < minSpeed THEN playerSpeed = minSpeed
  387.     IF playerSpeed > maxSpeed THEN playerSpeed = maxSpeed
  388.  
  389.     IF idSet THEN
  390.         IF chatOpen = False THEN
  391.             IF _KEYDOWN(keyUP) THEN player(me).y = player(me).y - playerSpeed
  392.             IF _KEYDOWN(keyDOWN) THEN player(me).y = player(me).y + playerSpeed
  393.             IF _KEYDOWN(keyLEFT) THEN player(me).x = player(me).x - playerSpeed
  394.             IF _KEYDOWN(keyRIGHT) THEN player(me).x = player(me).x + playerSpeed
  395.  
  396.             IF player(me).x < 0 THEN player(me).x = 0
  397.             IF player(me).y < 0 THEN player(me).y = 0
  398.             IF player(me).x > _WIDTH(mapImage) THEN player(me).x = _WIDTH(mapImage)
  399.             IF player(me).y > _HEIGHT(mapImage) THEN player(me).y = _HEIGHT(mapImage)
  400.         END IF
  401.         adjustCamera
  402.     END IF
  403.  
  404.     exitSign = _EXIT
  405.     IF exitSign THEN
  406.         IF mode = mode_onlineclient THEN sendData server, id_PLAYERQUIT, ""
  407.         EXIT DO
  408.     END IF
  409.  
  410.     IF (mode = mode_onlineclient) THEN
  411.         DIM k AS LONG
  412.         k = _KEYHIT
  413.  
  414.         IF k = 27 THEN
  415.             IF chatOpen THEN
  416.                 chatOpen = False
  417.             END IF
  418.         END IF
  419.  
  420.         COLOR _RGB32(255)
  421.  
  422.         DIM m$
  423.         currentPing = TIMER - serverPing
  424.         IF currentPing > timeout THEN
  425.             SCREEN 0
  426.             _AUTODISPLAY
  427.             COLOR 14: PRINT "/\ ";: COLOR 12
  428.             PRINT "Connection lost (timed out)"
  429.             CLOSE server.handle
  430.             GOTO start
  431.         END IF
  432.         m$ = LTRIM$(STR$(currentPing))
  433.         m$ = MID$(m$, INSTR(m$, ".") + 1)
  434.         m$ = LEFT$(STRING$(3 - LEN(m$), "0") + m$, 3) + "ms"
  435.         _PRINTSTRING (_WIDTH - 150 - _PRINTWIDTH(m$), 0), m$
  436.  
  437.         _FONT 16
  438.         m$ = LTRIM$(STR$(totalClients)) + "/" + LTRIM$(STR$(UBOUND(player)))
  439.         _PRINTSTRING ((_WIDTH - _PRINTWIDTH(m$)) / 2, _HEIGHT - _FONTHEIGHT), m$
  440.         _FONT 8
  441.     END IF
  442.  
  443.     DIM x AS SINGLE, y AS SINGLE
  444.     target = 0
  445.     FOR i = 1 TO UBOUND(player)
  446.         'proximity
  447.         IF i <> me AND player(i).state = True THEN
  448.             IF dist(player(me).x, player(me).y, player(i).x, player(i).y) < 150 THEN target = i
  449.         END IF
  450.     NEXT
  451.  
  452.     IF target THEN
  453.         DIM targetAnimation AS SINGLE
  454.         targetAnimation = targetAnimation - .1
  455.         IF targetAnimation < 0 THEN targetAnimation = 5
  456.  
  457.         x = player(target).x + camera.x + COS(shipFlotation) * shipFloatAmplitude
  458.         y = player(target).y + camera.y + SIN(shipFlotation) * shipFloatAmplitude
  459.         CircleFill x, y, player(target).size + 10 + targetAnimation, _RGB32(255, 0, 0, 100)
  460.     END IF
  461.  
  462.     FOR i = 1 TO UBOUND(player)
  463.         IF player(i).state = False OR player(i).color = 0 THEN _CONTINUE
  464.         'IF i <> me AND LEN(playerStream(i)) > 0 THEN
  465.         '    'process player stream of coordinates
  466.         '    player(i).x = CVS(MID$(playerStream(i), 1, 4))
  467.         '    player(i).y = CVS(MID$(playerStream(i), 5, 4))
  468.         '    playerStream(i) = MID$(playerStream(i), 9)
  469.         'END IF
  470.  
  471.         x = player(i).x + camera.x + COS(shipFlotation) * shipFloatAmplitude
  472.         y = player(i).y + camera.y + SIN(shipFlotation) * shipFloatAmplitude
  473.         CircleFill x, y + 6, player(i).size + 5, _RGB32(0, 50)
  474.         CircleFill x, y, player(i).size + 5, _RGB32(0)
  475.         CircleFill x, y, player(i).size, colors(player(i).color)
  476.         COLOR _RGB32(0)
  477.         _PRINTSTRING (1 + x - _PRINTWIDTH(player(i).name) / 2, 1 + y - 20), player(i).name
  478.         COLOR _RGB32(255)
  479.         _PRINTSTRING (x - _PRINTWIDTH(player(i).name) / 2, y - 20), player(i).name
  480.     NEXT
  481.  
  482.     IF _KEYDOWN(keySPACE) THEN
  483.         DIM lastShot AS SINGLE
  484.         IF target > 0 THEN
  485.             IF TIMER - lastShot > .5 THEN
  486.                 lastShot = TIMER
  487.                 score = score + 100
  488.                 sendData server, id_SHOOT, MKI$(target)
  489.                 addParticles player(target).x, player(target).y, 5, _RGB32(255)
  490.                 addParticles player(target).x, player(target).y, 100, colors(player(target).color)
  491.                 thickLine player(me).x + camera.x, player(me).y + camera.y, player(target).x + camera.x, player(target).y + camera.y, 8, _RGB32(227, 78, 6, 80)
  492.             END IF
  493.         END IF
  494.     END IF
  495.  
  496.     updateParticles
  497.  
  498.     'LINE (_WIDTH / 2 - cameraWindow, _HEIGHT / 2 - cameraWindow)-STEP(cameraWindow * 2, cameraWindow * 2), , B
  499.  
  500.     'display warnings
  501.     FOR i = 1 TO UBOUND(warning)
  502.         IF warning(i).state = True THEN
  503.             COLOR _RGB32(0)
  504.             _PRINTSTRING (11, 1 + _HEIGHT / 2 + _FONTHEIGHT * i), warning(i).name
  505.             COLOR _RGB32(238, 50, 22)
  506.             _PRINTSTRING (10, _HEIGHT / 2 + _FONTHEIGHT * i), warning(i).name
  507.             IF TIMER - warning(i).ping > 2.5 THEN warning(i).state = False
  508.         END IF
  509.     NEXT
  510.  
  511.     'display messagebox icon
  512.     IF mode = mode_onlineclient THEN
  513.         _PUTIMAGE (ui(1).x, ui(1).y), messageIcon
  514.         IF hasUnreadMessages THEN
  515.             CircleFill _WIDTH - 50, 10, 8, _RGB32(0)
  516.             CircleFill _WIDTH - 50, 10, 5, _RGB32(205, 6, 0)
  517.         END IF
  518.  
  519.         IF chatOpen THEN
  520.             hasUnreadMessages = False
  521.             LINE (50, 50)-(_WIDTH - 50, _HEIGHT - 50), _RGB32(0, 150), BF
  522.             LINE (50, 50)-(_WIDTH - 50, _HEIGHT - 50), _RGB32(0), B
  523.             _FONT 16
  524.             COLOR _RGB32(0)
  525.             FOR i = 1 TO UBOUND(chat)
  526.                 IF chat(i).state THEN
  527.                     y = 65 + _FONTHEIGHT * ((i - 1) * 2)
  528.                     LINE (55, y - 10)-(_WIDTH - 55, y + 18), _RGB32(255, 80), BF
  529.                     _FONT 8
  530.                     x = 60
  531.                     IF chat(i).id = me THEN x = _WIDTH - 60 - _PRINTWIDTH(chat(i).name)
  532.                     COLOR _RGB32(100)
  533.                     _PRINTSTRING (1 + x, 1 + y - 8), chat(i).name
  534.                     COLOR colors(chat(i).color)
  535.                     _PRINTSTRING (x, y - 8), chat(i).name
  536.                     _FONT 16
  537.                     x = 60
  538.                     IF chat(i).id = me THEN x = _WIDTH - 60 - _PRINTWIDTH(chat(i).text)
  539.                     COLOR _RGB32(100)
  540.                     _PRINTSTRING (1 + x, 1 + y), LEFT$(chat(i).text, (_WIDTH - 100) \ _FONTWIDTH)
  541.                     COLOR _RGB32(255)
  542.                     _PRINTSTRING (x, y), LEFT$(chat(i).text, (_WIDTH - 100) \ _FONTWIDTH)
  543.                 END IF
  544.             NEXT
  545.  
  546.             DIM myMessage$, char$, tooFast AS _BYTE
  547.             CONST messageSpeed = 1.5
  548.             char$ = INKEY$
  549.             SELECT CASE char$
  550.                 CASE CHR$(22) 'ctrl+v
  551.                     myMessage$ = myMessage$ + _CLIPBOARD$
  552.                 CASE " " TO "z"
  553.                     myMessage$ = myMessage$ + char$
  554.                 CASE CHR$(8)
  555.                     IF LEN(myMessage$) THEN
  556.                         myMessage$ = LEFT$(myMessage$, LEN(myMessage$) - 1)
  557.                     END IF
  558.                 CASE CHR$(13)
  559.                     DIM lastSentChat AS SINGLE
  560.                     IF myMessage$ = ">reset" THEN
  561.                         player(me).size = 15
  562.                         sendData server, id_SIZE, MKI$(player(me).size)
  563.                         myMessage$ = ""
  564.                         chatOpen = False
  565.                     ELSEIF myMessage$ = ">big" THEN
  566.                         player(me).size = 25
  567.                         sendData server, id_SIZE, MKI$(player(me).size)
  568.                         myMessage$ = ""
  569.                         chatOpen = False
  570.                     ELSEIF myMessage$ = ">updateserver" THEN
  571.                         'temporary solution for triggering auto-update checks
  572.                         sendData server, id_UPDATESERVER, ""
  573.                         myMessage$ = ""
  574.                         chatOpen = False
  575.                     ELSE
  576.                         IF LEN(myMessage$) > 0 AND TIMER - lastSentChat > messageSpeed THEN
  577.                             lastSentChat = TIMER
  578.                             addMessageToChat me, myMessage$
  579.                             sendData server, id_CHAT, myMessage$
  580.                             myMessage$ = ""
  581.                         ELSEIF LEN(myMessage$) > 0 AND TIMER - lastSentChat < messageSpeed THEN
  582.                             tooFast = True
  583.                         END IF
  584.                     END IF
  585.             END SELECT
  586.  
  587.             COLOR _RGB32(0)
  588.             _PRINTSTRING (61, 61 + _FONTHEIGHT * (i * 2) - 24), "> " + myMessage$ + "_"
  589.             COLOR _RGB32(255)
  590.             _PRINTSTRING (60, 60 + _FONTHEIGHT * (i * 2) - 24), "> " + myMessage$ + "_"
  591.             _FONT 8
  592.  
  593.             IF tooFast THEN
  594.                 DIM s AS INTEGER
  595.                 s = _CEIL(messageSpeed - (TIMER - lastSentChat))
  596.                 m$ = "(too fast - wait" + STR$(s) + " second" + LEFT$("s", ABS(s > 1)) + ")"
  597.                 y = _HEIGHT - 50 - _FONTHEIGHT
  598.                 COLOR _RGB32(0)
  599.                 _PRINTSTRING (61, 1 + y), m$
  600.                 COLOR _RGB32(200, 177, 44)
  601.                 _PRINTSTRING (60, y), m$
  602.                 IF TIMER - lastSentChat > messageSpeed THEN tooFast = False
  603.             END IF
  604.         ELSE
  605.             char$ = INKEY$
  606.             SELECT CASE char$
  607.                 CASE CHR$(13)
  608.                     chatOpen = True
  609.             END SELECT
  610.         END IF
  611.     END IF
  612.  
  613.     DIM mouseIsDown AS _BYTE, mouseDownOn AS INTEGER, mouseWheel AS INTEGER
  614.     DIM mb1 AS _BYTE, mb2 AS _BYTE, mx AS INTEGER, my AS INTEGER
  615.     mouseWheel = 0
  616.         mouseWheel = mouseWheel + _MOUSEWHEEL
  617.         IF _MOUSEBUTTON(1) = mb1 AND _MOUSEBUTTON(2) = mb2 THEN
  618.             DO WHILE _MOUSEINPUT
  619.                 mouseWheel = mouseWheel + _MOUSEWHEEL
  620.                 IF NOT (_MOUSEBUTTON(1) = mb1 AND _MOUSEBUTTON(2) = mb2) THEN EXIT DO
  621.             LOOP
  622.         END IF
  623.         mb1 = _MOUSEBUTTON(1)
  624.         mb2 = _MOUSEBUTTON(2)
  625.         mx = _MOUSEX
  626.         my = _MOUSEY
  627.     END IF
  628.  
  629.     focus = 0
  630.     FOR i = UBOUND(ui) TO 1 STEP -1
  631.         IF mx > ui(i).x AND mx < ui(i).x + ui(i).w AND my > ui(i).y AND my < ui(i).y + ui(i).h THEN
  632.             focus = i
  633.             EXIT FOR
  634.         END IF
  635.     NEXT
  636.  
  637.     IF mb1 THEN
  638.         mouseDownOn = focus
  639.         mouseIsDown = True
  640.     ELSE
  641.         IF mouseIsDown THEN
  642.             IF mouseDownOn THEN
  643.                 SELECT CASE ui(mouseDownOn).name
  644.                     CASE "messageicon"
  645.                         IF mode = mode_onlineclient THEN chatOpen = NOT chatOpen
  646.                 END SELECT
  647.             END IF
  648.         END IF
  649.         mouseIsDown = False
  650.     END IF
  651.  
  652.     IF mode = mode_onlineclient THEN
  653.         _FONT 16
  654.         COLOR _RGB32(0)
  655.         _PRINTSTRING (1, 1), "Score:" + STR$(score)
  656.         COLOR _RGB32(255)
  657.         _PRINTSTRING (0, 0), "Score:" + STR$(score)
  658.         _FONT 8
  659.     END IF
  660.  
  661.     _DISPLAY
  662.     _LIMIT 60
  663.  
  664. SUB addMessageToChat (id AS INTEGER, text$)
  665.     DIM i AS INTEGER
  666.     FOR i = 2 TO UBOUND(chat)
  667.         SWAP chat(i), chat(i - 1)
  668.     NEXT
  669.     chat(UBOUND(chat)).id = id
  670.     chat(UBOUND(chat)).state = True
  671.     IF id > 0 THEN
  672.         chat(UBOUND(chat)).name = player(id).name
  673.         chat(UBOUND(chat)).color = player(id).color
  674.     ELSE
  675.         chat(UBOUND(chat)).name = "SYSTEM:"
  676.         chat(UBOUND(chat)).color = 7
  677.         chatOpen = True
  678.     END IF
  679.     chat(UBOUND(chat)).text = text$
  680.  
  681. SUB addWarning (text$)
  682.     DIM i AS INTEGER
  683.     FOR i = 1 TO UBOUND(warning)
  684.         IF warning(i).state = False THEN
  685.             warning(i).state = True
  686.             warning(i).name = text$
  687.             warning(i).ping = TIMER
  688.             EXIT FOR
  689.         END IF
  690.     NEXT
  691.  
  692. SUB sendData (client AS object, id AS INTEGER, value$)
  693.     DIM packet$
  694.     packet$ = MKI$(id) + value$ + endSignal
  695.     IF client.handle THEN PUT #client.handle, , packet$
  696.  
  697. SUB getData (client AS object, buffer AS STRING)
  698.     DIM incoming$
  699.     GET #client.handle, , incoming$
  700.     buffer = buffer + incoming$
  701.  
  702. FUNCTION parse%% (buffer AS STRING, id AS INTEGER, value$)
  703.     DIM endMarker AS LONG
  704.     endMarker = INSTR(buffer, endSignal)
  705.     IF endMarker THEN
  706.         id = CVI(LEFT$(buffer, 2))
  707.         value$ = MID$(buffer, 3, endMarker - 3)
  708.         buffer = MID$(buffer, endMarker + LEN(endSignal))
  709.         parse%% = True
  710.     END IF
  711.  
  712. SUB adjustCamera
  713.     IF player(me).x + camera.x > _WIDTH / 2 + cameraWindow THEN
  714.         camera.x = _WIDTH / 2 - player(me).x + cameraWindow
  715.     ELSEIF player(me).x + camera.x < _WIDTH / 2 - cameraWindow THEN
  716.         camera.x = _WIDTH / 2 - player(me).x - cameraWindow
  717.     END IF
  718.     IF camera.x > 0 THEN camera.x = 0
  719.     IF camera.x < -(_WIDTH(mapImage) - _WIDTH) THEN camera.x = -(_WIDTH(mapImage) - _WIDTH)
  720.  
  721.     IF player(me).y + camera.y > _HEIGHT / 2 + cameraWindow THEN
  722.         camera.y = _HEIGHT / 2 - player(me).y + cameraWindow
  723.     ELSEIF player(me).y + camera.y < _HEIGHT / 2 - cameraWindow THEN
  724.         camera.y = _HEIGHT / 2 - player(me).y - cameraWindow
  725.     END IF
  726.     IF camera.y > 0 THEN camera.y = 0
  727.     IF camera.y < -(_HEIGHT(mapImage) - _HEIGHT) THEN camera.y = -(_HEIGHT(mapImage) - _HEIGHT)
  728.  
  729.  
  730. SUB CircleFill (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  731.     ' CX = center x coordinate
  732.     ' CY = center y coordinate
  733.     '  R = radius
  734.     '  C = fill color
  735.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  736.     DIM X AS INTEGER, Y AS INTEGER
  737.     Radius = ABS(R)
  738.     RadiusError = -Radius
  739.     X = Radius
  740.     Y = 0
  741.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  742.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  743.     WHILE X > Y
  744.         RadiusError = RadiusError + Y * 2 + 1
  745.         IF RadiusError >= 0 THEN
  746.             IF X <> Y + 1 THEN
  747.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  748.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  749.             END IF
  750.             X = X - 1
  751.             RadiusError = RadiusError - X * 2
  752.         END IF
  753.         Y = Y + 1
  754.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  755.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  756.     WEND
  757.  
  758. SUB db (text$)
  759.     $IF DEBUGGING = TRUE THEN
  760.         _ECHO text$
  761.     $ELSE
  762.         DIM dummy$
  763.         dummy$ = text$
  764.     $END IF
  765.  
  766. FUNCTION dist! (x1!, y1!, x2!, y2!)
  767.     dist! = _HYPOT((x2! - x1!), (y2! - y1!))
  768.  
  769. SUB thickLine (x1 AS SINGLE, y1 AS SINGLE, x2 AS SINGLE, y2 AS SINGLE, lineWeight%, c~&)
  770.     DIM a AS SINGLE, x0 AS SINGLE, y0 AS SINGLE
  771.     DIM prevDest AS LONG
  772.     DIM colorSample AS LONG
  773.  
  774.     colorSample = _NEWIMAGE(1, 1, 32)
  775.  
  776.     prevDest = _DEST
  777.     _DEST colorSample
  778.     PSET (0, 0), c~&
  779.     _DEST prevDest
  780.  
  781.     a = _ATAN2(y2 - y1, x2 - x1)
  782.     a = a + _PI / 2
  783.     x0 = 0.5 * lineWeight% * COS(a)
  784.     y0 = 0.5 * lineWeight% * SIN(a)
  785.  
  786.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), colorSample TO(x1 - x0, y1 - y0)-(x1 + x0, y1 + y0)-(x2 + x0, y2 + y0), , _SMOOTH
  787.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), colorSample TO(x1 - x0, y1 - y0)-(x2 + x0, y2 + y0)-(x2 - x0, y2 - y0), , _SMOOTH
  788.  
  789.     _FREEIMAGE colorSample
  790.  
  791. SUB addParticles (x AS SINGLE, y AS SINGLE, total AS INTEGER, c AS _UNSIGNED LONG)
  792.     DIM addedP AS INTEGER, p AS INTEGER
  793.     DIM a AS SINGLE
  794.  
  795.     addedP = 0: p = 0
  796.     DO
  797.         p = p + 1
  798.         IF p > UBOUND(particle) THEN EXIT DO
  799.         IF particle(p).state = True THEN _CONTINUE
  800.         addedP = addedP + 1
  801.         particle(p).state = True
  802.         particle(p).x = x
  803.         particle(p).y = y
  804.         a = RND * _PI(2)
  805.         particle(p).xv = COS(a) * (RND * 10)
  806.         particle(p).yv = SIN(a) * (RND * 10)
  807.         particle(p).r = _RED32(c)
  808.         particle(p).g = _GREEN32(c)
  809.         particle(p).b = _BLUE32(c)
  810.         particle(p).size = _CEIL(RND * 3)
  811.         particle(p).start = TIMER
  812.         particle(p).duration = RND
  813.     LOOP UNTIL addedP >= total
  814.  
  815. SUB updateParticles
  816.     DIM i AS INTEGER
  817.  
  818.     FOR i = 1 TO UBOUND(particle)
  819.         CONST gravity = .1
  820.         IF particle(i).state THEN
  821.             particle(i).xv = particle(i).xv + particle(i).xa
  822.             particle(i).x = particle(i).x + particle(i).xv
  823.             particle(i).yv = particle(i).yv + particle(i).ya + gravity
  824.             particle(i).y = particle(i).y + particle(i).yv
  825.  
  826.             IF particle(i).x > _WIDTH(mapImage) OR particle(i).x < 0 OR particle(i).y > _HEIGHT(mapImage) OR particle(i).y < 0 THEN
  827.                 particle(i).state = False
  828.             ELSE
  829.                 CircleFill particle(i).x + camera.x, particle(i).y + camera.y, particle(i).size, _RGB32(particle(i).r, particle(i).g, particle(i).b, map(TIMER - particle(i).start, 0, particle(i).duration, 255, 0))
  830.             END IF
  831.         END IF
  832.     NEXT
  833.  
  834. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  835.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  836.  
« Last Edit: October 24, 2020, 04:55:15 pm by FellippeHeitor »

FellippeHeitor

  • Guest
Re: Pretentious not-yet-a-clone clone of Among Us in QB64
« Reply #38 on: October 26, 2020, 01:08:41 am »
Version 3 of the client attached to this post. Notice that previous versions won't be able to connect to the servers now.

 
Captura de Tela 2020-10-26 às 02.09.11.png
* amongst.bas (Filesize: 52.52 KB, Downloads: 94)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Pretentious not-yet-a-clone clone of Among Us in QB64
« Reply #39 on: October 26, 2020, 04:52:25 am »
Question:  Can you have the game simply try to share itself across all three servers, much like IRC and freenode does?  QB64 has a limited user base, and having to divide your chances into thirds to find someone else playing, seems like it'd just make it harder to find others to join with. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline qbkiller101

  • Newbie
  • Posts: 73
    • View Profile
Re: Pretentious not-yet-a-clone clone of Among Us in QB64
« Reply #40 on: October 26, 2020, 06:02:27 am »
Hey, @FellippeHeitor can you add an option on the main screen to choose controls? WASD, arrow keys, or mouse, cuz I can't figure out graphics, I have written the code for movement of each option though.

FellippeHeitor

  • Guest
Re: Pretentious not-yet-a-clone clone of Among Us in QB64
« Reply #41 on: October 26, 2020, 12:32:30 pm »
@SMcNeill We're still researching a way to keep it in sync across clients in the same server, that might at some point be considered. When you're at Discord let me know and I'll tell you in which server I currently am logged in.

@qbkiller101 I'll check it out, thanks!