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 - MrFreyer

Pages: [1] 2 3
1
QB64 Discussion / Buffer for _AXIS and _BUTTON command?
« on: August 12, 2020, 04:55:00 pm »
Hi all,
is there an internal buffer for the _AXIS and the _BUTTON command?

If my game has a really low framerate and I mash a button, on the controller, repeatedly, the game runs the specific action for a few seconds, even if no further buttoninput is done... Same with the analog stick (_AXIS). Sadly this is really annoying :D
If I use the keyboard (_KEYDOWN) while the game have a low framerate, I have to press the keys for a few milliseconds, till the game detect the input, but instantly stops an action when the key isn't pressed anymore.
This is much better than the controller-problem.

Thanks for answers and help.

2
Programs / Re: The Grand Demon Saga (Game)
« on: December 02, 2019, 11:32:42 pm »
As soon as I have an apple laptop, I will make a version for macOS.  :D
I really won't share the whole code - it comes from 2 years of work ^^

3
Programs / Re: The Grand Demon Saga (Game)
« on: December 02, 2019, 08:28:26 am »
Any chance for a macOS build or the source code? :)
How can I make a macOS build?
What happens if you run it under macOS?

EDIT:
is there just a problem with the filepaths?

EDITEDIT:
...and on the screenshot, yo'llu see the reason why I shouln't share the whole sourcecode ':D

4
Programs / The Grand Demon Saga (Game)
« on: December 01, 2019, 09:02:55 pm »
Hi @all,

I'm currently programming a small game in my free time. It's still an very early version...

You can download it via the download-link at granddemonsaga.net, or directly via
https://www.file-upload.net/download-13806677/TheGrandDemonSaga_v.0.0.1.zip.html.

If you have questions about the gamemechanics or wanna see some specific code-sections, just ask.

