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

Pages: [1] 2 3 ... 115
1
Programs / Re: Next one Music Visualizer
« on: March 19, 2022, 05:59:34 am »
That's an amazing effect. I ran a mp3 song through it and noticed the amplitude of the terrain suddenly increased significantly while the sound remained relatively the same. Must have been picking up something subtle in the encoding...

Yes, this is because it is used to visualize the line every 8192th audio sample. Then the line is moved one step closer in the Z axis (it has a higher coordinate number, the nearest visible one is -1, 0 is no longer invisible and 1 is basically in front of the monitor). For a finer display, I had each sample drawn, it's this source code, the edit is on line 39. Still, not every sample will be rendered now. Why?
In order to render virtually every sound sample, you must first determine in how many frames per second the program will run.
Suppose you set 50 frames per second for smooth graphics. For sound, this means 44100 (SNDRATE) / 50 samples per second, that is 882 samples. But that also means overwriting 882 values in memory 50 times per second.
In this program, this is solved by not tracking exactly where you ended up rendering. Simply take the current position of the sound and load more samples from it. Therefore, it can easily happen that some samples simply fall out before the whole thing is rendered.
  Under line 61, the program solves normal 2D graphics for blinking background circles.

This source code try use "every" sample:

Code: QB64: [Select]
  1. 'sky texture
  2. Texture2 = NewImage(255, 255, 32)
  3. Dest Texture2
  4. For diY = 0 To 100
  5.     Line (diY + 20, diY + 20)-(235 - diY, 235 - diY), RGBA32(67, 100, 255 - diY, 255 - diY), B
  6.     Circle (127, 127), 100 + diY, RGBA32(155 - diY, diY / 2, 20 + diY, 155 - diY)
  7. 'earth texture
  8. Texture = NewImage(255, 255, 32)
  9. Dest Texture
  10. Cls , &HFFFF0000
  11. For diY = 0 To 100
  12.     Line (diY + 20, diY + 20)-(235 - diY, 235 - diY), RGB32(diY, 0, 0), B
  13. Dest 0
  14. Dim As Long SND, Position, FillCachem, HT
  15. Dim As Float IL, IR, IntensityLeft, IntensityRight
  16. Dim As MEM L, R
  17. Dim As Unsigned Byte Rc, Gc, Bc
  18. ReDim LightsL(10) As Unsigned Byte
  19. ReDim LightsR(10) As Unsigned Byte
  20. Dim M3D(90, 90) As Single
  21. Dim M2D(90, 90) As Single
  22. SND = SndOpen("bb.mp3") '            <-----------------  insert here your sound file name!
  23. VOL = 10
  24. SndVol SND, VOL / 20
  25. L = MemSound(SND, 1)
  26. R = MemSound(SND, 2)
  27. DW = DesktopWidth
  28. DH = DesktopHeight
  29. HT = CopyImage(Texture, 33)
  30. HT2 = CopyImage(Texture2, 33)
  31. FreeImage Texture
  32. Screen NewImage(DW, DH, 32)
  33. FullScreen
  34. SndPlay SND
  35. Do Until Position >= L.SIZE - 882 'CHANGED
  36.     ShiftIt = 89
  37.     Do Until ShiftIt < 0
  38.         For rows = 0 To 90
  39.             Swap M3D(rows, ShiftIt), M3D(rows, ShiftIt + 1)
  40.             Swap M2D(rows, ShiftIt), M2D(rows, ShiftIt + 1)
  41.         Next
  42.         ShiftIt = ShiftIt - 1
  43.     Loop
  44.     Depth = 0
  45.     Do Until Depth = 180 '                              This fill 3D visualisation in X axis. One sample is long 2 bytes, one row is 90 points long. This fill 90 points.
  46.         If Depth + Position > L.SIZE Then End
  47.         M3D(ra, 0) = MemGet(L, L.OFFSET + Position + Depth, Integer) / 32768 * 1.7
  48.         M2D(ra, 0) = MemGet(R, R.OFFSET + Position + Depth, Integer) / 32768 * 1.7
  49.         Depth = Depth + 2 '                            This is byte counter and now use all samples not every 8192th as in previous case (first source code in this thread)
  50.         ra = ra + 1
  51.     Loop
  52.     ra = 0
  53.     For Z = 0 To 89
  54.         For X = 0 To 89
  55.             HX = -45 + X
  56.             HX2 = HX + 1
  57.             HZ = -89 + Z
  58.             HZ2 = HZ + 1
  59.             HY1 = -3 + M3D(X, Z): HY2 = -3 + M3D(X + 1, Z): HY3 = -3 + M3D(X, Z + 1): HY4 = -3 + M3D(X + 1, Z + 1)
  60.             HY11 = 3 - M2D(X, Z): HY12 = 3 - M2D(X + 1, Z): HY13 = 3 - M2D(X, Z + 1): HY14 = 3 - M2D(X + 1, Z + 1)
  61.             MapTriangle (0, 0)-(255, 0)-(0, 255), HT To(HX, HY1, HZ)-(HX2, HY2, HZ)-(HX, HY3, HZ2), 0, Smooth
  62.             MapTriangle (255, 0)-(0, 255)-(255, 255), HT To(HX2, HY2, HZ)-(HX, HY3, HZ2)-(HX2, HY4, HZ2), 0, Smooth
  63.             MapTriangle (0, 0)-(255, 0)-(0, 255), HT2 To(HX, HY11, HZ)-(HX2, HY12, HZ)-(HX, HY13, HZ2), 0, Smooth
  64.             MapTriangle (255, 0)-(0, 255)-(255, 255), HT2 To(HX2, HY12, HZ)-(HX, HY13, HZ2)-(HX2, HY14, HZ2), 0, Smooth
  65.     Next X, Z
  66.  
  67.     '----------------------------------------------------------------------------------------------------------- CIRCLES --------------------------------------------------------------
  68.     FillCache = 0
  69.     IntensityLeft = 0
  70.     IntensityRight = 0
  71.     Do Until FillCache = 882
  72.         IntensityLeft = IntensityLeft + Abs(MemGet(L, L.OFFSET + Position + FillCache, Integer) / 32768)
  73.         IntensityRight = IntensityRight + Abs(MemGet(R, R.OFFSET + Position + FillCache, Integer) / 32768)
  74.         FillCache = FillCache + 2
  75.     Loop
  76.     IL = IntensityLeft / 2 '                                                                   recalc values as decimal
  77.     IR = IntensityRight / 2
  78.     ReDim LightsL(10) As Unsigned Byte
  79.     ReDim LightsR(10) As Unsigned Byte
  80.     CLL = 0
  81.     Do Until IL <= 0
  82.         If IL > 4.41 Then LightsL(CLL) = 255 Else LightsL(CLL) = IL * 57
  83.         IL = IL - 4.41
  84.         CLL = CLL + 1
  85.         MAX CLL, 10
  86.     Loop
  87.     CLR = 0
  88.     Do Until IR <= 0
  89.         If IR > 4.41 Then LightsR(CLR) = 255 Else LightsR(CLR) = IR * 57
  90.         IR = IR - 4.41
  91.         CLR = CLR + 1
  92.         MAX CLR, 10
  93.     Loop
  94.     IL = 0
  95.     IR = 0
  96.     For DL = 0 To 10
  97.         Select Case DL
  98.             Case 0 TO 5
  99.                 Rc = 0: Gc = 255: Bc = 0
  100.             Case 6 TO 8
  101.                 Rc = 255: Gc = 255: Bc = 0
  102.             Case Is > 8
  103.                 Rc = 255: Gc = 0: Bc = 0
  104.         End Select
  105.         CircleFill Width / 2 - 50 - DL * 80, Height / 2, 30, &HFF000000
  106.         CircleFill Width / 2 - 50 - DL * 80, Height / 2, 30, RGBA32(Rc, Gc, Bc, LightsL(DL))
  107.         CircleFill Width / 2 + 50 + DL * 80, Height / 2, 30, &HFF000000
  108.         CircleFill Width / 2 + 50 + DL * 80, Height / 2, 30, RGBA32(Rc, Gc, Bc, LightsR(DL))
  109.     Next
  110.     Display
  111.     Limit 50
  112.     Position = SndGetPos(SND) * SndRate * 2
  113.  
  114.  
  115. Sub MAX (Value, mv)
  116.     If Value > mv Then Value = mv
  117.  
  118. Sub CircleFill (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
  119.     ' CX = center x coordinate
  120.     ' CY = center y coordinate
  121.     '  R = radius
  122.     '  C = fill color
  123.     Dim Radius As Integer, RadiusError As Integer
  124.     Dim X As Integer, Y As Integer
  125.     Radius = Abs(R)
  126.     RadiusError = -Radius
  127.     X = Radius
  128.     Y = 0
  129.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  130.     Line (CX - X, CY)-(CX + X, CY), C, BF
  131.     While X > Y
  132.         RadiusError = RadiusError + Y * 2 + 1
  133.         If RadiusError >= 0 Then
  134.             If X <> Y + 1 Then
  135.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  136.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  137.             End If
  138.             X = X - 1
  139.             RadiusError = RadiusError - X * 2
  140.         End If
  141.         Y = Y + 1
  142.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  143.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  144.     Wend
  145.  

Due to the adjustment, I also had to adjust the rendering of the circles. This brought a noticeable increase in speed (not so many shades are used anymore, only about 5 for the color intensity of the circle)

2
Programs / Re: Next one Music Visualizer
« on: March 16, 2022, 01:04:37 pm »
@johnno56

Thank you for trying it. I am glad, that you like it!

3
QB64 Discussion / Re: Command line to create EXE's ?
« on: March 13, 2022, 04:57:56 am »
@mynameispaul

You can also use QB64 /? for view more options (switches).

4
Programs / Next one Music Visualizer
« on: March 12, 2022, 12:49:01 pm »
Hi. This program try generate terrain (not smooth) using music file.

Do not forget overwriting your sound file name on row 17 in this source code.

Code: QB64: [Select]
  1. Texture = NewImage(255, 255, 32)
  2. Dest Texture
  3. Cls , &HFFFF0000
  4. For diY = 0 To 100
  5.     Line (diY + 20, diY + 20)-(235 - diY, 235 - diY), RGB32(diY, 0, 0), B
  6. Dest 0
  7. Dim As Long SND, Position, FillCachem, HT
  8. Dim As Float IL, IR, IntensityLeft, IntensityRight
  9. Dim As MEM L, R
  10. Dim As Unsigned Byte Rc, Gc, Bc
  11. ReDim LightsL(10) As Unsigned Byte
  12. ReDim LightsR(10) As Unsigned Byte
  13. Dim M3D(90, 90) As Single
  14. Dim M2D(90, 90) As Single
  15. SND = SndOpen("bb.mp3") '            <-----------------  insert here your sound file name!
  16. VOL = 10
  17. SndVol SND, VOL / 20
  18. L = MemSound(SND, 1)
  19. R = MemSound(SND, 2)
  20. DW = DesktopWidth
  21. DH = DesktopHeight
  22. HT = CopyImage(Texture, 33)
  23. FreeImage Texture
  24. Screen NewImage(DW, DH, 32)
  25. FullScreen
  26. SndPlay SND
  27. Do Until Position >= L.SIZE - 8192
  28.     ShiftIt = 89
  29.     Do Until ShiftIt < 0
  30.         For rows = 0 To 90
  31.             Swap M3D(rows, ShiftIt), M3D(rows, ShiftIt + 1)
  32.             Swap M2D(rows, ShiftIt), M2D(rows, ShiftIt + 1)
  33.         Next
  34.         ShiftIt = ShiftIt - 1
  35.     Loop
  36.     Depth = 0
  37.     Do Until Depth = 90000
  38.         If Depth + Position > L.SIZE Then End
  39.         M3D(ra, 0) = MemGet(L, L.OFFSET + Position + Depth, Integer) / 32768 * 1.7
  40.         M2D(ra, 0) = MemGet(R, R.OFFSET + Position + Depth, Integer) / 32768 * 1.7
  41.         Depth = Depth + 1000
  42.         ra = ra + 1
  43.     Loop
  44.     ra = 0
  45.     For Z = 0 To 89
  46.         For X = 0 To 89
  47.             HX = -45 + X
  48.             HX2 = HX + 1
  49.             HZ = -89 + Z
  50.             HZ2 = HZ + 1
  51.             HY1 = -3 + M3D(X, Z): HY2 = -3 + M3D(X + 1, Z): HY3 = -3 + M3D(X, Z + 1): HY4 = -3 + M3D(X + 1, Z + 1)
  52.             HY11 = 3 - M2D(X, Z): HY12 = 3 - M2D(X + 1, Z): HY13 = 3 - M2D(X, Z + 1): HY14 = 3 - M2D(X + 1, Z + 1)
  53.             MapTriangle (0, 0)-(255, 0)-(0, 255), HT To(HX, HY1, HZ)-(HX2, HY2, HZ)-(HX, HY3, HZ2), 0, Smooth
  54.             MapTriangle (255, 0)-(0, 255)-(255, 255), HT To(HX2, HY2, HZ)-(HX, HY3, HZ2)-(HX2, HY4, HZ2), 0, Smooth
  55.             MapTriangle (0, 0)-(255, 0)-(0, 255), HT To(HX, HY11, HZ)-(HX2, HY12, HZ)-(HX, HY13, HZ2), 0, Smooth
  56.             MapTriangle (255, 0)-(0, 255)-(255, 255), HT To(HX2, HY12, HZ)-(HX, HY13, HZ2)-(HX2, HY14, HZ2), 0, Smooth
  57.     Next X, Z
  58.  
  59.     '----------------------------------------------------------------------------------------------------------- CIRCLES --------------------------------------------------------------
  60.     FillCache = 0
  61.     IntensityLeft = 0
  62.     IntensityRight = 0
  63.     Do Until FillCache = 8192
  64.         IntensityLeft = IntensityLeft + Abs(MemGet(L, L.OFFSET + Position + FillCache, Integer) / 32768)
  65.         IntensityRight = IntensityRight + Abs(MemGet(R, R.OFFSET + Position + FillCache, Integer) / 32768)
  66.         FillCache = FillCache + 2
  67.     Loop
  68.     IL = IntensityLeft / 2 '                                                                   recalc values as decimal
  69.     IR = IntensityRight / 2
  70.     ReDim LightsL(10) As Unsigned Byte
  71.     ReDim LightsR(10) As Unsigned Byte
  72.     CLL = 0
  73.     Do Until IL <= 0
  74.         If IL > 28 Then LightsL(CLL) = 255 Else LightsL(CLL) = IL * 8
  75.         IL = IL - 28
  76.         CLL = CLL + 1
  77.         MAX CLL, 10
  78.     Loop
  79.     CLR = 0
  80.     Do Until IR <= 0
  81.         If IR > 28 Then LightsR(CLR) = 255 Else LightsR(CLR) = IR * 8
  82.         IR = IR - 28
  83.         CLR = CLR + 1
  84.         MAX CLR, 10
  85.     Loop
  86.     IL = 0
  87.     IR = 0
  88.     For DL = 0 To 10
  89.         Select Case DL
  90.             Case 0 TO 5
  91.                 Rc = 0: Gc = 255: Bc = 0
  92.             Case 6 TO 8
  93.                 Rc = 255: Gc = 255: Bc = 0
  94.             Case Is > 8
  95.                 Rc = 255: Gc = 0: Bc = 0
  96.         End Select
  97.         CircleFill Width / 2 - 50 - DL * 80, Height / 2, 30, &HFF000000
  98.         CircleFill Width / 2 - 50 - DL * 80, Height / 2, 30, RGBA32(Rc, Gc, Bc, LightsL(DL))
  99.         CircleFill Width / 2 + 50 + DL * 80, Height / 2, 30, &HFF000000
  100.         CircleFill Width / 2 + 50 + DL * 80, Height / 2, 30, RGBA32(Rc, Gc, Bc, LightsR(DL))
  101.     Next
  102.     Display
  103.     Limit 50
  104.     Position = SndGetPos(SND) * SndRate * 2
  105.  
  106.  
  107. Sub MAX (Value, mv)
  108.     If Value > mv Then Value = mv
  109.  
  110. Sub CircleFill (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
  111.     ' CX = center x coordinate
  112.     ' CY = center y coordinate
  113.     '  R = radius
  114.     '  C = fill color
  115.     Dim Radius As Integer, RadiusError As Integer
  116.     Dim X As Integer, Y As Integer
  117.     Radius = Abs(R)
  118.     RadiusError = -Radius
  119.     X = Radius
  120.     Y = 0
  121.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  122.     Line (CX - X, CY)-(CX + X, CY), C, BF
  123.     While X > Y
  124.         RadiusError = RadiusError + Y * 2 + 1
  125.         If RadiusError >= 0 Then
  126.             If X <> Y + 1 Then
  127.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  128.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  129.             End If
  130.             X = X - 1
  131.             RadiusError = RadiusError - X * 2
  132.         End If
  133.         Y = Y + 1
  134.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  135.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  136.     Wend
  137.  

5
QB64 Discussion / Re: Blurry text??
« on: February 19, 2022, 04:02:24 pm »
Hi, @Mad Axeman

Try pressing Left Alt + Enter a few times while working in the IDE.

6
Hi @OldMoses

It still make error. I've dealt with it too, so I'm going it through MEM:

Code: QB64: [Select]
  1. 'OPTION BASE 1
  2. Screen _NewImage(1024, 512, 32)
  3.  
  4. Dim An(1 To 10) As String * 10
  5.  
  6. For x% = 1 To 10
  7.     Read An(x%)
  8. Next x%
  9.  
  10. Open "animals.dat" For Binary As #f
  11.  
  12. 'method A
  13. 'For R = LBound(An) To UBound(An)
  14. 'Put #f, , An(R)
  15. 'Next
  16.  
  17. 'method B
  18. m = _Mem(An())
  19. r$ = Space$(m.SIZE)
  20. _MemGet m, m.OFFSET, r$
  21. Put #f, , r$
  22.  
  23.  
  24. Print "done"
  25.  
  26. Data dog,cat,bison,elephant,weasel,bear,skunk,ocelot,platypus,pig
  27.  
  28.  
  29.  

7
Programs / Petr's Script program in QB64
« on: February 07, 2022, 10:29:56 am »
Hi guys.

This is a small program I'm working on right now. Its purpose is simply to display lyrics, subtitles, comments and / or pictures, play sounds and it's all time-controlled. It can also pause the execution and stop the presentation time. It is a very simple solution. The main goal is to make it easier to shoot videos about QB64 on YouTube - of course, subtitles can also be added there, but this solution, without the need for further editing, seemed better to me. So now all you have to do is download non-copyrighted music, take a few screenshots, translate the comments and it can be fun to create. The amazing thing about Open Source is that it can be shared like this. You will definitely have suggestions on what to add. I gradually want to do it. In the evening, I will use this program to create a presentation about why I haven't been here for a long time and then publish it on my Youtube channel.

You need the attached ZIP file to try it out. When started, the program will ask for the file name. Write there "kuci" - it is script file name, this file is also in zip file. Look in kuci file and see how it is all done.

Code: QB64: [Select]
  1. Title "QB64 Script"
  2. Type Content
  3.     Time As Single
  4.     Statement As String
  5.  
  6.  
  7. ReDim Shared Images(0) As Long, imgI
  8. ReDim Sounds(0) As Long
  9. ReDim Videos(0) As String
  10. ReDim Fonts(0) As Long
  11. ReDim My(0) As Content
  12. ReDim Clrs(2) As Unsigned Byte
  13.  
  14. Input "Input text script file name:"; script$
  15. If FileExists(script$) Then
  16.     FF = FreeFile
  17.     Open script$ For Input As #FF
  18.     While Not EOF(FF)
  19.         Line Input #FF, s$
  20.  
  21.  
  22.         '-------------------------------------- LOAD TO MEMORY AND CHECK ALL FILES IF EXISTS [STEP 1/3] ----------------------------------------------------------
  23.         'ziskat cas
  24.         sep = InStr(s$, " ")
  25.         Tim$ = Mid$(s$, 1, sep - 1)
  26.         sep = InStr(Tim$, ":")
  27.         Min = Val(Mid$(Tim$, 2, sep))
  28.         Tim$ = Mid$(Tim$, sep + 1)
  29.         Secs = Val(Mid$(Tim$, 1, sep))
  30.         sep = InStr(Tim$, ":")
  31.         Tim$ = Mid$(Tim$, sep + 1)
  32.         Set = Val(Mid$(Tim$, 1, sep))
  33.  
  34.         'cas: Min, Sec, Set
  35.         Time = (Min * 60) + Secs + (Set / 100)
  36.         My(record).Time = Time
  37.  
  38.  
  39.  
  40.         'ziskat prikaz (cmd$)
  41.         sep = InStr(s$, " ")
  42.         s$ = Mid$(s$, sep + 1)
  43.         My(record).Statement = (s$)
  44.  
  45.  
  46.  
  47.         sep = InStr(s$, " ")
  48.         cmd$ = Left$(s$, sep - 1)
  49.  
  50.         Select Case UCase$(cmd$)
  51.             Case "SCRN" '                                                        Screen settings
  52.                 'ziskat ResX
  53.                 s$ = Mid$(s$, sep + 1)
  54.                 sep = InStr(s$, " ")
  55.                 ResX = Val(Mid$(s$, 1, sep - 1))
  56.  
  57.                 'ziskat ResY
  58.                 s$ = Mid$(s$, sep + 1)
  59.                 sep = InStr(s$, " ")
  60.                 ResY = Val(Mid$(s$, sep + 1))
  61.  
  62.             Case "SIMG" '                                                       Load images to array (in my mind is already upgrade for it)
  63.                 FileName$ = Mid$(s$, sep + 1)
  64.                 If FileExists(FileName$) Then
  65.                     iU = UBound(Images)
  66.                     Images(iU) = _LoadImage(FileName$, 32)
  67.                     If Images(iU) = -1 Then Print "Error: Image file "; FileName$; " is in unsupported format.": Sleep 3: End
  68.                     ReDim Preserve Images(iU + 1) As Long
  69.                 Else
  70.                     Print "SIMG File "; FileName$; " not found. (Record nr."; record; ")": Sleep 3: End
  71.                 End If
  72.  
  73.             Case "PASS"
  74.                 '                                                              Load images to array as SIMG statement, but PASS is for other use than SIMG (look again)
  75.  
  76.                 s$ = Mid$(s$, sep + 1)
  77.                 sep = InStr(s$, " ")
  78.                 PhotoA$ = Mid$(s$, sep + 1)
  79.  
  80.                 sep = InStr(s$, " ")
  81.                 s$ = Mid$(s$, sep + 1)
  82.                 sep2 = InStrRev(s$, " ")
  83.  
  84.                 s$ = Mid$(s$, sep2)
  85.                 Effect = Val(s$)
  86.  
  87.                 PassE(psI) = Effect
  88.                 psI = psI + 1
  89.                 ReDim Preserve PassE(psI) As Integer
  90.  
  91.                 If FileExists(PhotoA$) Then
  92.                     iU = UBound(Images)
  93.                     Images(iU) = _LoadImage(PhotoA$, 32)
  94.                     If Images(iU) = -1 Then Print "Error: Image file "; PhotoA$; " is in unsupported format.": Sleep 3: End
  95.                     ReDim Preserve Images(iU + 1) As Long
  96.                 Else
  97.                     Print "PASS File "; PhotoA$; " not found. (Record nr."; record; ")": Sleep 3: End
  98.                 End If
  99.  
  100.             Case "SNDL", "SNDP" '                                                Load sounds to array
  101.                 FileName$ = Mid$(s$, sep + 1)
  102.                 If FileExists(FileName$) Then
  103.                     sU = UBound(Sounds)
  104.                     Sounds(sU) = SndOpen(FileName$)
  105.                     If Sounds(sU) = 0 Then Print "Error: Sound file: "; FileName$; " is in unsupported format,": Sleep 3: End
  106.                     ReDim Preserve Sounds(sU + 1) As Long
  107.                 Else
  108.                     Print "Sound file "; FileName$; " not found.": Sleep 3: End
  109.                 End If
  110.  
  111.             Case "SVID" '                                                       Load video file names (if file exists) to array as string (will be used later with Windows Media Player)
  112.                 FileName$ = Mid$(s$, sep + 1)
  113.                 If FileExists(FileName$) Then
  114.                     vU = UBound(Videos)
  115.                     Videos(vU) = FileName$
  116.                     ReDim Preserve Videos(vU + 1) As String
  117.                 Else
  118.                     Print "Video file "; FileName$; " not found.": Sleep 3: End
  119.                 End If
  120.  
  121.             Case "FONT" '                                                       Load font TTF, OTF file
  122.                 sep = InStr(s$, " ")
  123.                 sep2 = InStrRev(s$, " ")
  124.                 FontName$ = Mid$(s$, sep + 1, sep2 - sep)
  125.                 FontSize = Val(Mid$(s$, sep2 + 1))
  126.                 fU = UBound(Fonts)
  127.                 Fonts(fU) = LoadFont(FontName$, FontSize, "MONOSPACE")
  128.                 If Fonts(fU) = 0 Then Print "Error loading font "; FontName$: Sleep 3: End
  129.                 ReDim Preserve Fonts(fU + 1) As Long
  130.         End Select
  131.         record = record + 1
  132.         ReDim Preserve My(record) As Content
  133.     Wend
  134.     Print "Error: Script text file "; script$; " not exists."
  135.     End
  136.  
  137. ' -------------------------------------  RUN OWN PRESENTATION [STEP 2/3]  -------------------------------------------------------------------------------
  138. NullTime = Timer
  139.  
  140. If ResX > 0 And ResY > 0 Then Screen NewImage(ResX, ResY, 32) Else Print "Text mode!"
  141.  
  142. R = 0
  143.  
  144. Do Until k& = 27
  145.     k& = _KeyHit
  146.     'time is calculated from TIMER
  147.     If Timer < NullTime Then NullTime = Timer - P_time 'midnight overflow check / not tested
  148.  
  149.  
  150.     'this is console developing window, it show presentation time for us. If presentation time is the same as in your script file, then it run again, otherwise program wait.
  151.  
  152.     P_time = Timer - NullTime
  153.  
  154.     Do Until P_time > My(R).Time
  155.         P_time = Timer - NullTime
  156.  
  157.         $Console
  158.         Dest Console
  159.         Echo Str$(P_time): Echo Str$(My(R).Time)
  160.         Delay .01
  161.         Dest 0
  162.  
  163.     Loop
  164.  
  165.  
  166.     Statement$ = UCase$(Left$(My(R).Statement, 4))
  167.  
  168.     'od 05-02-2022
  169.     Select Case Statement$
  170.         Case "SIMG" '                        command: Show Image (accept ratio)
  171.             If PixelSize = 4 Then '          works just if SCRN stetement for setting graphic screen is in text file used before SIMG statement, otherwise is this skipped!
  172.                 GetImageRatio LUX, LUY, RUX, RUY, imgI
  173.                 _PutImage (LUX, LUY)-(RUX, RUY), Images(imgI)
  174.                 imgI = imgI + 1
  175.             End If
  176.         Case "SNDL"
  177.             If SndPlaying(Sounds(SoundsI)) = 1 Then SndStop Sounds(SoundsI) 'Play sound in loop
  178.             SndLoop Sounds(SoundsI)
  179.             SoundsI = SoundsI + 1
  180.         Case "SNDP"
  181.             If SndPlaying(Sounds(SoundsI)) = 1 Then SndStop Sounds(SoundsI) 'Play sound once
  182.             SndPlay Sounds(SoundsI)
  183.             SoundsI = SoundsI + 1
  184.         Case "SNDS"
  185.             SndStop Sounds(SoundsI)
  186.         Case "PASS" '                         insert a transition between photos / videos 'parameter is OPTIONAL!
  187.             Parameter = PassE(passI)
  188.             passI = passI + 1
  189.             InsertTransmission Parameter
  190.         Case "DELA" '                                        DELA statement is the same as SLEEP, it also stop time in presentation
  191.             Parameter = Val(Mid$(My(R).Statement, 5))
  192.  
  193.             StopTime = Timer - NullTime
  194.             NullTime = StopTime
  195.             If Parameter Then Sleep Parameter Else Sleep
  196.             NullTime = Timer - StopTime
  197.  
  198.         Case "SVID" '                                       For future version - PlayVideo in this version is empty SUB, in future it use SpriggsySpriggs libraries for call Windows Media Player
  199.             VideoName$ = Videos(VideoI)
  200.             VideoI = VideoI + 1
  201.             PlayVideo VideoName$
  202.         Case "FONT" '                                       View FONT. Use in file: ú[00:00:10] FONT Arial.ttf 40  <---- in step 1/3 it loads and in step 2/3 it view all text using Arial font size 40
  203.             Font Fonts(FontI)
  204.             FontI = FontI + 1
  205.         Case "STIT"
  206.             Text$ = Mid$(My(R).Statement, 5) '              Print SUBTITLE to screen (just one row in this version) use in file is: [01:00:97] STIT This is subtitle
  207.             InsertText Text$
  208.         Case "CLRS"
  209.             Cls , RGB32(Clrs(0), Clrs(1), Clrs(2)) '                 clear screen using color sets for foreground or for background color
  210.         Case "COLF" '                                                set foreground color for subtitles (STIT statement)
  211.             ReDim Clrs(2) As _Unsigned _Byte
  212.             n$ = Mid$(My(R).Statement, 5)
  213.             'Print n$
  214.             For T = 0 To 2
  215.                 sep = InStr(n$, " ") + 1
  216.                 nr$ = Mid$(n$, sep, 3)
  217.                 control = InStr(nr$, " ")
  218.                 If control Then Clrs(T) = Val(Mid$(nr$, 1, control)) Else Clrs(T) = Val(nr$)
  219.                 n$ = Mid$(n$, sep + 1)
  220.             Next
  221.  
  222.             Color RGB32(Clrs(0), Clrs(1), Clrs(2))
  223.  
  224.         Case "COLB" '                                                set background color
  225.             ReDim Clrs(2) As _Unsigned _Byte
  226.             n$ = Mid$(My(R).Statement, 5)
  227.             'Print n$
  228.             For T = 0 To 2
  229.                 sep = InStr(n$, " ") + 1
  230.                 nr$ = Mid$(n$, sep, 3)
  231.                 control = InStr(nr$, " ")
  232.                 If control Then Clrs(T) = Val(Mid$(nr$, 1, control)) Else Clrs(T) = Val(nr$)
  233.                 n$ = Mid$(n$, sep + 1)
  234.             Next
  235.  
  236.             Color , RGB32(Clrs(0), Clrs(1), Clrs(2))
  237.  
  238.         Case "TEXT" '                                                      Print centered text to screen. Use in file: [02:00:99] TEXT Here place long text which is then centered and printed to screen
  239.             n$ = Mid$(My(R).Statement, 5)
  240.             LongText n$
  241.  
  242.         Case "FSCR"
  243.             FullScreen
  244.         Case "CLSS"
  245.             Cls
  246.  
  247.     End Select
  248.     R = R + 1
  249.     If R > record Then Exit Do 'skip to phase 3 - erasing RAM and quit.
  250.  
  251. '-------------------------------------- Erase RAM, delete images and sounds from memory and then end [Step 3/3] -----------------------------------------
  252.  
  253.  
  254. For C1 = LBound(Images) To UBound(Images) - 1
  255.     FreeImage Images(C1)
  256.  
  257. For C2 = LBound(Sounds) To UBound(Sounds) - 1
  258.     SndClose Sounds(C2)
  259.  
  260. Erase Images
  261. Erase Sounds
  262. Erase Videos
  263. Erase Fonts
  264. Erase Clrs
  265. Erase PassE
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280. Sub InsertText (T$)
  281.     TextLenght = PrintWidth(T$)
  282.     Middle = Width \ 2 - TextLenght \ 2
  283.     PrintMode KeepBackground
  284.     PrintString (Middle, Height - FontHeight - 10), T$
  285.  
  286.  
  287. Sub LongText (t As String)
  288.     TextMax = Width \ FontWidth
  289.     Rows = Len(t) \ TextMax
  290.     y = Height / 2 - (FontHeight * Rows / 2)
  291.     Tr = 1
  292.     t$ = t$ + " "
  293.     Do Until LastSpace = Len(t)
  294.         Word$ = Mid$(t, Tr, TextMax)
  295.         LastSpace = InStrRev(Word$, " ")
  296.         S$ = Mid$(Word$, 1, LastSpace)
  297.         Center = Width / 2 - PrintWidth(S$) / 2
  298.         PrintString (Center, y), S$
  299.         y = y + FontHeight
  300.         t$ = Mid$(t$, LastSpace + 1)
  301.     Loop
  302.  
  303.  
  304.  
  305.  
  306. Sub InsertTransmission (Value As Integer)
  307.     'prechody fotek, 0 = nahodny
  308.     Old = CopyImage(0, 32)
  309.     New = NewImage(Width, Height, 32)
  310.     GetImageRatio lux, luy, rdx, rdy, imgI
  311.     _PutImage (lux, luy)-(rdx, rdy), Images(imgI), New
  312.     imgI = imgI + 1
  313.     If Value = 0 Then Value = 1 + 10 * Rnd
  314.     s = 0
  315.     centerX = Width \ 2
  316.     centerY = Height \ 2
  317.  
  318.     Select Case Value
  319.         Case 1 'old image shift up, new is shift from bottom
  320.             Do Until s <= -Height
  321.                 PutImage (0, s), Old, 0
  322.                 PutImage (0, s + Height), New, 0
  323.                 s = s - 10
  324.             Loop
  325.  
  326.         Case 2 'old photo go down, new is shift from ceil
  327.             Do Until s >= Height
  328.                 PutImage (0, s), Old, 0
  329.                 PutImage (0, s - Height), New, 0
  330.                 s = s + 10
  331.             Loop
  332.  
  333.         Case 3 'old photo is shifted to right, new is comming from left
  334.             Do Until s >= Width
  335.                 PutImage (s, 0), Old, 0
  336.                 PutImage (s - Width, 0), New, 0
  337.                 s = s + 10
  338.             Loop
  339.  
  340.         Case 4 'old photo is shifted to left and new photo is comming from right
  341.             Do Until s <= -Width
  342.                 PutImage (s, 0), Old, 0
  343.                 PutImage (s + Width, 0), New, 0
  344.                 s = s + 10
  345.             Loop
  346.  
  347.         Case 5 'old photo is rewrited by circle contains new photo
  348.             Do Until s > _Pi(2)
  349.                 x1 = centerX + Cos(s) * Width
  350.                 y1 = centerY + Sin(s) * Width
  351.                 x2 = centerX + Cos(s + .2) * Width
  352.                 y2 = centerY + Sin(s + .2) * Width
  353.                 MapTriangle (centerX, centerY)-(x1, y1)-(x2, y2), New To(centerX, centerY)-(x1, y1)-(x2, y2), 0
  354.                 s = s + .01
  355.                 Display
  356.             Loop
  357.             Delay .2
  358.             AutoDisplay
  359.  
  360.         Case 6 ' new photo is zoomed from middle the screen as rectangle with this image
  361.  
  362.             Stp = Width / 100
  363.             Stp2 = Height / 100
  364.             x1 = centerX + Sin(3.925) * k
  365.             Do Until x1 <= 0
  366.                 x1 = centerX + Sin(3.925) * k
  367.                 y1 = centerY + Cos(3.925) * k2
  368.                 x3 = centerX + Sin(0.785) * k
  369.                 y3 = centerY + Cos(0.785) * k2
  370.                 PutImage (x1, y1)-(x3, y3), New, 0
  371.                 k = k + Stp
  372.                 k2 = k2 + Stp2
  373.                 kk = kk + 1
  374.                 Delay .01
  375.             Loop
  376.  
  377.         Case 7 'new photo is inserted as rectnagles from left to right and from ceiling to bottom
  378.  
  379.             sx = Width / 10
  380.             sy = Height / 10
  381.             For y = 0 To Height Step sy
  382.                 For x = 0 To Width Step sx
  383.                     PutImage (x, y), New, 0, (x, y)-(x + sx, y + sy)
  384.                     Delay .02
  385.             Next x, y
  386.  
  387.         Case 8 'vice versa as Case 7
  388.  
  389.             sx = Width / 10
  390.             sy = Height / 10
  391.  
  392.             For x = 0 To Width Step sx
  393.                 For y = 0 To Height Step sy
  394.                     PutImage (x, y), New, 0, (x, y)-(x + sx, y + sy)
  395.                     Delay .02
  396.             Next y, x
  397.  
  398.         Case 9 'photo is displayed using quarter circle effect
  399.             c = _Pi / 2
  400.             Do Until s > _Pi(2) / 4
  401.                 x1 = centerX + Cos(s) * Width
  402.                 y1 = centerY + Sin(s) * Width
  403.                 x2 = centerX + Cos(s + .01) * Width
  404.                 y2 = centerY + Sin(s + .01) * Width
  405.  
  406.                 x3 = centerX + Cos(s + c) * Width
  407.                 y3 = centerY + Sin(s + c) * Width
  408.                 x4 = centerX + Cos(s + .01 + c) * Width
  409.                 y4 = centerY + Sin(s + .01 + c) * Width
  410.  
  411.                 x5 = centerX + Cos(s + 2 * c) * Width
  412.                 y5 = centerY + Sin(s + 2 * c) * Width
  413.                 x6 = centerX + Cos(s + .01 + 2 * c) * Width
  414.                 y6 = centerY + Sin(s + .01 + 2 * c) * Width
  415.  
  416.                 x7 = centerX + Cos(s + 3 * c) * Width
  417.                 y7 = centerY + Sin(s + 3 * c) * Width
  418.                 x8 = centerX + Cos(s + .01 + 3 * c) * Width
  419.                 y8 = centerY + Sin(s + .01 + 3 * c) * Width
  420.  
  421.  
  422.                 MapTriangle (centerX, centerY)-(x1, y1)-(x2, y2), New To(centerX, centerY)-(x1, y1)-(x2, y2), 0
  423.                 MapTriangle (centerX, centerY)-(x3, y3)-(x4, y4), New To(centerX, centerY)-(x3, y3)-(x4, y4), 0
  424.                 MapTriangle (centerX, centerY)-(x5, y5)-(x6, y6), New To(centerX, centerY)-(x5, y5)-(x6, y6), 0
  425.                 MapTriangle (centerX, centerY)-(x7, y7)-(x8, y8), New To(centerX, centerY)-(x7, y7)-(x8, y8), 0
  426.  
  427.                 s = s + .01
  428.                 Display
  429.                 Delay .01
  430.             Loop
  431.             Delay .2
  432.             AutoDisplay
  433.  
  434.         Case 10 'The image is divided into stripes in the Y axis, odd go to the right, even go to the left. So the old one is comming out and a new image arrives at the screen.
  435.             ReDim Ys(1 To 10) As Integer
  436.             ReDim Xs(1 To 10) As Integer
  437.             d = Height / 10
  438.             XSpd = Width / 100 'shift speed in X axis is WIDTH/100 pixels per loop
  439.             For Yf = 1 To 10
  440.                 Ys(Yf) = (Yf - 1) * d
  441.             Next
  442.             PCopy 0, 1
  443.             Do Until done >= Width
  444.                 PCopy 1, 0
  445.                 For s = 1 To 10
  446.                     If s Mod 2 = 0 Then
  447.                         Xs(s) = Xs(s) - XSpd
  448.                         PutImage (Xs(s), Ys(s)), Old, 0, (0, Ys(s))-(Width, Ys(s) + d)
  449.                         PutImage (Xs(s) + Width, Ys(s)), New, 0, (0, Ys(s))-(Width, Ys(s) + d)
  450.                     Else
  451.                         Xs(s) = Xs(s) + XSpd
  452.                         PutImage (Xs(s), Ys(s)), Old, 0, (0, Ys(s))-(Width, Ys(s) + d)
  453.                         PutImage (Xs(s) - Width, Ys(s)), New, 0, (0, Ys(s))-(Width, Ys(s) + d)
  454.                     End If
  455.                 Next s
  456.                 done = done + XSpd
  457.                 Display
  458.                 Delay .01
  459.             Loop
  460.             Delay .02
  461.             AutoDisplay
  462.  
  463.         Case 11 'vice versa as Case 10
  464.             ReDim Ys(1 To 10) As Integer
  465.             ReDim Xs(1 To 10) As Integer
  466.             d = Height / 10
  467.             XSpd = Width / 100 'shift speed in X axis is WIDTH/100 pixels per loop
  468.             For Yf = 1 To 10
  469.                 Ys(Yf) = (Yf - 1) * d
  470.             Next
  471.             PCopy 0, 1
  472.             Do Until done >= Width
  473.                 PCopy 1, 0
  474.                 For s = 1 To 10
  475.                     If s Mod 2 = 0 Then
  476.                         Xs(s) = Xs(s) + XSpd
  477.                         PutImage (Xs(s), Ys(s)), Old, 0, (0, Ys(s))-(Width, Ys(s) + d)
  478.                         PutImage (Xs(s) - Width, Ys(s)), New, 0, (0, Ys(s))-(Width, Ys(s) + d)
  479.                     Else
  480.                         Xs(s) = Xs(s) - XSpd
  481.                         PutImage (Xs(s), Ys(s)), Old, 0, (0, Ys(s))-(Width, Ys(s) + d)
  482.                         PutImage (Xs(s) + Width, Ys(s)), New, 0, (0, Ys(s))-(Width, Ys(s) + d)
  483.                     End If
  484.                 Next s
  485.                 done = done + XSpd
  486.                 Display
  487.                 Delay .01
  488.             Loop
  489.             Delay .02
  490.             AutoDisplay
  491.     End Select
  492.     FreeImage Old
  493.     FreeImage New
  494.  
  495. Sub PlayVideo (Video As String)
  496.     'is my work for next weekend...
  497.  
  498.  
  499.  
  500. Sub GetImageRatio (LeftUpperX, LeftUpperY, RightDownX, RightDownY, handle)
  501.     W = Width(Images(handle))
  502.     H = Height(Images(handle))
  503.     sW = Width '                    Screen Width
  504.     sH = Height '                   Screen Height
  505.  
  506.     RatioX = sW / W
  507.     RatioY = sH / H
  508.  
  509.     Ratio = 1 '                     if RatioX = RatioY
  510.     If RatioX < RatioY Then Ratio = RatioX
  511.     If RatioY < RatioX Then Ratio = RatioY
  512.  
  513.     N_I_W = W * Ratio '             New _ Image _ Width
  514.     N_I_H = H * Ratio '             New _ Image _ Height
  515.  
  516.     LeftUpperX = (sW - N_I_W) \ 2
  517.     RightDownX = sW - LeftUpperX
  518.     LeftUpperY = (sH - N_I_H) \ 2
  519.     RightDownY = sH - LeftUpperY
  520.  

Edit: After creating window press any key to start, i forgot DELA statement in script file (is used before screen recording)

8
Programs / Re: Program for neat display of long text
« on: February 06, 2022, 03:53:53 am »
Thank you all for your many inspiring ideas and examples. The MasterGy solution is beautiful, the test with the Steve program took me 61 seconds, and to comment on BPlus - you're right, my program just didn't expect that there would be so many characters in the text without a space. I see that you can really improve a lot on this as well. The solution at the beginning of this thread is still sufficient for the purpose for which it was written. I will publish the exact use and the reason why I deal with it soon. It is again just one fragment from a larger program. Thank you all for your many inspiring suggestions!

9
Programs / Re: Program for neat display of long text
« on: February 05, 2022, 10:16:16 am »
Now is it centered also in Y axis:

Code: QB64: [Select]
  1. 'TEXT statement automaticelly center and divide long text string on the screen. Also in Y axis now.
  2.  
  3.  
  4. T$ = "For English-speaking friends, this notice in English: This program is designed to split extremely long text so that whole words appear on a line and do not break at the end of a line. Dividing is only possible in spaces between words."
  5.  
  6. Screen NewImage(1024, 768, 32)
  7. f = LoadFont("arial.ttf", 25, "MONOSPACE")
  8. Font f
  9. Text T$
  10.  
  11.  
  12. Sub Text (t As String)
  13.     TextMax = Width \ FontWidth
  14.     Rows = Len(t) \ TextMax
  15.     y = Height / 2 - (FontHeight * Rows / 2)
  16.     Tr = 1
  17.     t$ = t$ + " "
  18.     Do Until LastSpace = Len(t)
  19.         Word$ = Mid$(t, Tr, TextMax)
  20.         LastSpace = InStrRev(Word$, " ")
  21.         S$ = Mid$(Word$, 1, LastSpace)
  22.         Center = Width / 2 - PrintWidth(S$) / 2
  23.         PrintString (Center, y), S$
  24.         y = y + FontHeight
  25.         t$ = Mid$(t$, LastSpace + 1)
  26.     Loop
  27.  

10
Programs / Re: Program for neat display of long text
« on: February 05, 2022, 09:53:54 am »

11
Programs / Program for neat display of long text
« on: February 05, 2022, 09:46:30 am »
This program has one goal. Divide the text where it is expected, ie where there is a space in the text. It looks funny now, but - I went to it so badly again, I won't even describe it, you wouldn't want to believe it anyway...

It's not visible, but - I mean - so much work and so much nonsense. I spend three hours on it (due to a completely disastrous concept) until I finally left the computer, deleted it all, and finally did it completely differently. The original source was a nasty monster and it didn't work. This is short and functional. So if anyone wants to deal with it, it's available here.

Code: QB64: [Select]
  1. 'prikaz TEXT automaticky rozdeli a vycentruje na radky dlouhy text:
  2.  
  3.  
  4. T$ = "Toto je ukazka velice dlouheho textoveho retezce, ktery ma program za ukol rozdelit na nekolik kratsich retezcu a zobrazit je vycentrovane. Deleni je mozne jen v mezerach. For English-speaking friends, this notice in English: This program is designed to split extremely long text so that whole words appear on a line and do not break at the end of a line. Dividing is only possible in spaces between words."
  5.  
  6. Screen NewImage(1024, 768, 32)
  7. f = LoadFont("arial.ttf", 25, "MONOSPACE")
  8. Font f
  9. Text T$
  10.  
  11.  
  12. Sub Text (t As String)
  13.     'spocitam pocet znaku na obrazovku, podle toho rozsekam retezec (v kusu o te delce najdu prvni mezeru zprava)
  14.     TextMax = Width \ FontWidth
  15.     Tr = 1
  16.     t$ = t$ + " "
  17.     Do Until LastSpace = Len(t)
  18.         Word$ = Mid$(t, Tr, TextMax)
  19.         LastSpace = InStrRev(Word$, " ")
  20.         S$ = Mid$(Word$, 1, LastSpace)
  21.         Center = Width / 2 - PrintWidth(S$) / 2
  22.         PrintString (Center, y), S$
  23.         y = y + FontHeight
  24.         t$ = Mid$(t$, LastSpace + 1)
  25.     Loop
  26.  

12
QB64 Discussion / Re: The QB64 Bible (Work In Progress)
« on: February 01, 2022, 05:09:09 pm »
@SMcNeill

Nicely written, it reads nicely. I'm glad you started, I'm looking forward to continuing. I also learned a few things I didn't know about before.

13
QB64 Discussion / Re: A lesson on how to break QB64
« on: January 24, 2022, 02:39:54 pm »
Hi. Maybe this can be solved by adding the Lock command to the IDE? This ensures that nothing - only the IDE can manipulate with the file on the disk. Maybe it would also like to check if each path and file exists before each compilation?

14
QB64 Discussion / Re: Shell Copy (small bug ?)
« on: January 21, 2022, 05:05:28 pm »
It is really very stupid to give such a short code as an attachment. Next time, I will not respond to such a post at all. Here's the solution (save it as untitled.bas)

Code: QB64: [Select]
  1. a$ = "copy " + Chr$(34) + _StartDir$ + "\untitled.bas" + Chr$(34) + Chr$(32) + Chr$(34) + "target.bas" + Chr$(34)
  2.  

15
Programs / Re: Playing with fire (again)
« on: January 18, 2022, 11:40:04 am »
This just wants an answer with a little modification :)

external files is not need

Code: QB64: [Select]
  1. _Title "Jolly Roger on Fire" 'b+ 2022-01-17
  2.  
  3. Const xmax = 500, ymax = 400
  4. Screen _NewImage(xmax, ymax, 32)
  5. _ScreenMove 360, 160
  6.  
  7. Dim p&(300) 'pallette
  8. For i = 1 To 100
  9.     fr = 240 * i / 100 + 15
  10.     p&(i) = _RGB(fr, 0, 0)
  11.     p&(i + 100) = _RGB(255, fr, 0)
  12.     p&(i + 200) = _RGB(255, 255, fr)
  13. w~& = _RGB32(255)
  14. jr& = _NewImage(188, 154, 32) '_LoadImage("Jolly Roger.png") '
  15. D = _Dest: _Dest jr&
  16. F = _LoadFont("arial.ttf", 64, "bold")
  17. _Font F, jr&
  18. _PrintString (10, 60), "NICE!"
  19. _PutImage , jr&, 0
  20. xxmax = 500: yymax = 200 'pixels too slow
  21. xstep = xmax / xxmax: ystep = ymax / yymax
  22. Dim f(xxmax, yymax), ff(xxmax, yymax) 'fire array and seed
  23. For y = 0 To yymax - 1
  24.     For x = 0 To xxmax - 1
  25.         If Point(x * xstep, y * ystep) = w~& Then f(x, y) = 300: ff(x, y) = 300
  26.     Next
  27.  
  28. While 1 'main fire
  29.     Cls
  30.     For y = 1 To yymax - 1
  31.         For x = 1 To xxmax - 1 'shift fire seed a bit
  32.             r = Rnd
  33.             If r > .9 Then f(x, y) = ff(x, y)
  34.         Next
  35.     Next
  36.     For y = 0 To yymax - 2 'fire based literally on 4 pixels below it like cellular automata
  37.         For x = 1 To xxmax - 1
  38.             f(x, y) = max((f(x - 1, y + 1) + f(x, y + 1) + f(x + 1, y + 1) + f(x - 1, y + 2)) / 4 - 5, 0)
  39.             Line (x * xstep, y * ystep)-Step(xstep, ystep), p&(f(x, y)), BF
  40.         Next
  41.     Next
  42.     _Display
  43.     _Limit 30
  44.  
  45. Function max (a, b)
  46.     If a > b Then max = a Else max = b
  47.  

Pages: [1] 2 3 ... 115