Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Zeppelin

Pages: [1] 2 3
1
Programs / Re: Intersection of two circles
« on: December 11, 2019, 04:24:45 pm »
Hey everyone,

Heres a WIP voronoi function.
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2.  
  3. cirs = 25
  4.  
  5. DIM cirX(cirs)
  6. DIM cirY(cirs)
  7.  
  8. rad = 25
  9. FOR n = 1 TO cirs
  10.     cirX(n) = INT(RND * _WIDTH - 1) + 1
  11.     cirY(n) = INT(RND * _HEIGHT - 1) + 1
  12.     CIRCLE (cirX(n), cirY(n)), 2
  13.     PAINT (cirX(n), cirY(n)), _RGB(255, 255, 255)
  14.     CIRCLE (cirX(n), cirY(n)), rad
  15.  
  16.     CLS
  17.  
  18.     FOR x = 1 TO cirs
  19.         FOR n = 1 TO cirs
  20.             dist = SQR(((cirX(x) - (cirX(n))) ^ 2) + ((cirY(x) - cirY(n)) ^ 2))
  21.             IF dist <= rad * 2 THEN
  22.                 Dx = cirX(n) - cirX(x)
  23.                 Dy = cirY(n) - cirY(x)
  24.  
  25.                 E = (Dx ^ 2 + Dy ^ 2 + r2 ^ 2 - r1 ^ 2) / (2 * rad)
  26.                 F = (-Dx ^ 2 - Dy ^ 2 + r2 ^ 2 - r1 ^ 2) / (2 * rad)
  27.  
  28.                 a = Dx / E
  29.                 b = Dy / E
  30.                 c = Dx / F
  31.                 d = Dy / F
  32.  
  33.                 cosbetap = (a + b * SQR(a ^ 2 + b ^ 2 - 1)) / (a ^ 2 + b ^ 2)
  34.                 sinbetap = (b + a * SQR(a ^ 2 + b ^ 2 - 1)) / (a ^ 2 + b ^ 2)
  35.                 cosbetam = (a - b * SQR(a ^ 2 + b ^ 2 - 1)) / (a ^ 2 + b ^ 2)
  36.                 sinbetam = (b - a * SQR(a ^ 2 + b ^ 2 - 1)) / (a ^ 2 + b ^ 2)
  37.  
  38.                 cosalphap = (c + d * SQR(c ^ 2 + d ^ 2 - 1)) / (c ^ 2 + d ^ 2)
  39.                 sinalphap = (d + c * SQR(c ^ 2 + d ^ 2 - 1)) / (c ^ 2 + d ^ 2)
  40.                 cosalpham = (c - d * SQR(c ^ 2 + d ^ 2 - 1)) / (c ^ 2 + d ^ 2)
  41.                 sinalpham = (d - c * SQR(c ^ 2 + d ^ 2 - 1)) / (c ^ 2 + d ^ 2)
  42.  
  43.                 ipX = cirX(n) + rad * cosalphap
  44.                 ipY = cirY(n) + rad * sinalpham
  45.  
  46.                 ipX2 = cirX(x) + rad * cosbetap
  47.                 ipY2 = cirY(x) + rad * sinbetam
  48.  
  49.  
  50.                 LINE (ipX, ipY)-(ipX2, ipY2), _RGB(0, 0, 255)
  51.             END IF
  52.  
  53.         NEXT n
  54.     NEXT x
  55.  
  56.     rad = rad + 1
  57.     _DELAY (0.1)
  58.  
  59. LOOP UNTIL rad = 500
  60.  
  61. PRINT "DONE"
  62.  

Zep

2
Programs / Re: _PUT Rotation Help
« on: December 06, 2019, 02:08:56 am »
Thanks bPlus,
Your method seems alot more efficient.

Zep

3
Programs / _PUT Rotation Help
« on: December 05, 2019, 05:51:00 pm »
Hey Everyone,
Here's a piece I've been working on for awhile now but in the Infinite sub I'm trying to get the 'sword' to make a full rotation and end up under the character during the jump, but it seems to just keep spinning and stopping at random points. Not too sure what I'm doing wrong.
 
