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

Pages: 1 ... 3 4 [5] 6 7 ... 537
61
Programs / Re: and another one for your toolbox...
« on: April 03, 2022, 10:48:58 pm »
Hey while we have this thread pulled down from a year ago, let's get this one posted too!

MessageBox function:

Code: QB64: [Select]
  1. ' Thank you FellippeHeitor!
  2. $If WIN Then
  3.         Function MessageBox (ByVal ignore&, message$, title$, Byval type&)
  4.     End Declare
  5.     DECLARE LIBRARY ""
  6.     FUNCTION MessageBox (BYVAL ignore&, message$, title$, BYVAL type&)
  7.     END DECLARE
  8. ' answer = MessageBox(0, "Hi, bplus. You can do this.", "This is platform-agnostic", 0)
  9. Dim m$, answer, temp
  10. m$ = "Message: press OK to return 1, press Cancel to return 2."
  11. answer = MessageBox(0, m$, "Test MessageBox", 4097) ' 4097 for OK = 1 Cancel = 2 Modal on top messagebox
  12. If answer = 1 Then
  13.     temp = MessageBox(0, "OK was pressed.", "Test MessageBox", 4096)
  14.     temp = MessageBox(0, "Cancel was pressed.", "Test MessageBox", 4096)
  15.  

Thank you Fellippe! Very lightweight in terms of LOC.

62
Programs / Re: QBJS - QBasic for the Web
« on: April 03, 2022, 06:46:03 pm »
Wow you are loading sounds right out of the Internet!

For some reason there seems to be either more circles or they are moving down screen faster than when I first made game. I couldn't of gotten that much older! I can barely make it across the screen 1 time, which is how the new scoring of the game is done in my versions. Remember Frogger Game?

63
Yeah there's STx paper right there:
Quote
Computers don't usually work in base 10, they work in base 2.

So consider yourself warned. :)

64
Programs / Re: QuadraLetterFall game
« on: April 03, 2022, 11:48:59 am »
I was wishing I could move the letters farther left or right than only a single step but I am new to this game. I don't want to appear harsh, I appreciate this is your first game or post and you are proud of your work. Ha! you should see my first from way back... this is way better!

65
Quote
@CharlieJV  you might be in habit of thinking of i as an incremented (by 1) integer index (like for arrays).

No, I am not thinking that.  When I do a For i = 1 to 5, I expect 1,2,3,4,5 to happen.

LOL, I thought April Fools day was yesterday!

And I say this:
Quote
jack is suggesting a While loop I think to try an get that last loop for i when it isn't an incremented (by 1) integer index but I had same idea tried it and still i a single type + .1 collects gabage and passes exactly 1.000 just like in For loop!
Translation While doesn't work either.

And both you and Steve repeat there is no advantage to While, so yeah! we all agree.

66
Programs / Re: QuadraLetterFall game
« on: April 02, 2022, 09:10:04 pm »
Yes it takes awhile to get use to. Is it supposed to start raining letters before you've read the instructions? I guess that's OK, after awhile one would have them memorized.

67
Programs / Re: QuadraLetterFall game
« on: April 02, 2022, 06:10:33 pm »
Welcome to the forum!

68
Programs / Re: B+'s Matrix Rain With World Map Backdrop
« on: April 02, 2022, 04:57:51 pm »
Yeah green and black look pretty good.

69
@CharlieJV  you might be in habit of thinking of i as an incremented (by 1) integer index (like for arrays).

When i is an integer it will do the last loop
Code: QB64: [Select]
  1. for i = 1 to 10
  2.  print i

jack is suggesting a While loop I think to try an get that last loop for i when it isn't an incremented (by 1) integer index but I had same idea tried it and still i a single type + .1 collects gabage and passes exactly 1.000 just like in For loop!



70
Programs / Re: B+'s Matrix Rain With World Map Backdrop
« on: April 02, 2022, 04:30:22 pm »
Interesting background Ken :)

71
Yeah it works for Doppler's problem too.
https://qb64forum.alephc.xyz/index.php?topic=4753.msg141737#msg141737