5
Programs / Mosaic Effect
« on: November 06, 2019, 03:31:34 am »
...it's the mosaic effect, like the SNES games used it to pixelate (blur?) the screen.

Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3.  
  4. desktopscreen.width = _DESKTOPWIDTH
  5. desktopscreen.height = _DESKTOPHEIGHT
  6.  
  7. screenwindow.width = 800
  8. screenwindow.height = 600
  9.  
  10. SCREEN _NEWIMAGE(screenwindow.width, screenwindow.height, 32)
  11. _SCREENMOVE (desktopscreen.width * 0.5 - screenwindow.width * 0.5), 0
  12.  
  13. CONST pixelbytes = 4 '4 byte per pixel (RGBA)
  14.  
  15. DIM pixelcolorRed AS _UNSIGNED _BYTE
  16. DIM pixelcolorGreen AS _UNSIGNED _BYTE
  17. DIM pixelcolorBlue AS _UNSIGNED _BYTE
  18.  
  19. DIM imageScreenMEMORY AS _MEM
  20.  
  21. mosaicSize = 1
  22.  
  23. 'calculate maximum mosaic tiles
  24. mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  25. mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  26.  
  27.     CLS
  28.     LINE (0, 0)-(screenwindow.width - 1, screenwindow.height - 1), _RGB(255, 255, 95), BF
  29.     _FONT 16
  30.     COLOR _RGB(255, 0, 255), _RGB(255, 255, 255)
  31.     _PRINTSTRING (32, 0), "Explanation:"
  32.     COLOR _RGB(255, 191, 0), _RGB(191, 95, 0)
  33.     _PRINTSTRING (32, 64), "This program shows the Mosaic Effect."
  34.     COLOR _RGB(0, 255, 0), _RGB(0, 0, 63)
  35.     _PRINTSTRING (32, 128), "But it's the old version, like the Super Nintendo Entertainment System used it."
  36.     COLOR _RGB(191, 191, 191), _RGB(191, 63, 0)
  37.     _PRINTSTRING (32, 192), "The old version takes just the color of a pixel"
  38.     COLOR _RGB(95, 63, 95), _RGB(0, 255, 193)
  39.     _PRINTSTRING (32, 256), "and overwrites the next few pixels on the x and y axis"
  40.     COLOR _RGB(0, 191, 127), _RGB(255, 0, 0)
  41.     _PRINTSTRING (32, 320), "with the color values of the first pixel."
  42.     COLOR _RGB(0, 255, 123), _RGB(31, 95, 31)
  43.     _PRINTSTRING (32, 384), "There is also a newer, smooth version, but who needs it? :D"
  44.     COLOR _RGB(255, 255, 255), _RGB(0, 0, 0)
  45.     _PRINTSTRING (32, 448), "Just press [+] or [-] to change the mosaic size."
  46.     COLOR _RGB(255, 95, 95), _RGB(0, 0, 0)
  47.     _PRINTSTRING (464, 448), "<<< change mosaic size"
  48.     COLOR _RGB(0, 0, 0), _RGB(63, 127, 63)
  49.     _PRINTSTRING (32, 512), "Press [Escape] to close the program."
  50.     COLOR _RGB(255, 95, 95), _RGB(0, 0, 0)
  51.     _PRINTSTRING (464, 512), "<<< close program"
  52.     COLOR _RGB(255, 0, 0), _RGB(31, 31, 31)
  53.     _PRINTSTRING (32, 576), "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X"
  54.  
  55.     imageScreenMEMORY = _MEMIMAGE(0)
  56.  
  57.     FOR pixelVertical = 1 TO mosaicsVertical
  58.         FOR pixelHorizontal = 1 TO mosaicsHorizontal
  59.             y = (pixelVertical  - 1) * mosaicSize
  60.             x = (pixelHorizontal  - 1) * mosaicSize
  61.  
  62.             _MEMGET imageScreenMEMORY , imageScreenMEMORY .OFFSET + (x * pixelbytes) + (y * (screenwindow.width * pixelbytes)), pixelcolorRed
  63.             _MEMGET imageScreenMEMORY , imageScreenMEMORY .OFFSET + ((x * pixelbytes) + 1) + (y * (screenwindow.width * pixelbytes)), pixelcolorGreen
  64.             _MEMGET imageScreenMEMORY , imageScreenMEMORY .OFFSET + ((x * pixelbytes) + 2) + (y * (screenwindow.width * pixelbytes)), pixelcolorBlue
  65.  
  66.             FOR y2 = 0 TO mosaicSize - 1
  67.                 FOR x2 = 0 TO mosaicSize - 1
  68.                     _MEMPUT imageScreenMEMORY , imageScreenMEMORY .OFFSET + (x * pixelbytes) + (x2 * pixelbytes) + (y * (screenwindow.width * pixelbytes)) + (y2 * (screenwindow.width * pixelbytes)), pixelcolorRed
  69.                     _MEMPUT imageScreenMEMORY , imageScreenMEMORY .OFFSET + ((x * pixelbytes) + 1) + (x2 * pixelbytes) + (y * (screenwindow.width * pixelbytes)) + (y2 * (screenwindow.width * pixelbytes)), pixelcolorGreen
  70.                     _MEMPUT imageScreenMEMORY , imageScreenMEMORY .OFFSET + ((x * pixelbytes) + 2) + (x2 * pixelbytes) + (y * (screenwindow.width * pixelbytes)) + (y2 * (screenwindow.width * pixelbytes)), pixelcolorBlue
  71.                 NEXT x2
  72.             NEXT y2
  73.  
  74.         NEXT pixelHorizontal
  75.     NEXT pixelVertical
  76.  
  77.     _DISPLAY
  78.  
  79.     WHILE INKEY$ <> "": WEND
  80.     DO
  81.         keypressed$ = INKEY$
  82.         IF keypressed$ = CHR$(43) THEN
  83.             mosaicSize = mosaicSize + 1
  84.             IF mosaicSize > 64 THEN mosaicSize = 64
  85.             mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  86.             mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  87.             EXIT DO
  88.         END IF
  89.         IF keypressed$ = CHR$(45) THEN
  90.             mosaicSize = mosaicSize - 1
  91.             IF mosaicSize < 1 THEN mosaicSize = 1
  92.             mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  93.             mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  94.             EXIT DO
  95.         END IF
  96.         IF keypressed$ = CHR$(27) THEN GOTO close_program
  97.     LOOP
  98.  
  99.  
  100. close_program:
  101.  