Code: QB64: [Select]
  1. '+-------------------+
  2. '        SLAY
  3. ' ZEPPELIN GAMES 2019
  4. '+-------------------+
  5.  
  6. _TITLE "SLAY" 'SET TITLE
  7. _FULLSCREEN 'SET FULLSCREEN
  8. SCREEN _NEWIMAGE(1200, 800, 32)
  9.  
  10. 'DECLARE VARIABLES
  11. 'SAVE DATA VARS
  12. DIM SHARED saveData$(1000)
  13.  
  14. 'PLAYER VARS
  15. DIM SHARED player%(100000)
  16. DIM SHARED sword%(100000)
  17. DIM SHARED player.health AS INTEGER
  18. DIM SHARED player.basehealth AS INTEGER
  19. DIM SHARED playerScale AS INTEGER
  20. playerScale = 15
  21.  
  22.  
  23. 'PLAYER STATS
  24. DIM SHARED stats.enemyskilled AS INTEGER
  25. DIM SHARED stats.totaldeaths AS INTEGER
  26.  
  27. 'SCREEN AND FORMATTING VARS
  28.  
  29.  
  30. 'GET THE SCREEN DIMSENSIONS
  31. w = _WIDTH
  32.  
  33. 'FONT DATA
  34.  
  35. 'SET THE COLOR
  36. col = _RGBA(255, 255, 255, 255)
  37.  
  38. 'START GAME
  39. LoadData
  40.  
  41. SUB LoadData
  42.     'LOAD SAVE DATA
  43.  
  44.     'LOAD PLAYER SPRITE
  45.     LoadSprite player%(), playerScale
  46.     LoadSprite sword%(), playerScale / 1.2
  47.  
  48.     IF _FILEEXISTS("SlayV4SaveData.txt") THEN 'SEE IF THE FILE EXISTS
  49.         OPEN "SlayV4SaveData.txt" FOR INPUT AS #1
  50.         DO UNTIL EOF(1) 'LOOP UNTIL END OF FILE
  51.             _LIMIT 60
  52.             filecount = filecount + 1 'COUNT AMOUNT OF LINES
  53.             LINE INPUT #1, file$
  54.             saveData$(filecount) = file$
  55.         LOOP
  56.         CLOSE #1
  57.  
  58.         IF filecount > 2 THEN
  59.             'PLAYER
  60.  
  61.             'DECRYPT NAME
  62.             name$ = ""
  63.             FOR n = 1 TO LEN(saveData$(1)) STEP 2
  64.                 name$ = name$ + CHR$(ASC(MID$(saveData$(1), n, 1)) - 4)
  65.             NEXT n
  66.  
  67.             'DECRYPT STATS
  68.             'HEALTH
  69.             health$ = ""
  70.             FOR n = 1 TO LEN(saveData$(2)) STEP 2
  71.                 health$ = health$ + CHR$(ASC(MID$(saveData$(2), n, 1)) - 4)
  72.             NEXT n
  73.  
  74.             player.name = UCASE$(name$) 'LOAD NAME
  75.             player.basehealth = VAL(health$) 'LOAD BASE HEALTH
  76.             player.health = player.basehealth 'SET PLAYER HEALTH
  77.             'SAVE DATA
  78.             save.point = VAL(saveData$(3)) 'LOAD SAVE POINT
  79.             'STATS
  80.             stats.enemyskilled = VAL(saveData$(4)) 'ENEMYS KILLED
  81.             stats.totaldeaths = VAL(saveData$(5)) 'TOTAL DEATHS
  82.         ELSE
  83.             CreateNewSave
  84.         END IF
  85.     ELSE
  86.         CreateNewSave
  87.     END IF
  88.  
  89.     'START GAME
  90.     _DELAY (1)
  91.     DrawLogo
  92.  
  93. SUB CreateNewSave
  94.     'CREATE NEW SAVE FILE
  95.     scaledText w / 2 - 65, h / 2 + 8, 16, _RGBA(255, 255, 255, 255), "Enter your name: "
  96.     DO
  97.         _LIMIT 60
  98.         LOCATE (h / 2 - 248) / fh + hf, (w / 2 - 50) / fw + fw: INPUT "", name$
  99.     LOOP UNTIL LEN(name$) > 1
  100.     IF LEN(name$) > 16 THEN
  101.         CLS
  102.         _PRINTSTRING (w / 2 - 150, h / 2), "Name length should be less than 16 characters"
  103.         _DELAY (2)
  104.         CLS
  105.         LoadData
  106.     END IF
  107.  
  108.     'SET VARS
  109.     player.name = UCASE$(name$)
  110.     player.health = 100
  111.  
  112.     save.point = 0
  113.     stats.enemyskilled = 0
  114.     stats.totaldeaths = 0
  115.  
  116.     'ENCRYPT SAVE DATA
  117.     'NAME
  118.     DIM nameArray$(16)
  119.     FOR n = 1 TO LEN(player.name)
  120.         nameArray$(n) = MID$(player.name, n, 1)
  121.     NEXT n
  122.  
  123.     FOR n = 1 TO LEN(player.name)
  124.         tempName$ = tempName$ + CHR$(ASC(nameArray$(n)) + 4)
  125.         tempName$ = tempName$ + CHR$(INT(RND * 100) + 100)
  126.     NEXT n
  127.  
  128.     name$ = tempName$
  129.  
  130.     'ENCRYPT STATS
  131.     'HEALTH
  132.     DIM healthArray$(5)
  133.     FOR n = 1 TO LEN(STR$(player.health))
  134.         healthArray$(n) = MID$(STR$(player.health), n, 1)
  135.     NEXT n
  136.  
  137.     FOR n = 1 TO LEN(STR$(player.health))
  138.         tempHealth$ = tempHealth$ + CHR$(ASC(healthArray$(n)) + 4)
  139.         tempHealth$ = tempHealth$ + CHR$(INT(RND * 100) + 100)
  140.     NEXT n
  141.  
  142.     'SAVE VARS TO TXT
  143.     OPEN "SlayV4SaveData.txt" FOR OUTPUT AS #1
  144.     'PLAYER
  145.     PRINT #1, name$
  146.     PRINT #1, tempHealth$
  147.     'SAVE DATA
  148.     PRINT #1, save.point
  149.     'STATS
  150.     PRINT #1, stats.enemyskilled
  151.     PRINT #1, stats.totaldeaths
  152.     CLOSE #1
  153.     CLS
  154.  
  155. SUB DrawLogo
  156.     'FADE LOGO IN
  157.     FOR n = 0 TO 255
  158.         'LIMIT FPS
  159.         _LIMIT 60
  160.  
  161.         LINE (w / 10 * 2, h / 10 * 7)-(w / 10 * 8, h / 10 * 8), _RGB(0, 0, 0), BF
  162.         scaledText w / 2, h / 2, 500, _RGBA32(255, 255, 255, n), "Z"
  163.         scaledText w / 2, h / 6 * 4.5, 50, _RGBA(255, 255, 255, n), "ZEPPELIN GAMES"
  164.         _DISPLAY
  165.     NEXT n
  166.  
  167.     scaledText w / 2, h / 2, 500, _RGBA32(255, 255, 255, 255), "Z"
  168.     scaledText w / 2, h / 6 * 4.5, 50, _RGBA32(255, 255, 255, 255), "ZEPPELIN GAMES"
  169.     _DISPLAY
  170.     _DELAY (3) 'WAIT A BIT
  171.  
  172.     'FADE THE LOGO AND TEXT OUT
  173.     FOR n = 0 TO 255
  174.         'LIMIT FPS
  175.         _LIMIT 60
  176.  
  177.         LINE (w / 10 * 2, h / 10 * 7)-(w / 10 * 8, h / 10 * 8), _RGB(0, 0, 0), BF
  178.         scaledText w / 2, h / 2, 500, _RGBA32(255, 255, 255, 255 - n), "Z"
  179.         scaledText w / 2, h / 6 * 4.5, 50, _RGBA(255, 255, 255, 255 - n), "ZEPPELIN GAMES"
  180.         _DISPLAY
  181.     NEXT n
  182.     CLS
  183.     _DISPLAY
  184.     DrawMenu
  185.  
  186. SUB DrawMenu
  187.     'FADE IN MENU SCREEN
  188.     DIM col AS LONG
  189.     col = _RGBA(255, 255, 255, 255)
  190.     'S
  191.     LINE (w / 10 * 2.75, h / 10 * 1.5)-(w / 10 * 3.5, h / 10 * 1.75), col, BF '1ST ACROSS
  192.     LINE (w / 10 * 2.75, h / 10 * 1.5)-(w / 10 * 3, h / 10 * 2.5), col, BF '1ST DOWN
  193.     LINE (w / 10 * 2.75, h / 10 * 2.5)-(w / 10 * 3.45, h / 10 * 2.75), col, BF '2ND ACROSS
  194.     LINE (w / 10 * 3.2, h / 10 * 2.75)-(w / 10 * 3.45, h / 10 * 2.9), col, BF '2ND DOWN
  195.     LINE (w / 10 * 3.2, h / 10 * 3.35)-(w / 10 * 3.45, h / 10 * 3.75), col, BF 'EXTENDED 2ND DOWN
  196.     LINE (w / 10 * 2.65, h / 10 * 3.75)-(w / 10 * 3.45, h / 10 * 4.1), col, BF '3RD ACROSS
  197.  
  198.     'L
  199.     LINE (w / 10 * 3.8, h / 10 * 1.5)-(w / 10 * 4.05, h / 10 * 2.65), col, BF '1ST DOWN
  200.     LINE (w / 10 * 3.8, h / 10 * 3.6)-(w / 10 * 4.05, h / 10 * 3.75), col, BF 'EXTENDED 1ST DOWN
  201.     LINE (w / 10 * 3.8, h / 10 * 3.75)-(w / 10 * 4.6, h / 10 * 4.1), col, BF '1ST ACROSS
  202.  
  203.     'A
  204.     LINE (w / 10 * 4.85, h / 10 * 1.5)-(w / 10 * 5.1, h / 10 * 2.7), col, BF 'LEFT DOWN
  205.     LINE (w / 10 * 4.85, h / 10 * 1.5)-(w / 10 * 5.75, h / 10 * 1.8), col, BF 'TOP LINE
  206.     LINE (w / 10 * 5.5, h / 10 * 1.5)-(w / 10 * 5.75, h / 10 * 2.7), col, BF 'RIGHT DOWN
  207.     LINE (w / 10 * 5.55, h / 10 * 1.5)-(w / 10 * 5.75, h / 10 * 2.9), col, BF 'RIGHT DOWN EDGE
  208.     LINE (w / 10 * 4.85, h / 10 * 2.4)-(w / 10 * 5.75, h / 10 * 2.65), col, BF 'MIDDLE LINE
  209.     LINE (w / 10 * 4.85, h / 10 * 3.5)-(w / 10 * 5.1, h / 10 * 4.1), col, BF 'EXTENDED LEFT DOWN
  210.     LINE (w / 10 * 5.5, h / 10 * 3.5)-(w / 10 * 5.75, h / 10 * 4.1), col, BF 'EXTENDED RIGHT DOWN
  211.     LINE (w / 10 * 5.55, h / 10 * 3.35)-(w / 10 * 5.75, h / 10 * 4.1), col, BF 'EXTENDED RIGHT DOWN EDGE
  212.  
  213.     'Y
  214.     LINE (w / 10 * 6, h / 10 * 1.5)-(w / 10 * 6.25, h / 10 * 2.75), col, BF 'LEFT DOWN
  215.     LINE (w / 10 * 6.75, h / 10 * 1.5)-(w / 10 * 7, h / 10 * 3), col, BF 'RIGHT DOWN
  216.     LINE (w / 10 * 6, h / 10 * 2.5)-(w / 10 * 7, h / 10 * 2.85), col, BF '1ST ACROSS
  217.     LINE (w / 10 * 6.75, h / 10 * 3.25)-(w / 10 * 7, h / 10 * 4.1), col, BF 'EXTENDED RIGHT DOWN
  218.     LINE (w / 10 * 6, h / 10 * 3.8)-(w / 10 * 7, h / 10 * 4.1), col, BF 'BOTTOM LINE
  219.  
  220.     'SWORD
  221.     LINE (w / 10 * 3, h / 10 * 3)-(w / 10 * 6.5, h / 10 * 3.25), col, BF 'HILT
  222.     LINE (w / 10 * 3.5, h / 10 * 2.5)-(w / 10 * 3.75, h / 10 * 3.75), col, BF 'Hand Guard
  223.     LINE (w / 10 * 3.75, h / 10 * 2.75)-(w / 10 * 4.75, h / 10 * 3.50), col, BF 'Blade First Layer
  224.     LINE (w / 10 * 4.75, h / 10 * 2.85)-(w / 10 * 5.5, h / 10 * 3.4), col, BF 'Blade 2nd Layer
  225.     LINE (w / 10 * 5.5, h / 10 * 3.10)-(w / 10 * 7, h / 10 * 3.15), col, BF 'Tip of Blade
  226.  
  227.     col = _RGBA(0, 0, 0, 255)
  228.     LINE (w / 10, h / 10 * 4.5)-(w, h / 10 * 7), col, BF 'CLEAR OPTIONS
  229.  
  230.     'SHOW ACCOUNT
  231.     _PRINTSTRING (5, 5), player.name
  232.  
  233.     'PRINT MENU OPTIONS
  234.     scaledText w / 2, h / 10 * 4.75, 25, _RGBA(255, 255, 255, 255), "SINGLE-PLAYER"
  235.     scaledText w / 2, h / 10 * 5.25, 25, _RGBA(255, 255, 255, 255), "MULTI-PLAYER"
  236.     scaledText w / 2, h / 10 * 5.75, 25, _RGBA(255, 255, 255, 255), "OPTIONS"
  237.     scaledText w / 2, h / 10 * 6.25, 25, _RGBA(255, 255, 255, 255), "QUIT"
  238.     scaledText w / 2, h / 10 * 9.5, 14, _RGBA(255, 255, 255, 255), "TIP: USE 'w' AND 's' TO NAVIGATE. PRESS 'ENTER' TO SELCT"
  239.  
  240.     'PICK MENU OPTION
  241.     opt = 0
  242.     col = _RGBA(0, 0, 0, 255)
  243.     DO
  244.         _LIMIT 60
  245.         LINE (w / 2 - 90, h / 10 * 4.5)-(w / 2 - 110, h / 10 * 7), col, BF 'CLEAR PAST POINTERS
  246.         _PRINTSTRING (w / 2 - 100, h / 10 * (4.6 + (0.52 * opt))), ">" 'DISPLAY POINTER
  247.         _DISPLAY 'REDUCE FLICKERING
  248.  
  249.         SELECT CASE INKEY$
  250.             CASE "s", "S" 'MOVE POINTER DOWN
  251.                 IF opt + 1 = 4 THEN
  252.                     opt = 0
  253.                 ELSE
  254.                     opt = opt + 1
  255.                 END IF
  256.  
  257.             CASE "w", "W" 'MOVE POINTER UP
  258.                 IF opt - 1 = -1 THEN
  259.                     opt = 3
  260.                 ELSE
  261.                     opt = opt - 1
  262.                 END IF
  263.  
  264.             CASE CHR$(13) 'ENTER KEY
  265.                 'SINGLE-PLAYER SELECTED
  266.                 IF opt = 0 THEN
  267.                     SinglePlayerMenu
  268.                 END IF
  269.  
  270.                 'MULTI-PLAYER SELECTED
  271.                 IF opt = 1 THEN
  272.                     MultiplayerGameMenu
  273.                 END IF
  274.  
  275.                 'OPTIONS SELETED
  276.                 IF opt = 2 THEN
  277.                     OptionsMenu
  278.                 END IF
  279.  
  280.                 'QUIT SELECTED
  281.                 IF opt = 3 THEN
  282.                     SYSTEM
  283.                 END IF
  284.         END SELECT
  285.     LOOP
  286.  
  287.  
  288. SUB OptionsMenu
  289.     LINE (w / 10, h / 10 * 4.5)-(w, h / 10 * 7), col, BF 'CLEAR OPTIONS
  290.     scaledText w / 2, h / 10 * 4.75, 25, _RGBA(255, 255, 255, 255), "INFO"
  291.     scaledText w / 2, h / 10 * 5.25, 25, _RGBA(255, 255, 255, 255), "RESET GAME"
  292.     scaledText w / 2, h / 10 * 5.75, 25, _RGBA(255, 255, 255, 255), "BACK"
  293.     scaledText w / 2, h / 10 * 9.5, 14, _RGBA(255, 255, 255, 255), "TIP: USE 'w' AND 's' TO NAVIGATE. PRESS 'ENTER' TO SELCT"
  294.  
  295.     opt = 0
  296.     DO
  297.         _LIMIT 60
  298.         LINE (w / 2 - 90, h / 10 * 4.5)-(w / 2 - 110, h / 10 * 7), col, BF 'CLEAR PAST POINTERS
  299.         _PRINTSTRING (w / 2 - 100, h / 10 * (4.6 + (0.52 * opt))), ">" 'DISPLAY POINTER
  300.  
  301.         _DISPLAY 'REDUCE FLICKERING
  302.  
  303.         SELECT CASE INKEY$
  304.             CASE "s", "S" 'MOVE POINTER DOWN
  305.                 IF opt + 1 = 3 THEN
  306.                     opt = 0
  307.                 ELSE
  308.                     opt = opt + 1
  309.                 END IF
  310.  
  311.             CASE "w", "W" 'MOVE POINTER UP
  312.                 IF opt - 1 = -1 THEN
  313.                     opt = 2
  314.                 ELSE
  315.                     opt = opt - 1
  316.                 END IF
  317.             CASE CHR$(13) 'ENTER PRESSED
  318.                 IF opt = 0 THEN 'GAME INFO
  319.                     LINE (0, h / 10 * 4.7)-(w, h), col, BF 'CLEAR OPTIONS
  320.                     scaledText w / 2, h / 10 * 4.75, 25, _RGBA(255, 255, 255, 255), "ZEPPELIN GAMES 2018"
  321.                     scaledText w / 2, h / 10 * 5.25, 25, _RGBA(255, 255, 255, 255), "SLAY V4"
  322.                     scaledText w / 2, h / 10 * 6.25, 25, _RGBA(255, 255, 255, 255), "ENEMIES KILLED: " + STR$(stats.enemyskilled)
  323.                     scaledText w / 2, h / 10 * 6.75, 25, _RGBA(255, 255, 255, 255), "TOTAL DEATHS: " + STR$(stats.totaldeaths)
  324.                     scaledText w / 2, h / 10 * 9.25, 14, _RGBA(255, 255, 255, 255), "PRESS ANY KEY TO CONTINUE"
  325.  
  326.                     _DISPLAY
  327.                     DO WHILE INKEY$ = ""
  328.                     LOOP
  329.                     LINE (0, h / 10 * 4.7)-(w, h), col, BF 'CLEAR OPTIONS
  330.                     OptionsMenu
  331.                 END IF
  332.                 IF opt = 1 THEN 'RESET GAME
  333.                     OPEN "SlayV4SaveData.txt" FOR OUTPUT AS #1
  334.                     PRINT #1, ""
  335.                     CLOSE #1
  336.                     CLS
  337.                     RUN "SLAY V4.exe"
  338.                 END IF
  339.                 IF opt = 2 THEN 'BACK
  340.                     DrawMenu
  341.                 END IF
  342.         END SELECT
  343.     LOOP
  344.  
  345. SUB SinglePlayerMenu
  346.     col = _RGBA(0, 0, 0, 255)
  347.     LINE (w / 10, h / 10 * 4.5)-(w, h / 10 * 7), col, BF 'CLEAR OPTIONS
  348.     scaledText w / 2, h / 10 * 4.75, 25, _RGBA(255, 255, 255, 255), "CAMPAIGN"
  349.     scaledText w / 2, h / 10 * 5.25, 25, _RGBA(255, 255, 255, 255), "INFINITE"
  350.     scaledText w / 2, h / 10 * 5.75, 25, _RGBA(255, 255, 255, 255), "BACK"
  351.     scaledText w / 2, h / 10 * 9.5, 14, _RGBA(255, 255, 255, 255), "TIP: USE 'w' AND 's' TO NAVIGATE. PRESS 'ENTER' TO SELCT"
  352.  
  353.     opt = 0
  354.     DO
  355.         _LIMIT 60
  356.         LINE (w / 2 - 90, h / 10 * 4.5)-(w / 2 - 110, h / 10 * 7), col, BF 'CLEAR PAST POINTERS
  357.         _PRINTSTRING (w / 2 - 100, h / 10 * (4.6 + (0.52 * opt))), ">" 'DISPLAY POINTER
  358.  
  359.         _DISPLAY 'REDUCE FLICKERING
  360.  
  361.         SELECT CASE INKEY$
  362.             CASE "s", "S" 'MOVE POINTER DOWN
  363.                 IF opt + 1 = 3 THEN
  364.                     opt = 0
  365.                 ELSE
  366.                     opt = opt + 1
  367.                 END IF
  368.  
  369.             CASE "w", "W" 'MOVE POINTER UP
  370.                 IF opt - 1 = -1 THEN
  371.                     opt = 2
  372.                 ELSE
  373.                     opt = opt - 1
  374.                 END IF
  375.             CASE CHR$(13) 'ENTER PRESSED
  376.                 IF opt = 0 THEN
  377.                     Campaign
  378.                 END IF
  379.                 IF opt = 1 THEN
  380.                     Infinite
  381.                 END IF
  382.                 IF opt = 2 THEN
  383.                     DrawMenu
  384.                 END IF
  385.         END SELECT
  386.     LOOP
  387.  
  388. 'CAMPAIGN - STORY
  389. SUB Campaign
  390.  
  391.  
  392. 'PRACTICE - GAMEMODE
  393. SUB Infinite
  394.     CLS
  395.     'DEFINE LOCAL VARS
  396.  
  397.     DIM health
  398.     DIM deltaTime
  399.  
  400.     DIM swordX
  401.     DIM swordY
  402.  
  403.     DIM swing
  404.     DIM angle
  405.  
  406.     playerSpeed = 500
  407.     jumpHeight = 150
  408.     health = 100
  409.     jump = 0
  410.     pX = _WIDTH / 2 - (playerScale * 2.5)
  411.     pY = _HEIGHT / 10 * 8
  412.  
  413.     swordX = pX
  414.     swordY = pY + (playerScale * 5)
  415.  
  416.     sTime = TIMER
  417.  
  418.     DO
  419.         _LIMIT 120
  420.         sTime = TIMER(0.001)
  421.         IF _KEYDOWN(100) THEN
  422.             pX = pX + playerSpeed / 100
  423.             IF pX > _WIDTH - (playerScale * 12) - 1 THEN pX = _WIDTH - (playerScale * 12) - 1
  424.         END IF
  425.         IF _KEYDOWN(97) THEN
  426.             pX = pX - playerSpeed / 100
  427.             IF pX < (playerScale * 12) THEN pX = (playerScale * 12)
  428.         END IF
  429.         IF _KEYDOWN(32) THEN
  430.             IF jump = 0 THEN
  431.                 jump = 1
  432.             END IF
  433.         END IF
  434.  
  435.         IF jump >= 1 THEN
  436.             IF pY > ((_HEIGHT / 10) * 8) - jumpHeight AND NOT jump = 2 THEN
  437.                 pY = pY - playerSpeed / 100
  438.  
  439.                 'Spin Sword
  440.                 swing = 1
  441.                 swordX = pX + ((playerScale * 6) * COS(_D2R(angle)))
  442.                 swordY = pY + ((playerScale * 6) * SIN(_D2R(angle)))
  443.             ELSE
  444.  
  445.                 IF pY <= (_HEIGHT / 10) * 8 THEN
  446.                     jump = 2
  447.                     pY = pY + playerSpeed / 100
  448.  
  449.                     'Spin Sword
  450.                     swing = 1
  451.                     swordX = pX + ((playerScale * 6) * COS(_D2R(angle)))
  452.                     swordY = pY + ((playerScale * 6) * SIN(_D2R(angle)))
  453.  
  454.                 ELSE
  455.                     jump = 0
  456.                     swing = 0
  457.                     pY = (_HEIGHT / 10) * 8
  458.                 END IF
  459.             END IF
  460.         END IF
  461.  
  462.         IF swing = 1 THEN
  463.             angle = angle + (jumpHeight / 100)
  464.         END IF
  465.  
  466.         LINE (pX - (playerScale * 10) - 10, pY - (playerScale * 12) - 10)-(pX + ((playerScale * 10) * 2) + 10, pY + (playerScale * 10) + 10), _RGB(0, 0, 0), BF
  467.  
  468.         PUT (pX, pY), player%()
  469.         PUT (swordX, swordY), sword%()
  470.         _DISPLAY
  471.  
  472.         eTime = TIMER(0.001)
  473.         deltaTime = eTime - sTime
  474.  
  475.     LOOP UNTIL health <= 0 OR INKEY$ = CHR$(27)
  476.     CLS
  477.     SaveGame
  478.     DrawMenu
  479.  
  480. 'MULTIPLAYER GAME MENU
  481. SUB MultiplayerGameMenu
  482.     LINE (w / 10, h / 10 * 4.7)-(w, h / 10 * 7), col, BF 'CLEAR OPTIONS
  483.     _PRINTSTRING (w / 2 - 40, h / 10 * 4.75), "LOCAL"
  484.     _PRINTSTRING (w / 2 - 34, h / 10 * 5.25), "LAN"
  485.     _PRINTSTRING (w / 2 - 37, h / 10 * 5.75), "BACK"
  486.  
  487.     opt = 0
  488.     DO
  489.         LINE (w / 2 - 58, h / 10 * 4.7)-(w / 2 - 70, h / 10 * 7), col, BF 'CLEAR PAST POINTERS
  490.         _PRINTSTRING (w / 2 - 65, h / 10 * (4.75 + (0.5 * opt))), ">" 'DISPLAY POINTER
  491.  
  492.         _DISPLAY 'REDUCE FLICKERING
  493.  
  494.         SELECT CASE INKEY$
  495.             CASE "s" 'MOVE POINTER DOWN
  496.                 IF opt + 1 = 3 THEN
  497.                     opt = 0
  498.                 ELSE
  499.                     opt = opt + 1
  500.                 END IF
  501.  
  502.             CASE "w" 'MOVE POINTER UP
  503.                 IF opt - 1 = -1 THEN
  504.                     opt = 2
  505.                 ELSE
  506.                     opt = opt - 1
  507.                 END IF
  508.             CASE CHR$(13) 'ENTER KEY
  509.                 IF opt = 0 THEN
  510.                     LocalMultiplayer
  511.                 ELSEIF opt = 1 THEN
  512.                     LANMultiplayer
  513.                 ELSEIF opt = 2 THEN
  514.                     DrawMenu
  515.                 END IF
  516.         END SELECT
  517.     LOOP UNTIL INKEY$ = CHR$(13)
  518.  
  519.  
  520. 'MULTIPLAYER ON SAME DEVICE
  521. SUB LocalMultiplayer
  522.  
  523.  
  524. 'MULTIPLAYER OVER WIFI CONNECTION
  525. SUB LANMultiplayer
  526.  
  527.  
  528.  
  529. SUB SaveGame
  530.     'SAVE VARS TO TXT
  531.     OPEN "SlayV4SaveData.txt" FOR OUTPUT AS #1
  532.     'PLAYER
  533.     PRINT #1, name$
  534.     PRINT #1, player.health
  535.     'SAVE DATA
  536.     PRINT #1, save.point
  537.     'STATS
  538.     PRINT #1, stats.enemyskilled
  539.     PRINT #1, stats.totaldeaths
  540.     CLOSE #1
  541.  
  542. SUB LoadSprite (sp%(), scale)
  543.     DIM sprite(4, 4)
  544.     FOR y = 0 TO 4
  545.         FOR x = 0 TO 4
  546.             READ sprite(x, y) 'Read the data
  547.         NEXT x
  548.     NEXT y
  549.  
  550.     FOR y = 0 TO 4 * scale STEP scale 'Factor in the scale
  551.         FOR x = 0 TO 4 * scale STEP scale
  552.             spriteCol = sprite(x / scale, y / scale)
  553.             LINE (x, y)-(x + scale, y + scale), _RGB(spriteCol * 255, spriteCol * 255, spriteCol * 255), BF 'Draw each pixel
  554.         NEXT x
  555.     NEXT y
  556.  
  557.     GET (0, 0)-(scale * 5, scale * 5), sp%()
  558.     CLS
  559.  
  560.     'Player Data
  561.     DATA 0,1,1,1,0
  562.     DATA 0,1,1,1,0
  563.     DATA 1,1,1,1,1
  564.     DATA 0,1,1,1,0
  565.     DATA 0,1,0,1,0
  566.  
  567.     'Sword Data
  568.     DATA 0,0,1,0,0
  569.     DATA 1,1,1,1,1
  570.     DATA 0,1,1,1,0
  571.     DATA 0,1,1,1,0
  572.     DATA 0,0,1,0,0
  573.  
  574. SUB scaledText (x, y, textHeight, K AS _UNSIGNED LONG, txt$)
  575.     fg = _DEFAULTCOLOR
  576.     'screen snapshot
  577.     cur& = _DEST
  578.     I& = _NEWIMAGE(8 * LEN(txt$), 16, 32)
  579.     _DEST I&
  580.     COLOR K, _RGBA32(0, 0, 0, 0)
  581.     _PRINTSTRING (0, 0), txt$
  582.     mult = textHeight / 16
  583.     xlen = LEN(txt$) * 8 * mult
  584.     _PUTIMAGE (x - .5 * xlen, y - .5 * textHeight)-STEP(xlen, textHeight), I&, cur&
  585.     COLOR fg
  586.     _FREEIMAGE I&