That does not guarantee a panacea, still have rounding errors when garbage builds up with adding and multiplying but this covers allot of problems.

72
Removing need to download some data, I put in a data statement and sleeping after each total so you can watch from start on screen.

Code: QB64: [Select]
  1. _Title "Total it" ' from Doppler "defsng math going off the rails, creating a total from list of numbers in file"
  2. ' ref: https://qb64forum.alephc.xyz/index.php?topic=4753.msg141698#msg141698
  3.  
  4. ' b+ mod removed file and replced with data line
  5. total = 0
  6. t = 0
  7.  
  8.     Read t$
  9.     If t$ = "EOD" Then Exit Do
  10.     t = Val(t$)
  11.     Print t
  12.     Print Str$(total) + " plus " + t$ + " equals ";
  13.     total = total + t
  14.     Print format$("#,###.##", Str$(total));
  15.     Print " press any to contiue..."
  16.     Sleep
  17. Data -750,21.71,13.67,22.92,91.25,119.63,10.84,18.46,40.44,171.73,3.08,92.39,57.20,22.79,-2.80,43.87,34.81,83.82,10.85,EOD
  18.  
  19. Function format$ (template As String, Source As String)
  20.     Dim d, s, n, i, t$
  21.     d = _Dest: s = _Source
  22.     n = _NewImage(80, 80, 0)
  23.     _Dest n: _Source n
  24.     Print Using template; Val(Source)
  25.     For i = 1 To 79
  26.         t$ = t$ + Chr$(Screen(1, i))
  27.     Next
  28.     If Left$(t$, 1) = "%" Then t$ = Mid$(t$, 2)
  29.     format$ = _Trim$(t$)
  30.     _Dest d: _Source s
  31.     _FreeImage n
  32.  
  33.  
  34.  

73
Steve said it some time ago, I paraphrase: Separate the calculations with variables function from the displaying of the results function.

You just need a good format routine to adjust for garbage that enters into calculations with floats. Probably would include rounding to the precision of decimals you desire in the output (display) format.

For CharlieJV this seems to work:
Code: QB64: [Select]
  1. For i = -1 To 1 Step .1
  2.     Print i, format$("##.#", Str$(i))
  3.  
  4. Function format$ (template As String, Source As String)
  5.     Dim d, s, n, i, t$
  6.     d = _Dest: s = _Source
  7.     n = _NewImage(80, 80, 0)
  8.     _Dest n: _Source n
  9.     Print Using template; Val(Source)
  10.     For i = 1 To 79
  11.         t$ = t$ + Chr$(Screen(1, i))
  12.     Next
  13.     If Left$(t$, 1) = "%" Then t$ = Mid$(t$, 2)
  14.     format$ = _Trim$(t$)
  15.     _Dest d: _Source s
  16.     _FreeImage n
  17.  
  18.  
 [ You are not allowed to view this attachment ]  

Well shoot, seems to be stopping at .9 not 1, dang!

OK this fixes that!
Code: QB64: [Select]
  1. For i = -1 To 1.0001 Step .1
  2.     Print i, format$("##.#", Str$(i))
  3. Function format$ (template As String, Source As String)
  4.     Dim d, s, n, i, t$
  5.     d = _Dest: s = _Source
  6.     n = _NewImage(80, 80, 0)
  7.     _Dest n: _Source n
  8.     Print Using template; Val(Source)
  9.     For i = 1 To 79
  10.         t$ = t$ + Chr$(Screen(1, i))
  11.     Next
  12.     If Left$(t$, 1) = "%" Then t$ = Mid$(t$, 2)
  13.     format$ = _Trim$(t$)
  14.     _Dest d: _Source s
  15.     _FreeImage n
  16.  