EDIT:
...and here the slightly slower version, but with POINT/ PRESET instead of _MEMGET/ _MEMPUT
Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3.  
  4. desktopscreen.width = _DESKTOPWIDTH
  5. desktopscreen.height = _DESKTOPHEIGHT
  6.  
  7. screenwindow.width = 800
  8. screenwindow.height = 600
  9.  
  10. SCREEN _NEWIMAGE(screenwindow.width, screenwindow.height, 32)
  11. _SCREENMOVE (desktopscreen.width * 0.5 - screenwindow.width * 0.5), 0
  12.  
  13. DIM pixelcolor AS LONG
  14. DIM pixelcolorRed AS _UNSIGNED _BYTE
  15. DIM pixelcolorGreen AS _UNSIGNED _BYTE
  16. DIM pixelcolorBlue AS _UNSIGNED _BYTE
  17.  
  18. mosaicSize = 1
  19.  
  20. 'calculate maximum mosaic tiles
  21. mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  22. mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  23.  
  24.     CLS
  25.     LINE (0, 0)-(screenwindow.width - 1, screenwindow.height - 1), _RGB(255, 255, 95), BF
  26.     _FONT 16
  27.     COLOR _RGB(255, 0, 255), _RGB(255, 255, 255)
  28.     _PRINTSTRING (32, 0), "Explanation:"
  29.     COLOR _RGB(255, 191, 0), _RGB(191, 95, 0)
  30.     _PRINTSTRING (32, 64), "This program shows the Mosaic Effect."
  31.     COLOR _RGB(0, 255, 0), _RGB(0, 0, 63)
  32.     _PRINTSTRING (32, 128), "But it's the old version, like the Super Nintendo Entertainment System used it."
  33.     COLOR _RGB(191, 191, 191), _RGB(191, 63, 0)
  34.     _PRINTSTRING (32, 192), "The old version takes just the color of a pixel"
  35.     COLOR _RGB(95, 63, 95), _RGB(0, 255, 193)
  36.     _PRINTSTRING (32, 256), "and overwrites the next few pixels on the x and y axis"
  37.     COLOR _RGB(0, 191, 127), _RGB(255, 0, 0)
  38.     _PRINTSTRING (32, 320), "with the color values of the first pixel."
  39.     COLOR _RGB(0, 255, 123), _RGB(31, 95, 31)
  40.     _PRINTSTRING (32, 384), "There is also a newer, smooth version, but who needs it? :D"
  41.     COLOR _RGB(255, 255, 255), _RGB(0, 0, 0)
  42.     _PRINTSTRING (32, 448), "Just press [+] or [-] to change the mosaic size."
  43.     COLOR _RGB(255, 95, 95), _RGB(0, 0, 0)
  44.     _PRINTSTRING (464, 448), "<<< change mosaic size"
  45.     COLOR _RGB(0, 0, 0), _RGB(63, 127, 63)
  46.     _PRINTSTRING (32, 512), "Press [Escape] to close the program."
  47.     COLOR _RGB(255, 95, 95), _RGB(0, 0, 0)
  48.     _PRINTSTRING (464, 512), "<<< close program"
  49.     COLOR _RGB(255, 0, 0), _RGB(31, 31, 31)
  50.     _PRINTSTRING (32, 576), "X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X"
  51.    
  52.     FOR pixelVertical  = 1 TO mosaicsVertical
  53.         FOR pixelHorizontal  = 1 TO mosaicsHorizontal
  54.             y = (pixelVertical  - 1) * mosaicSize
  55.             x = (pixelHorizontal   - 1) * mosaicSize
  56.  
  57.             pixelcolor = POINT(x, y)
  58.             pixelcolorRed = _RED32(pixelcolor)
  59.             pixelcolorGreen = _GREEN32(pixelcolor)
  60.             pixelcolorBlue = _BLUE32(pixelcolor)
  61.  
  62.             FOR y2 = 0 TO mosaicSize - 1
  63.                 FOR x2 = 0 TO mosaicSize - 1
  64.                     PRESET (x + x2, y + y2), _RGB(pixelcolorRed, pixelcolorGreen, pixelcolorBlue)
  65.                 NEXT x2
  66.             NEXT y2
  67.  
  68.         NEXT pixelHorizontal  
  69.     NEXT pixelVertical
  70.     _DISPLAY
  71.  
  72.     WHILE INKEY$ <> "": WEND
  73.     DO
  74.         keypressed$ = INKEY$
  75.         IF keypressed$ = CHR$(43) THEN
  76.             mosaicSize = mosaicSize + 1
  77.             IF mosaicSize > 64 THEN mosaicSize = 64
  78.             mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  79.             mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  80.             EXIT DO
  81.         END IF
  82.         IF keypressed$ = CHR$(45) THEN
  83.             mosaicSize = mosaicSize - 1
  84.             IF mosaicSize < 1 THEN mosaicSize = 1
  85.             mosaicsVertical = FIX(screenwindow.height / mosaicSize)
  86.             mosaicsHorizontal = FIX(screenwindow.width / mosaicSize)
  87.             EXIT DO
  88.         END IF
  89.         IF keypressed$ = CHR$(27) THEN GOTO close_program
  90.     LOOP
  91.  
  92.  
  93. close_program:
  94.  

6
Programs / Re: Higher/Smoother framerate movement
« on: November 05, 2019, 05:52:49 pm »
...something smooth like this?

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