Thanks,
Zep

4
Programs / Re: Drawing Polygons
« on: November 26, 2019, 04:47:45 am »
Thanks bPlus,
It's always a small issue that underpins what could've been :D

Zep

5
Programs / Drawing Polygons
« on: November 25, 2019, 11:11:36 pm »
Hey all,
I've been trying to make a program that can draw any polygon (pentagon, octagon, pentacontagon, etc...), although I can't get it to work.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. l = 100
  3. s = 8
  4.  
  5. angle = (360 / s)
  6. lx = (_WIDTH / 2) + ((COS(angle)) * l)
  7. ly = (_HEIGHT / 2) + ((SIN(angle)) * l)
  8.  
  9. FOR n = 1 TO s
  10.     x = (_WIDTH / 2) + ((COS(angle)) * l)
  11.     y = (_HEIGHT / 2) + ((SIN(angle)) * l)
  12.  
  13.     LINE (lx, ly)-(x, y), _RGB(255, 255, 255)
  14.  
  15.     lx = x
  16.     ly = y
  17.  
  18.     angle = (360 / s) * n
  19.     PRINT angle
  20.  

l is the length of each line
s is the amount of sides i want.

No matter what I do either the shape doesnt line up or it overlaps.

Thanks,
Zep

6
Programs / Re: Mini Messenger
« on: November 18, 2019, 05:55:15 pm »
SMcNeill,
First off just wanna say thanks for actually getting TCP/IP to work. I've tried many times with the examples on the wiki.