74
Programs / Re: Easter Egg Decorating
« on: April 01, 2022, 11:31:12 pm »
Ah but did you try with Rotozoom?
Code: QB64: [Select]
  1. _Title "Matrix Rain 4" 'B+ started 2019-03-16
  2. ' from Matrix Rain 2019-03-14
  3. ' or QB64 Purple Rain!
  4.  
  5. '>>> Save this file as: Matrix Rain 4.bas, so the program can load the strings from it.  <<<
  6.  
  7. '2019-03-15 This will attempt to spin the drops as they fall
  8. '2019-03-16  Don't need no damn Character Set.DAT file!!!
  9. '2019-03-16 Ijust want to see the vertical code strings dangle and twist.
  10.  
  11. '2019-03-19 Matrix Rain 4
  12. ' + added randWeight to weight the random sizes chosen so many more on small side than large
  13. ' + draw letters on a transparent background so the background of the letter does not cover
  14. '   the drops behind it.
  15.  
  16.  
  17. Const xmax = 1280
  18. Const ymax = 740
  19. Const nDrops = 500
  20. Type dropType
  21.     x As Single
  22.     sz As Single
  23.     curY As Integer
  24.     dxs As Single 'direction and change of spin some small fraction of 1, +-1/3, +-1/4, +-1/5...
  25.  
  26. Screen _NewImage(xmax, ymax, 32)
  27. _ScreenMove 80, 0 'for snap shot
  28. '_FULLSCREEN 'as screen saver
  29.  
  30. ReDim Shared fileStrings$(1000) 'container for these program lines that will be dangling
  31. Open "Matrix Rain 4.bas" For Input As #1
  32.     Line Input #1, fs$
  33.     If Len(LTrim$(fs$)) <> 0 Then 'less empty spaces
  34.         fileStrings$(i) = LTrim$(fs$)
  35.         i = i + 1
  36.     End If
  37. ReDim _Preserve fileStrings$(i - 1)
  38. ' check loading
  39. 'FOR i = 0 TO UBOUND(fileStrings$)
  40. '    PRINT i, fileStrings$(i)
  41. 'NEXT
  42. 'END
  43.  
  44. 'setup drops
  45. Dim Shared drop(nDrops) As dropType
  46. Dim Shared s$(nDrops)
  47.  
  48. For i = 0 To nDrops
  49.     newDrop i, 1
  50.  
  51. While _KeyDown(27) = 0
  52.     Cls
  53.     For i = 0 To nDrops
  54.         drawDrop (i)
  55.         drop(i).curY = drop(i).curY + 1
  56.         If drop(i).curY > Len(s$(i)) Then newDrop i, 0
  57.     Next
  58.     _Display
  59.     _Limit 25
  60.  
  61. Sub newDrop (i, start)
  62.     drop(i).x = Rnd * xmax 'set location
  63.     drop(i).sz = randWeight(.3, 5, 3) 'set size  weighted on small sizes
  64.     'length of text string can fit on screen
  65.     charLength = ymax \ (drop(i).sz * 16) + 1 'from size determine how many chars fit on screen
  66.     randLine = Int(Rnd * UBound(fileStrings$)) 'pick a random program line
  67.     s$(i) = Mid$(fileStrings$(randLine), 1, charLength) 'here is text string to dangle
  68.     While Len(s$(i)) < charLength
  69.         If randLine + 1 > UBound(fileStrings$) Then randLine = 0 Else randLine = randLine + 1
  70.         s$(i) = Mid$(s$(i) + " : " + fileStrings$(randLine), 1, charLength)
  71.     Wend
  72.     If start <> 0 Then drop(i).curY = Int(Rnd * (charLength)) + 1 Else drop(i).curY = 1 'flat and readable at curY
  73.     drop(i).dxs = 1 / (Int(Rnd * 7) + 3) 'change of spin rate +-1/3, +-1/4, ... +-1/9
  74.     If Rnd < .5 Then drop(i).dxs = -drop(i).dxs
  75.  
  76. Sub drawDrop (i)
  77.     For j = 1 To drop(i).curY
  78.         d = drop(i).curY - j
  79.         If d = 0 Then
  80.             c~& = _RGBA32(255, 100, 255, 225)
  81.         ElseIf d = 1 Then
  82.             c~& = _RGBA32(255, 50, 255, 205)
  83.         ElseIf d = 2 Then
  84.             c~& = _RGBA32(255, 25, 255, 180)
  85.         ElseIf d >= 3 Then
  86.             c~& = _RGBA32(255, 0, 255, 190 - d * 5)
  87.         End If
  88.         rot = 1: dir = -1
  89.         For k = 0 To d
  90.             rot = rot + drop(i).dxs * dir
  91.             If rot > 1 Then dir = -1 * dir: rot = 1 + drop(i).dxs * dir
  92.             If rot < -1 Then dir = dir * -1: rot = -1 + drop(i).dxs * dir
  93.         Next
  94.         drwChar Mid$(s$(i), j, 1), c~&, drop(i).x + 4 * drop(i).sz, drop(i).sz * 16 * (j - 1) + 8 * drop(i).sz, rot * drop(i).sz, drop(i).sz, 0
  95.     Next
  96.  
  97. Sub drwChar (char$, c As _Unsigned Long, midX, midY, xScale, yScale, Rotation) 'what ever the present color is set at
  98.     I& = _NewImage(8, 16, 32)
  99.     _Dest I&
  100.     Color c, _RGBA32(0, 0, 0, 0)
  101.     _PrintString (0, 0), char$
  102.     _Dest 0
  103.     RotoZoom2 midX, midY, I&, xScale, yScale, Rotation
  104.     _FreeImage I&
  105.  
  106. Sub RotoZoom2 (X As Long, Y As Long, Image As Long, xScale As Single, yScale As Single, Rotation As Single)
  107.     Dim px(3) As Single: Dim py(3) As Single
  108.     W& = _Width(Image&): H& = _Height(Image&)
  109.     px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
  110.     px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
  111.     sinr! = Sin(-Rotation): cosr! = Cos(-Rotation)
  112.     For i& = 0 To 3
  113.         x2& = (px(i&) * cosr! + sinr! * py(i&)) * xScale + X: y2& = (py(i&) * cosr! - px(i&) * sinr!) * yScale + Y
  114.         px(i&) = x2&: py(i&) = y2&
  115.     Next
  116.     _MapTriangle (0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  117.     _MapTriangle (0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image& To(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  118.  
  119. Function randWeight (manyValue, fewValue, power)
  120.     randWeight = manyValue + Rnd ^ power * (fewValue - manyValue)
  121.  
  122.  

BTW the letters, digits and symbols are the from the source QB64 code.

75
Programs / Re: Easter Egg Decorating
« on: April 01, 2022, 10:54:47 pm »
Yeah here are some cherry picked Textured Eggs:
Code: QB64: [Select]
  1. _Title "drawEasterEgg Textured" 'b+ 2022-03-30 mod 2022-04-01 add r,g,b parameter
  2. Const Xmax = 500, Ymax = 500, Pi = _Pi
  3. Screen _NewImage(Xmax, Ymax, 32)
  4. _ScreenMove 100, 100
  5. scale = 100
  6.     Cls
  7.     drawEasterEgg 250, 250, Rnd * scale + scale, Rnd * 2 * Pi, Rnd, Rnd, Rnd
  8.     Sleep
  9.  
  10.  
  11. Sub drawEasterEgg (xc, yc, scale, radianAngle, r, g, b) ' add rgb so can draw the same
  12.     For x = -1 To 1 Step .01
  13.         For y = -1 To 1 Step .01
  14.             If x < 0 Then c = c + .0005 Else c = c - .0005
  15.             If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then ' 1.6 * y orig
  16.                 If y > 0 Then
  17.                     Color _RGB32(128 * (1 - y) + 128 * (1 - y) * Sin(c * r), 128 * (1 - y) + 128 * (1 - y) * Sin(c * g), 127 * (1 - y) + 127 * (1 - y) * Sin(c * b))
  18.                 Else
  19.                     Color _RGB32(128 + 128 * Sin(c * r), 128 + 128 * Sin(c * g), 127 + 127 * Sin(c * b))
  20.                 End If
  21.                 a = _Atan2(y, x)
  22.                 d = scale * Sqr(x * x + y * y)
  23.                 PSet (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))
  24.             End If
  25.         Next
  26.     Next
  27.  
  28.  

 
texture but dark.PNG

 
Texture egg 2.PNG

 
Texture egg 3.PNG

Pages: 1 ... 3 4 [5] 6 7 ... 537