(all changes marked with  'NEW NEW NEW ####################################) :D

EDIT: some other were faster, sorry

7
Programs / Noise Effect
« on: November 05, 2019, 05:37:32 pm »
...just a little noise-effect I want to share.

Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3.  
  4. desktop.height = _DESKTOPHEIGHT
  5.  
  6. screenwindow.WIDTH = 800
  7. screenwindow.height = 600
  8.  
  9. SCREEN _NEWIMAGE(screenwindow.WIDTH, screenwindow.height, 32)
  10. _SCREENMOVE (desktop.width * 0.5 - screenwindow.WIDTH * 0.5), 0
  11.  
  12. CONST pixelbytes = 4 '4 bytes per pixel (RGBA)
  13.  
  14. DIM pixelcolorRed AS _UNSIGNED _BYTE
  15. DIM pixelcolorGreen AS _UNSIGNED _BYTE
  16. DIM pixelcolorBlue AS _UNSIGNED _BYTE
  17.  
  18. DIM screenMemoryblock AS _MEM
  19.  
  20. screenMemoryblock = _MEMIMAGE(0)
  21.  
  22.     FOR y = 0 TO screenwindow.height - 1
  23.         FOR x = 0 TO screenwindow.WIDTH - 1
  24.  
  25.             pixelcolorRed = (RND * 254) + 1 'pick random red pixelcolor-value from 1 to 255
  26.             pixelcolorGreen = (RND * 254) + 1 'pick random green pixelcolor-value from 1 to 255
  27.             pixelcolorBlue = (RND * 254) + 1 'pick random blue pixelcolor-value from 1 to 255
  28.  
  29.             _MEMPUT screenMemoryblock, screenMemoryblock.OFFSET + (x * pixelbytes) + (y * (screenwindow.WIDTH * pixelbytes)), pixelcolorRed
  30.             _MEMPUT screenMemoryblock, screenMemoryblock.OFFSET + ((x * pixelbytes) + 1) + (y * (screenwindow.WIDTH * pixelbytes)), pixelcolorGreen
  31.             _MEMPUT screenMemoryblock, screenMemoryblock.OFFSET + ((x * pixelbytes) + 2) + (y * (screenwindow.WIDTH * pixelbytes)), pixelcolorBlue
  32.  
  33.         NEXT x
  34.     NEXT y
  35.  
  36.     _DISPLAY
  37.  
  38.  


EDIT:
...and the same program with PRESET instead of _MEMPUT. Would be slightly slower.
Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3.  
  4. desktop.height = _DESKTOPHEIGHT
  5.  
  6. screenwindow.WIDTH = 800
  7. screenwindow.height = 600
  8.  
  9. SCREEN _NEWIMAGE(screenwindow.WIDTH, screenwindow.height, 32)
  10. _SCREENMOVE (desktop.WIDTH * 0.5 - screenwindow.WIDTH * 0.5), 0
  11.  
  12. DIM pixelcolorRed AS _UNSIGNED _BYTE
  13. DIM pixelcolorGreen AS _UNSIGNED _BYTE
  14. DIM pixelcolorBlue AS _UNSIGNED _BYTE
  15.  
  16.     FOR y = 0 TO screenwindow.height - 1
  17.         FOR x = 0 TO screenwindow.WIDTH - 1
  18.  
  19.             pixelcolorRed = (RND * 254) + 1 'pick random red pixelcolor-value from 1 to 255
  20.             pixelcolorGreen = (RND * 254) + 1 'pick random green pixelcolor-value from 1 to 255
  21.             pixelcolorBlue = (RND * 254) + 1 'pick random blue pixelcolor-value from 1 to 255
  22.  
  23.             PRESET (x, y), _RGB(pixelcolorRed, pixelcolorGreen, pixelcolorBlue)
  24.  
  25.         NEXT x
  26.     NEXT y
  27.  
  28.     _DISPLAY
  29.  
  30.  

8
Did you modify makeline_xxx.txt to add optimization maybe (-O1/-O2 etc)?? - Optimization requires alot more memory.
No...don't even know what that means :D

In this case, it sounds as if you’re trying to allocate a 72MB block of memory for some purpose, and the system isn’t finding that large of an open block of memory, so I’d guess whatever program you’re compiling is rather large in nature. 
yeah, the program (game) have more than 30,000 lines of code.
I allocate memory for a faster screenrendering. Here is some of my code:

Code: QB64: [Select]
  1. IF drawlayerMapFrame1 THEN _FREEIMAGE drawlayerMapFrame1
  2. IF drawlayerMapFrame2 THEN _FREEIMAGE drawlayerMapFrame2
  3. IF drawlayerMapFrame3 THEN _FREEIMAGE drawlayerMapFrame3
  4. IF drawlayerMapFrame4 THEN _FREEIMAGE drawlayerMapFrame4
  5. IF drawlayerMapFrame5 THEN _FREEIMAGE drawlayerMapFrame5
  6. IF drawlayerMapFrame6 THEN _FREEIMAGE drawlayerMapFrame6
  7. IF drawlayerMapFrame7 THEN _FREEIMAGE drawlayerMapFrame7
  8. IF drawlayerMapFrame8 THEN _FREEIMAGE drawlayerMapFrame8
  9.  
  10. drawlayerMapFrame1 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  11. drawlayerMapFrame2 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  12. drawlayerMapFrame3 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  13. drawlayerMapFrame4 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  14. drawlayerMapFrame5 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  15. drawlayerMapFrame6 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  16. drawlayerMapFrame7 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  17. drawlayerMapFrame8 = _NEWIMAGE(map.width, map.height, screenwindow.colormode)
  18.  
  19.  
  20. FOR drawlayerCounter = 1 TO 8
  21.  
  22.     SELECT CASE drawlayerCounter
  23.         CASE 1: _DEST drawlayerMapFrame1
  24.         CASE 2: _DEST drawlayerMapFrame2
  25.         CASE 3: _DEST drawlayerMapFrame3
  26.         CASE 4: _DEST drawlayerMapFrame4
  27.         CASE 5: _DEST drawlayerMapFrame5
  28.         CASE 6: _DEST drawlayerMapFrame6
  29.         CASE 7: _DEST drawlayerMapFrame7
  30.         CASE 8: _DEST drawlayerMapFrame8
  31.     END SELECT
  32.  
  33.     drawpositionY = 0
  34.     drawpositionX = 0
  35.  
  36.     FOR tileVertical = 1 TO map.heightTiles
  37.         FOR tileHorizontal = 1 TO map.widthTiles
  38.        
  39.             IF tile.type(tileHorizontal, tileVertical) THEN
  40.  
  41.      '(here are just 1,200 lines of image references)
  42.  
  43.                 _PUTIMAGE (drawpositionX, drawpositionY), sprites.tiles, , (SPRTSHTPIXPOSFIRST(imagereferenceX1), SPRTSHTPIXPOSFIRST(imagereferenceY1))-(SPRTSHTPIXPOSLAST(imagereferenceX2), SPRTSHTPIXPOSLAST(imagereferenceY2))
  44.  
  45.             END IF
  46.  
  47.             drawpositionX = drawpositionX + tileSize
  48.             IF drawpositionX = map.width THEN drawpositionX = 0: drawpositionY = drawpositionY + tileSize
  49.  
  50.         NEXT tileHorizontal
  51.     NEXT tileVertical
  52.    
  53. NEXT drawlayerCounter
  54.  
  55.  
  56.  
  57. drawlayerMapFrame1MEMORY = _MEMIMAGE(drawlayerMapFrame1)
  58. drawlayerMapFrame2MEMORY = _MEMIMAGE(drawlayerMapFrame2)
  59. drawlayerMapFrame3MEMORY = _MEMIMAGE(drawlayerMapFrame3)
  60. drawlayerMapFrame4MEMORY = _MEMIMAGE(drawlayerMapFrame4)
  61. drawlayerMapFrame5MEMORY = _MEMIMAGE(drawlayerMapFrame5)
  62. drawlayerMapFrame6MEMORY = _MEMIMAGE(drawlayerMapFrame6)
  63. drawlayerMapFrame7MEMORY = _MEMIMAGE(drawlayerMapFrame7)
  64. drawlayerMapFrame8MEMORY = _MEMIMAGE(drawlayerMapFrame8)
  65.  

Code: QB64: [Select]
  1.  REM{render tilebackground
  2.         '(pixelbytes = 4)
  3.         '4 bytes are required for one pixel (RGBA)
  4.  
  5.     pixellinesSkiped = 0
  6.     pixellinesCutoff = 0
  7.     screenshiftVertical = 0
  8.     IF map.height < screenwindow.height THEN
  9.         'if map is smaller than screen
  10.         pixellinesSkiped = (screenwindow.height - map.height) * 0.5
  11.         pixellinesCutoff = screenwindow.height - map.height
  12.     ELSE
  13.         'if camera is too close to mapboundings (black frame)
  14.         IF cameraY < (screenwindow.height * 0.5) - 1 THEN
  15.             pixellinesSkiped = (screenwindow.height * 0.5) - 1 - cameraY
  16.             pixellinesCutoff = (screenwindow.height * 0.5) - cameraY
  17.         ELSEIF cameraY > (map.height - 1) - (screenwindow.height * 0.5) THEN
  18.             pixellinesCutoff = (cameraY + (screenwindow.height * 0.5) + 1) - map.height
  19.             screenshiftVertical = cameraY - (screenwindow.height * 0.5) + 1
  20.         ELSEIF cameraY >= (screenwindow.height * 0.5) - 1 AND cameraY <= (map.height - 1) - (screenwindow.height * 0.5) THEN
  21.             screenshiftVertical = cameraY - (screenwindow.height * 0.5) + 1
  22.         END IF
  23.     END IF
  24.    
  25.     pixelcolumnsSkiped = 0
  26.     pixelcolumnsCutoff = 0
  27.     screenshiftHorizontal = 0
  28.     IF map.width < screenwindow.width THEN
  29.         pixelcolumnsCutoff = screenwindow.width - map.width
  30.         pixelcolumnsSkiped = (screenwindow.width - map.width) * 0.5
  31.     ELSE
  32.         IF cameraX < (screenwindow.width * 0.5) - 1 THEN
  33.             pixelcolumnsSkiped = (screenwindow.width * 0.5) - 1 - cameraX
  34.             pixelcolumnsCutoff = (screenwindow.width * 0.5) - 1 - cameraX
  35.         ELSEIF cameraX > (map.width - 1) - (screenwindow.width * 0.5) THEN
  36.             pixelcolumnsCutoff = ((cameraX + (screenwindow.width * 0.5) + 1) - map.width)
  37.             screenshiftHorizontal = cameraX - (screenwindow.width * 0.5) + 1
  38.         ELSEIF cameraX >= (screenwindow.width * 0.5) - 1 AND cameraX <= (map.width - 1) - (screenwindow.width * 0.5) THEN
  39.             screenshiftHorizontal = cameraX - (screenwindow.width * 0.5) + 1
  40.         END IF
  41.     END IF
  42.    
  43.     bytesize.mappixelwidth = map.width * pixelbytes
  44.     bytesize.screenpixelline = screenwindow.width * pixelbytes
  45.        
  46.     bytesize.screenshiftVertical = screenshiftVertical * bytesize.mappixelwidth
  47.     bytesize.screenshiftHorizontal = screenshiftHorizontal * pixelbytes
  48.  
  49.  
  50.    
  51.     SELECT CASE global.animationFrame
  52.         CASE 1:
  53.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  54.                 _MEMCOPY drawlayerMapFrame1MEMORY, drawlayerMapFrame1MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame1MEMORY.SIZE - drawlayerMapFrame1MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  55.             NEXT screenpixellineCounter
  56.         CASE 2:
  57.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  58.                 _MEMCOPY drawlayerMapFrame2MEMORY, drawlayerMapFrame2MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame2MEMORY.SIZE - drawlayerMapFrame2MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  59.             NEXT screenpixellineCounter
  60.         CASE 3:
  61.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  62.                 _MEMCOPY drawlayerMapFrame3MEMORY, drawlayerMapFrame3MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame3MEMORY.SIZE - drawlayerMapFrame3MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  63.             NEXT screenpixellineCounter
  64.         CASE 4:
  65.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  66.                 _MEMCOPY drawlayerMapFrame4MEMORY, drawlayerMapFrame4MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame4MEMORY.SIZE - drawlayerMapFrame4MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  67.             NEXT screenpixellineCounter
  68.         CASE 5:
  69.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  70.                 _MEMCOPY drawlayerMapFrame5MEMORY, drawlayerMapFrame5MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame5MEMORY.SIZE - drawlayerMapFrame5MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  71.             NEXT screenpixellineCounter
  72.         CASE 6:
  73.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  74.                 _MEMCOPY drawlayerMapFrame6MEMORY, drawlayerMapFrame6MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame6MEMORY.SIZE - drawlayerMapFrame6MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  75.             NEXT screenpixellineCounter
  76.         CASE 7:
  77.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  78.                 _MEMCOPY drawlayerMapFrame7MEMORY, drawlayerMapFrame7MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame7MEMORY.SIZE - drawlayerMapFrame7MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  79.             NEXT screenpixellineCounter
  80.         CASE 8:
  81.             FOR screenpixellineCounter = 1 TO screenwindow.height - pixellinesCutoff
  82.                 _MEMCOPY drawlayerMapFrame8MEMORY, drawlayerMapFrame8MEMORY.OFFSET + bytesize.screenshiftVertical + bytesize.screenshiftHorizontal + (bytesize.mappixelwidth * (screenpixellineCounter - 1)), drawlayerMapFrame8MEMORY.SIZE - drawlayerMapFrame8MEMORY.SIZE + bytesize.screenpixelline - (pixelcolumnsCutoff * pixelbytes) TO drawlayerScreenMEMORY, drawlayerScreenMEMORY.OFFSET + ((screenpixellineCounter - 1) * bytesize.screenpixelline) + (pixelcolumnsSkiped * pixelbytes) + (pixellinesSkiped * bytesize.screenpixelline)
  83.             NEXT screenpixellineCounter
  84.     END SELECT
  85.  

The reason why it works in 64-bit versions is simply because you don’t have that 1.5GB memory limit; your program can use as much as your PC has available, including swap size.
...okay, so I will stick to the 64-bit version.

The only time I’ve seen cc1plus.exe toss an error like that was with excessive use of PRINT statements inside a program.  Depending on how it’s written, a single PRINT command can translate into a hundred lines of c-code.  If you can share the code, we might be able to help sort out what the issue is with it.
There are only _PRINTSTRING commands - no PRINT commands... round about 360 _PRINTSTRING.

9
I permamently got a compile error if I compile with the 1.3 win x86 version. In the 1.3 win x64 version compiling works fine.
The errorlog says
cc1plus.exe: out of memory allocating 72341256 bytes
Is this because of the size of the sourcecode?

10
QB64 Discussion / Re: Sometimes unexpected strong lags
« on: November 01, 2019, 06:01:02 pm »
ahh, I forgot that I set the LIMIT to 240 :D

11
QB64 Discussion / Re: Sometimes unexpected strong lags
« on: November 01, 2019, 05:08:48 pm »
...but why is the CPU usage that high?

12
QB64 Discussion / Re: Sometimes unexpected strong lags
« on: November 01, 2019, 04:11:16 pm »
Can’t you simplify the key handler quite a bit?  Less calls to KEYDOWN might improve performance.

From:

 
'a
IF _KEYDOWN(97) AND key97 = false THEN
    key97 = _KEYDOWN(97)
END IF
IF NOT _KEYDOWN(97) AND key97 <> false THEN
    key97 = false
END IF


To:

 
IF _KEYDOWN(97) THEN key97 = true ELSE key97 = false ‘a

One simple check to set if it’s down or not.

It's maybe slightly (but not much) better...

Normaly I use something like

IF _KEYDOWN(KEYCODE~%(keyA)) AND controlinput.key(keyA) = false THEN
    controlinput.key(keyA) = true
ELSEIF NOT _KEYDOWN(KEYCODE~%(keyA)) AND controlinput.key(keyA) THEN
    controlinput.key(keyA) = false
END IF

as the keyhandle, because sometimes I need to lock a key while pressing, to only do a specific action just one time.

Now I followed your sugestion but it doesn't change much.

13
QB64 Discussion / Re: Sometimes unexpected strong lags
« on: November 01, 2019, 03:34:57 pm »
The taskmanager looks relatively okay... but the program takes 50%-60% of my CPU and about 120MB RAM... guess because of the sortwareimages(?) :o

14
QB64 Discussion / Sometimes unexpected strong lags
« on: November 01, 2019, 10:36:58 am »
In this small program you can move around with w, a, s, d and while I do so, sometimes I got a massive lag.
Sometimes the lag lasts 0.5 till 1 second.

Is this because of my busy laptop, or something in the code?

EDIT:
And the movement isn't as fluent as it should be. It's like a permanent, slight stuttering.

Code: QB64: [Select]
  1. DEFINT A-Z
  2.  
  3. CONST false = 0
  4. CONST true = -1
  5. CONST locked = 127
  6.  
  7.  
  8. desktopscreen.width = _DESKTOPWIDTH
  9. desktopscreen.height = _DESKTOPHEIGHT
  10.  
  11. screenwindow.width = 1280
  12. screenwindow.height = 720
  13.  
  14. SCREEN _NEWIMAGE(screenwindow.width, screenwindow.height, 32)
  15. _SCREENMOVE (desktopscreen.width * 0.5 - screenwindow.width * 0.5), 0
  16.  
  17.  
  18. cameraX = 640
  19. cameraY = 640
  20.  
  21. DIM framesPerSecond AS SINGLE
  22. DIM frametimeCurrent AS DOUBLE
  23. DIM frametimeLast AS DOUBLE
  24. DIM frametime AS SINGLE
  25. DIM frames AS INTEGER
  26. DIM frametimeStopped AS DOUBLE
  27. DIM frametimeResumption AS DOUBLE
  28. DIM framerate AS INTEGER
  29.  
  30.  
  31.  
  32. backgroundWidthTiles = 50
  33. backgroundHeightTiles = 50
  34.  
  35. DIM drawlayer AS LONG
  36. drawlayer = _NEWIMAGE(64 * backgroundWidthTiles, 64 * backgroundHeightTiles, 32)
  37.  
  38. _DEST drawlayer
  39.  
  40. 'draw backgound layer
  41. drawpositionX = 0
  42. drawpositionY = 0
  43. FOR y = 1 TO backgroundHeightTiles
  44.     FOR x = 1 TO backgroundWidthTiles
  45.  
  46.         'random tile colors
  47.         randomNumber = (RND * 4) + 1
  48.         SELECT CASE randomNumber
  49.             CASE 1:
  50.                 red = 124
  51.                 green = 0
  52.                 blue = 0
  53.             CASE 2:
  54.                 red = 0
  55.                 green = 124
  56.                 blue = 0
  57.             CASE 3:
  58.                 red = 0
  59.                 green = 0
  60.                 blue = 124
  61.             CASE 4:
  62.                 red = 124
  63.                 green = 124
  64.                 blue = 0
  65.             CASE 5:
  66.                 red = 124
  67.                 green = 124
  68.                 blue = 124
  69.         END SELECT
  70.  
  71.         'draw tiles (64x64 pixel) on drawlayer
  72.         LINE (drawpositionX, drawpositionY)-(drawpositionX + 63, drawpositionY + 63), _RGB(red, green, blue), BF
  73.  
  74.         drawpositionX = drawpositionX + 64
  75.         IF drawpositionX > backgroundWidthTiles * 64 THEN drawpositionX = 0: drawpositionY = drawpositionY + 64
  76.        
  77.     NEXT x
  78.  
  79.  
  80.    
  81. 'mainloop
  82.     _LIMIT 240
  83.  
  84.     DO
  85.         frametimeCurrent = TIMER(.001)
  86.         frametime = (frametimeCurrent - frametimeLast)
  87.     LOOP UNTIL frametime >= 1 / 240 '240 is maximum frames per second
  88.  
  89.     frametimeLast = frametimeCurrent
  90.  
  91.     framesPerSecond = 1 / frametime
  92.     IF framesPerSecond < 10 THEN framesPerSecond = 10 '10 is minimum frames per second
  93.  
  94.    
  95.     'check keyinputs
  96.     GOSUB keylistener
  97.  
  98.    
  99.    
  100.     'process keyinputs
  101.     IF key27 = true THEN GOTO shutdown 'close program
  102.  
  103.     IF key119 = true THEN 'move up
  104.         cameraY = cameraY - (320 / framesPerSecond)
  105.         IF cameraY < 0 THEN cameraY = 0
  106.     END IF
  107.    
  108.     IF key115 = true THEN 'move down
  109.         cameraY = cameraY + (320 / framesPerSecond)
  110.         IF cameraY > 50 * 64 - 1 THEN cameraY = 50 * 64 - 1
  111.     END IF
  112.    
  113.     IF key97 = true THEN 'move left
  114.         cameraX = cameraX - (320 / framesPerSecond)
  115.         IF cameraX < 0 THEN cameraX = 0
  116.     END IF
  117.    
  118.     IF key100 = true THEN 'move right
  119.         cameraX = cameraX + (320 / framesPerSecond)
  120.         IF cameraX > 50 * 64 - 1 THEN cameraX = 50 * 64 - 1
  121.     END IF
  122.  
  123.  
  124.    
  125.  
  126.     CLS
  127.    
  128.         'calculate drawposition of drawlayer
  129.         drawpositionY = cameraY - (screenwindow.height * 0.5) + 1
  130.         drawpositionX = cameraX - (screenwindow.width * 0.5) + 1
  131.    
  132.         _PUTIMAGE (0, 0), drawlayer, , (drawpositionX, drawpositionY)-(drawpositionX + screenwindow.width - 1, drawpositionY + screenwindow.height - 1)
  133.  
  134.  
  135.     'print text
  136.     COLOR _RGB(255, 255, 255)
  137.     _PRINTSTRING (0, 16), "w/a/s/d = move"
  138.     _PRINTSTRING (0, 32), "Escape = exit"
  139.      
  140.     _DISPLAY
  141.  
  142.  
  143. shutdown:
  144.  
  145.  
  146. keylistener:
  147. 'Esc
  148. IF _KEYDOWN(27) AND key27 = false THEN
  149.     key27 = _KEYDOWN(27)
  150. IF NOT _KEYDOWN(27) AND key27 <> false THEN
  151.     key27 = false
  152.  
  153. 'w
  154. IF _KEYDOWN(119) AND key119 = false THEN
  155.     key119 = _KEYDOWN(119)
  156. IF NOT _KEYDOWN(119) AND key119 <> false THEN
  157.     key119 = false
  158.  
  159. 'a
  160. IF _KEYDOWN(97) AND key97 = false THEN
  161.     key97 = _KEYDOWN(97)
  162. IF NOT _KEYDOWN(97) AND key97 <> false THEN
  163.     key97 = false
  164.  
  165. 's
  166. IF _KEYDOWN(115) AND key115 = false THEN
  167.     key115 = _KEYDOWN(115)
  168. IF NOT _KEYDOWN(115) AND key115 <> false THEN
  169.     key115 = false
  170.  
  171. 'd
  172. IF _KEYDOWN(100) AND key100 = false THEN
  173.     key100 = _KEYDOWN(100)
  174. IF NOT _KEYDOWN(100) AND key100 <> false THEN
  175.     key100 = false
  176.  

Thanks

15
I'm using version 1.3 win x64...

You get the screen with "TESTTEXT 1 - Press any key"?
I just get a black screen :/

Pages: [1] 2 3