Code: QB64: [Select]
  1. DIM SHARED Users(1 TO 1000) ' array to hold other client info
  2. DIM SHARED NumClients
  3.  
  4.  
  5. PRINT "[Steve's Mini Messenger]"
  6. host = _OPENHOST("TCP/IP:7319") ' no host found, so begin new host
  7. IF host THEN
  8.     PRINT "[Beginning new host chat session!]"
  9.     NumClients = 0
  10.     client = _OPENCLIENT("TCP/IP:7319:localhost")
  11.     IF client = 0 THEN PRINT "ERROR: could not attach host's personal client to host!"
  12.     INPUT "Enter your name:", myname$
  13.     'PRINT #client, myname$ + " connected!"
  14.     PRINT "[Chat session active!]"
  15.     PRINT "ERROR: Could not begin new host!"
  16.     PRINT "JOINING as CLIENT"
  17.  
  18.     'Join as client
  19.     client = _OPENCLIENT("TCP/IP:7319:localhost") ' Attempt to connect to local host as a client
  20. END IF ' host
  21.  
  22. IF host THEN
  23.     _TITLE "HOST"
  24.     DO ' host main loop
  25.         newclient = _OPENCONNECTION(host) ' receive any new connection
  26.         IF newclient THEN
  27.             NumClients = NumClients + 1
  28.             Users(NumClients) = newclient
  29.             PRINT "Welcome to Steve's Mini Messenger!"
  30.         END IF
  31.         FOR i = 1 TO NumClients
  32.             GetMessage Users(i) 'check all clients for a message
  33.             IF OUT$ <> "" THEN
  34.                 l = LEN(OUT$)
  35.                 FOR j = 1 TO NumClients ' distribute incoming messages to all clients
  36.                     PUT #Users(j), , l
  37.                     PUT #Users(j), , OUT$
  38.                 NEXT
  39.             END IF
  40.         NEXT i
  41.  
  42.         SendMessage myname$, mymessage$, client
  43.         _LIMIT 30
  44.     LOOP
  45.  
  46. IF client THEN
  47.     INPUT "Enter your name: ", myname$
  48.     OUT$ = myname$ + " connected!"
  49.     l = LEN(OUT$)
  50.     PUT #client, , l
  51.     PUT #client, , OUT$
  52.  
  53.     _TITLE "CLIENT"
  54.     DO
  55.         GetMessage client
  56.         SendMessage myname$, mymessage$, client ' display current input on screen
  57.         _LIMIT 30
  58.     LOOP
  59.  
  60.  
  61. SUB GetMessage (client) ' get & display any new message
  62.     GET #client, , l
  63.     IF l > 0 THEN
  64.         OUT$ = SPACE$(l)
  65.         GET #client, , OUT$
  66.         VIEW PRINT 1 TO 20
  67.         LOCATE 20, 1
  68.         PRINT OUT$
  69.         VIEW PRINT 1 TO 24
  70.     ELSE
  71.         OUT$ = ""
  72.     END IF
  73.  
  74. SUB SendMessage (myname$, mymessage$, client) ' simple input handler
  75.     k$ = INKEY$
  76.     IF LEN(k$) THEN
  77.         IF k$ = CHR$(8) AND LEN(mymessage$) <> 0 THEN
  78.             mymessage$ = LEFT$(mymessage$, LEN(mymessage$) - 1)
  79.         ELSE
  80.             IF LEN(k$) = 1 AND ASC(k$) >= 32 THEN mymessage$ = mymessage$ + k$
  81.         END IF
  82.     END IF
  83.     VIEW PRINT 1 TO 24
  84.     LOCATE 22, 1: PRINT SPACE$(80); ' erase previous message displayed
  85.     LOCATE 22, 1: PRINT myname$ + ": "; mymessage$;
  86.     IF k$ = CHR$(13) THEN ' [Enter] sends the message
  87.         IF mymessage$ = "" THEN SYSTEM ' [Enter] with no message ends program
  88.         mymessage$ = myname$ + ":" + mymessage$
  89.         l = LEN(mymessage$)
  90.         PUT #client, , l
  91.         PUT #client, , mymessage$
  92.         mymessage$ = ""
  93.     END IF
  94.     IF k$ = CHR$(27) THEN SYSTEM ' [Esc] key ends program
  95.  

Here's a version of your program that can run both client and/or host. Checks if a host is already open, then connects as client. Its just easier than having two separate programs.

Zep

7
QB64 Discussion / Re: Rotating Sprites
« on: November 06, 2019, 07:40:58 pm »
RhoSigma,
MAPTRIANGLE doesnt seem to be working for me. Whenever I try to display the sprite, nothing appears (its just black).
Could this be that I'm not using an actual image?

Zep

8
QB64 Discussion / Rotating Sprites
« on: November 06, 2019, 03:04:14 am »
Hey everyone,
Is it possible to rotate sprites with PUT, e.g. rotating an image to a specific degree.
Or am I going to have to calculate each corner of the images coordinates?

Thanks,
Zep

9
Programs / Re: Higher/Smoother framerate movement
« on: November 05, 2019, 05:20:21 pm »
Like this, you can set the speed of the program so that it'll have a maximum movement with _LIMIT on very fast computers, and you can increase the playerSpeed as necessary to keep game flow steady if it's ever ran on very old/slow computers.  (Just add a condition to check for your FPS, which should always be within 1 of your limit, and then you can adjust the player and opponent speed to skip a few frames if the values get too low,  to keep the game moving at the same rate, which is what I think you were wanting to do with deltatime as you implemented it.)
I usually program in c# with Unity, so the deltatime was to try keep a consistent movement speed disregarding framerate (to some degree).
I will add limits to all loops (completely forgot, sorry about the egg-cooking CPU).

Thanks,
Zep

10
Programs / Higher/Smoother framerate movement
« on: November 04, 2019, 08:55:58 pm »
Hey Guys,
Is it possible to achieve a higher/smoother framerate when moving sprites using _PUTIMAGE.
See file below.
To get to the demo go:
-Singleplayer
-Infinite
To exit the demo hit escape.

Thanks,
Zep

11
QB64 Discussion / _PRINTSTRING For INPUT
« on: November 01, 2019, 04:11:23 am »
Hey,
Is there a command like _PRINTSTRING that allows coordinate placement of text but for INPUT?
I am aware of LOCATE, but it doesnt use screen coordinates. If there isnt a way to do this, is there a way to convert LOCATE coords to _PRINTSCREEN coords?

Thanks,
Zep

12
Programs / Re: GUESS MY NUMBER GAME
« on: September 10, 2019, 02:53:34 am »
Well done bPlus. I don't think we can get it much smaller than that.

13
Programs / Re: GUESS MY NUMBER GAME
« on: September 09, 2019, 11:07:11 pm »
Ron,
How short can you make it though ;)

Code: QB64: [Select]
  1. RANDOMIZE TIMER: num = INT(RND * 100)
  2. FOR n = 1 TO 10
  3.     INPUT ">> ", in
  4.     IF in < num THEN PRINT "Higher"
  5.     IF in > num  THEN PRINT "Lower" ELSE
  6.     IF in = num THEN PRINT "Correct. You Win": END
  7. NEXT n: PRINT "Game-over. 10 turns passed"

7 lines

Zep.

14
Programs / Smooth Sprite Movement
« on: August 04, 2019, 08:52:10 pm »
Hey everyone,
Heres a good starting point or example for anyone having problems with slow or jerky sprite movement.
Code: QB64: [Select]
  1. [/cod_TITLE "Space Invaders"
  2. SCREEN 13 '320x200
  3.  
  4. 'LOAD SPRITES
  5. DIM SHARED alien1%(1000)
  6. DIM SHARED alien2%(1000)
  7. DIM SHARED alien3%(1000)
  8.  
  9. DIM SHARED shield%(1000)
  10. DIM SHARED player%(1000)
  11.  
  12. TYPE Bullet
  13.     xPos AS INTEGER
  14.     yPos AS INTEGER
  15.     alive AS INTEGER
  16.  
  17. DIM SHARED bullets(100) AS Bullet
  18.  
  19. DIM SHARED deltaTime
  20. DIM SHARED playerSpeed
  21. DIM SHARED bulletSpeed
  22. DIM SHARED lastBulletTime
  23.  
  24.  
  25. CALL LoadSprite(alien1%())
  26. CALL LoadSprite(alien2%())
  27. CALL LoadSprite(alien3%())
  28.  
  29. CALL LoadSprite(shield%())
  30. CALL LoadSprite(player%())
  31.  
  32. playerSpeed = 100
  33. bulletSpeed = 100
  34.  
  35. FOR n = 1 TO 100
  36.     bullets(n).alive = 0
  37.  
  38. CALL DrawShields
  39.  
  40.     sTime = TIMER
  41.  
  42.     CALL MovePlayer
  43.     CALL SpawnBullet
  44.     CALL UpdateBullets
  45.  
  46.  
  47.     eTime = TIMER
  48.     deltaTime = eTime - sTime
  49.  
  50. SUB UpdateBullets
  51.     FOR n = 1 TO 100
  52.         IF bullets(n).alive = 1 THEN
  53.             LINE (bullets(n).xPos, bullets(n).yPos)-(bullets(n).xPos + 2, bullets(n).yPos + 4), _RGB(0, 0, 0), BF
  54.             bullets(n).yPos = bullets(n).yPos - (deltaTime * bulletSpeed)
  55.             LINE (bullets(n).xPos, bullets(n).yPos)-(bullets(n).xPos + 2, bullets(n).yPos + 4), _RGB(255, 0, 0), BF
  56.             _DISPLAY
  57.  
  58.             IF bullets(n).yPos < 0 THEN
  59.                 bullets(n).alive = 0
  60.                 LINE (bullets(n).xPos, bullets(n).yPos)-(bullets(n).xPos + 3, bullets(n).yPos + 5), _RGB(0, 0, 0), BF
  61.             END IF
  62.  
  63.         END IF
  64.     NEXT n
  65.  
  66. SUB SpawnBullet
  67.     IF _KEYDOWN(32) = -1 THEN
  68.         IF TIMER - lastBulletTime > 0.1 THEN
  69.             first = 101
  70.             FOR n = 100 TO 1 STEP -1
  71.                 IF NOT bullets(n).alive = 1 THEN
  72.                     IF n < first THEN
  73.                         first = n
  74.                     END IF
  75.                 END IF
  76.             NEXT n
  77.  
  78.             IF first < 101 THEN
  79.                 lastBulletTime = TIMER
  80.                 bullets(first).alive = 1
  81.                 bullets(first).xPos = pX + 5
  82.                 bullets(first).yPos = 170
  83.                 LINE (bullets(first).xPos, bullets(first).yPos)-(bullets(first).xPos + 2, bullets(first).yPos + 4), _RGB(255, 255, 255), BF
  84.             END IF
  85.         END IF
  86.     END IF
  87.  
  88. SUB MovePlayer
  89.     IF _KEYDOWN(100) = -1 THEN
  90.         pX = pX + (deltaTime * playerSpeed)
  91.     END IF
  92.     IF _KEYDOWN(97) = -1 THEN
  93.         pX = pX - (deltaTime * playerSpeed)
  94.     END IF
  95.  
  96.     IF pX < 20 THEN
  97.         pX = 20
  98.     END IF
  99.     IF pX > 300 THEN
  100.         pX = 300
  101.     END IF
  102.  
  103.     LINE (pX - 10, 175)-(pX + 100, 201), _RGB(0, 0, 0), BF
  104.     PUT (pX, 175), player%()
  105.     _DISPLAY
  106.  
  107. SUB DrawShields
  108.     FOR x = 0 TO 3
  109.         PUT (x * (320 / 4) + 30, 150), shield%()
  110.     NEXT x
  111.  
  112. SUB LoadSprite (sp%())
  113.     DIM sprite(4, 4)
  114.     scale = 2
  115.     FOR y = 0 TO 4
  116.         FOR x = 0 TO 4
  117.             READ sprite(x, y) 'Read the data
  118.         NEXT x
  119.     NEXT y
  120.  
  121.     FOR y = 0 TO 4 * scale STEP scale 'Factor in the scale
  122.         FOR x = 0 TO 4 * scale STEP scale
  123.             LINE (x, y)-(x + scale, y + scale), sprite(x / scale, y / scale), BF 'Draw each pixel
  124.         NEXT x
  125.     NEXT y
  126.  
  127.     GET (0, 0)-(10, 10), sp%()
  128.     CLS
  129.  
  130. 'Alien 1 Data
  131. DATA 0,0,15,0,0
  132. DATA 0,15,15,15,0
  133. DATA 0,15,15,15,0
  134. DATA 15,0,15,0,15
  135. DATA 0,15,0,15,0
  136.  
  137. 'Alien 2 Data
  138. DATA 0,0,15,0,0
  139. DATA 0,15,15,15,0
  140. DATA 0,15,0,15,0
  141. DATA 15,0,0,0,15
  142. DATA 15,0,0,0,15
  143.  
  144. 'Alien 3 Data
  145. DATA 15,0,0,0,15
  146. DATA 15,0,15,0,15
  147. DATA 0,15,0,15,0
  148. DATA 0,15,0,15,0
  149. DATA 0,0,15,0,0
  150.  
  151. 'Shield Data
  152. DATA 0,15,15,15,0
  153. DATA 15,15,15,15,15
  154. DATA 15,15,0,15,15
  155. DATA 15,0,0,0,15
  156. DATA 15,0,0,0,15
  157.  
  158. 'Player Data
  159. DATA 0,0,0,0,0
  160. DATA 0,0,15,0,0
  161. DATA 0,15,15,15,0
  162. DATA 15,15,15,15,15
  163. DATA 15,15,15,15,15
  164.  
  165. e]
  166.  
  167. Yes. It is for a space invaders clone im making.
  168.  
  169. Zep

15
QB64 Discussion / Re: Discord
« on: June 26, 2019, 04:31:53 am »
Quote
September 16, 2018, 09:02:01 PM »
Great to hear that everyone is ok.
Just an idea, but someone make a discord so that we can chat and not disturb the forum?
I think it will help people with small problems and you get notified when someone needs help.
Pretty good I think

Zeppelin

So now we have one ;)

Pages: [1] 2 3