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 - Richard Frost

Pages: 1 [2] 3 4 ... 22
16
Programs / Re: ArcRings
« on: December 24, 2021, 01:25:49 am »
I threw in a _DELAY .01 after the last circle to be able to follow the action.  What I
learned  from this, mainly, is the _PI multiplier.   Super demo of that function.

17
Programs / Re: ArcRings
« on: December 24, 2021, 12:37:21 am »
Nice party simulation, but why would Pac Men, Commodore enthusiasts, and Communists hang out together?

18
A related matter is Ctrl \

In QB4.5 it brought up the Search dialog.  I asked that it added to QB64.
Instead it repeats the last search, duplicating F3.

Er.  It does bring up the Search dialog, the first time used, THEN it's
like F3.  Maybe that's what 4.5 did too. I forget.  Ignore this message.
I'd delete it if I saw a button for it.

19
QB64 Discussion / Re: simple array question (I forgot)
« on: December 22, 2021, 09:56:00 pm »
I make a SUB static in an effort to cut down on global variables.

If I've got one-time initializations for a SUB, it's either have a global flag
for that sub or a local one that's preserved by making the SUB static.  There's
probably a better way that escapes me.

20
QB64 Discussion / Re: simple array question (I forgot)
« on: December 22, 2021, 09:42:08 pm »
Another reason to initialize arrays (or any variables) to zero on your own is
the case of declaring an array in a SUB and later making the SUB static. 

21
Programs / Re: Screensaver: Super Simple Snowfall (with accumulation)
« on: December 22, 2021, 09:37:25 pm »
Much faster, therefore more convincing.  I tinkered with it a little to
try and get more speed (fewer layers and flakes), but just crashed it.

You qualify to put a pom-pom on your hat.  Eh?

22
Programs / Re: Screensaver: Super Simple Snowfall (with accumulation)
« on: December 21, 2021, 05:26:08 pm »
As usual, Bplus' effort is the prettiest.  But it's a bit slow.
And the near flakes are so large that when they hit the ground,
the planet should spit in two, or aliens jump out and demand
cheese products.

23
Programs / Re: Screensaver: Super Simple Snowfall (with accumulation)
« on: December 21, 2021, 12:18:52 am »
My old attempt at snow - could use upgrading to the capabilities of QB64.

Arrow keys control the direction and speed of the snow.

Code: QB64: [Select]
  1. DefInt A-Z
  2.  
  3. _Title "Xmas Tree"
  4.  
  5. q = 22000
  6. q2 = 5000
  7. z = 15
  8. x = 640
  9. sn = Val(Command$): If sn = 0 Then sn = 5000
  10.  
  11. Dim x(q), y(q), garr(q2), sarr(q2), p&(z), f(z)
  12. Dim sd(x), sdm(x), bx(x), by(x), sx(sn), sy(sn), wp(sn)
  13.  
  14. begin:
  15. GoSub init
  16.     t# = Timer
  17.     GoSub snow
  18.     GoSub star
  19.     If t# > sparkat# Then GoSub sparkle
  20.     If t# > colorat# Then GoSub ccycle
  21.     If t# > drawbt# Then GoSub drawballs
  22.     i$ = InKey$
  23.     If Len(i$) = 2 Then
  24.         v = Asc(Right$(i$, 1))
  25.         yinc = yinc - (v = 80) + (v = 72)
  26.         xinc = xinc - (v = 77) + (v = 75)
  27.     End If
  28.     If i$ = Chr$(13) Then GoTo begin
  29. Loop Until i$ = Chr$(27)
  30. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  31. timeinc:
  32. tvar# = Timer + tinc!
  33. If tvar# > 86399 Then tvar# = var# - 86400
  34. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  35. ccycle:
  36. cs = cs + 1 + (cs = 2) * 3 '        turn a string of bulbs on/off
  37. i = cs * 4 + 3 '                    starting point for color
  38. f(cs) = 1 - f(cs) '                 flag as on/off
  39. For tc = 0 To 3 '                   4 shades per color
  40.     If f(cs) Then z& = p&(i) Else z& = p&(i + tc)
  41.     Palette i + tc, z& '            turn color on/off
  42. Next tc
  43. tinc! = .5: GoSub timeinc: colorat# = tvar#
  44. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  45. sparkle:
  46. sss = 1 - sss
  47. If sss = 0 Then
  48.     Put (spx, spy), sarr(), PSet '  restore area under sparkle
  49.     i = Rnd * (n - 1) + 1 '         pick random tree point
  50.     spx = x(i) - 12
  51.     spy = y(i)
  52.     ti = Int(Rnd * 10) * 200 '      pick random sparkle (of 10)
  53.     Get (spx, spy)-(spx + 25, spy + 25), sarr() ' save area to be plotted on
  54.     Put (spx, spy), garr(ti), Or ' merge sparkle
  55. tinc! = .1 - (sss = 0) * Rnd
  56. GoSub timeinc
  57. sparkat# = tvar#
  58. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  59. snow:
  60. For d& = 0 To sn
  61.     sf = sf + 1 + (sf = sn) * (sn + 1)
  62.     xi = sx(sf)
  63.     yi = sy(sf)
  64.     sd = sd(xi)
  65.     sdm = sdm(xi)
  66.     If yi = (479 - sd) Then
  67.         If (sd = 0) Or (Point(xi, yi + 1)) = 15 Then
  68.             If sd = sdm Then
  69.                 If Rnd > .7 Then wp(sf) = -15
  70.             Else
  71.                 sd(xi) = sd + 1
  72.                 wp(sf) = -15
  73.             End If
  74.             For tty = yi To 479
  75.                 PSet (xi, tty), -(Rnd > .3) * 15
  76.             Next tty
  77.         End If
  78.     End If
  79.     If wp(sf) < 15 Then PSet (sx(sf), sy(sf)), Abs(wp(sf))
  80.     If (sf Mod 30) = 0 Then
  81.         xdir = Rnd * xinc
  82.         ydir = Rnd * yinc
  83.     End If
  84.     sx(sf) = sx(sf) + xdir
  85.     sy(sf) = sy(sf) + ydir
  86.     okx = (sx(sf) >= 0) And (sx(sf) < xm)
  87.     oky = (sy(sf) >= 0) And (sy(sf) < ym)
  88.     If okx And oky Then
  89.         wp(sf) = Point(sx(sf), sy(sf))
  90.         PSet (sx(sf), sy(sf)), 15
  91.     Else
  92.         wp(sf) = 0
  93.         GoSub assign
  94.     End If
  95. Next d&
  96. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  97. assign:
  98. If Rnd > .5 Then
  99.     sx(sf) = Rnd * (xm - 1)
  100.     If yinc > 0 Then sy(sf) = 0 Else sy(sf) = 479
  101.     If xinc < 0 Then sx(sf) = xm - 1 Else sx(sf) = 0
  102.     sy(sf) = Rnd * 478 + 1
  103. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  104. init:
  105. xm = 640: ym = 480: q = 200: x1 = 12: y1 = 12
  106. n = 0: xp = 0: ta = 45: ts = 4: needles = 0: bi = 0
  107. For s = 0 To 9 ' make stars
  108.     GoSub star
  109.     Get (0, 0)-(25, 25), garr(s * q)
  110.     Line (0, 0)-(25, 25), 0, BF
  111. x1 = 320: y1 = 50: ta = 30: ts = 20 ' big treeptop star
  112. GoSub setcolor
  113. GoSub drawbase
  114. GoSub drawtree
  115. GoSub drawballs
  116. GoSub snowinit
  117. For i = 0 To 2
  118.     f(i) = -(Rnd < .5)
  119. q = 0
  120. y1 = y1 - 15
  121. ba# = Timer
  122. tinc! = 2: GoSub timeinc: colorat# = tvar#
  123. tinc! = 3: GoSub timeinc: sparkat# = tvar#
  124. tinc! = 1: GoSub timeinc: keyat# = tvar#
  125. If pn& = 0 Then
  126.     pn& = 4
  127.     pd& = 1
  128.     xinc = 2
  129.     yinc = 2
  130. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  131. snowinit:
  132. For i = 1 To sn '                   create snow
  133.     sx(i) = Rnd * xm
  134.     sy(i) = Rnd * ym
  135.     wp(i) = 0
  136. For i = 1 To sn '                   show snow
  137.     PSet (sx(i), sy(i)), 15
  138. z1 = Rnd * 8 + 8
  139. z2 = Rnd * 8 + 8
  140. For x = 0 To xm '                   set drift limits
  141.     ty1 = 6 * Sin(x / z1) + 10
  142.     ty2 = 6 * Sin(x / z2) + 10
  143.     If ty1 < ty2 Then y = ty2 Else y = ty1
  144.     sdm(x) = y: sd(x) = 0
  145. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  146. drawtree:
  147. k = 20
  148. For i! = 0 To 8.5 Step .1
  149.     For x0 = -k To k
  150.         x2 = 320 + i! * x0
  151.         y2 = y1 + i! * 45
  152.         For zz = 0 To 1
  153.             xe = Rnd * 30 - 15
  154.             ye = Rnd * 30 - 4
  155.             Line (x2, y2)-(x2 + xe, y2 + ye), 2
  156.             needles = needles + 1
  157.         Next zz
  158.         n = n + 1
  159.         x(n) = x2
  160.         y(n) = y2
  161.     Next x0
  162.     tk = k * 2
  163.     i = n - tk + Rnd * tk '         random point from y level
  164.     If i < 1 Then i = 1 '           bounds checking
  165.     If i > n Then i = n
  166.  
  167.     If y(i) < 500 Then dball = -(Rnd > .1)
  168.     If y(i) < 400 Then dball = -(Rnd > .1)
  169.     If y(i) < 300 Then dball = -(Rnd > .1)
  170.     If y(i) < 200 Then dball = -(Rnd > .5)
  171.     If y(i) < 100 Then dball = -(Rnd > .8)
  172.  
  173.     If dball Then '                 do ball
  174.         bi = bi + 1
  175.         bx(bi) = x(i)
  176.         by(bi) = y(i)
  177.     End If
  178.  
  179.     For vv = 0 To 3 '               garland
  180.         mr! = ma! * Atn(1) / 45
  181.         xp = 320 + i! * k * Sin(mr!)
  182.         Line (xp, y(i))-Step(1, 1), 15, BF
  183.         ma! = (ma! + 87) Mod 360
  184.     Next vv
  185. Next i!
  186. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  187. drawbase:
  188. p& = &H1315
  189. For y = 428 To 460
  190.     Line (300, y)-(340, y), 1, , p&
  191.     p& = (p& And &HFFF) * 8 + (p& And &HF000) / (2 ^ 12)
  192. xl = -0
  193. For y = 460 To 479 Step 1
  194.     For x = 286 - xl To 354 + xl
  195.         c = -(Rnd > .5) - (Rnd > .5)
  196.         PSet (x, y), c
  197.     Next x
  198.     xl = xl + 1
  199. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  200. drawballs:
  201. For i = 1 To bi
  202.     x = bx(i)
  203.     y = by(i)
  204.     c = (i Mod 3) * 4 + 6 '         light string
  205.     For zz = 6 To 0 Step -1 '       shading (4 shades per color)
  206.         tc = c - zz \ 2
  207.         For qq = zz To 0 Step -1
  208.             z1 = Rnd * 2
  209.             z2 = Rnd * 2
  210.             Circle (x + z1, y + z2), qq, tc
  211.             Circle (x, y), qq, tc
  212.         Next qq
  213.     Next zz
  214. 'tinc! = 600: GOSUB timeinc: drawbt# = tvar# ' redraw (snow covers balls)
  215. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  216. star:
  217. tsc = (tsc + 1) Mod 10
  218. For a = 0 To 180 Step ta
  219.     r! = a * Atn(1) / 45
  220.     zx = Rnd * ts + 2
  221.     zy = zx + 2
  222.     x3 = x1 + zx * Cos(r!): x4 = x1 - zx * Cos(r!)
  223.     y3 = y1 + zy * Sin(r!): y4 = y1 - zy * Sin(r!)
  224.     Line (x3, y3)-(x4, y4), (tsc > 5) * -15
  225. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  226. setcolor:
  227. For c = 0 To 15
  228.     Read gg, r, g, b
  229.     p&(c) = CDbl(b) * 65536 + CDbl(g) * 256 + r
  230.     Palette c, p&(c)
  231. ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  232. Data 0,0,0,0
  233. Data 1,30,12,14
  234. Data 2,22,34,22
  235. Data 3,32,0,0
  236. Data 4,50,10,10
  237. Data 5,60,16,16
  238. Data 6,63,20,20
  239. Data 7,7,7,30
  240. Data 8,10,10,50
  241. Data 9,21,21,58
  242. Data 10,31,31,63
  243. Data 11,32,32,4
  244. Data 12,42,42,10
  245. Data 13,55,55,12
  246. Data 14,63,63,20
  247. Data 15,60,60,60
  248.  

24
Programs / Re: Screensaver: Super Simple Snowfall (with accumulation)
« on: December 21, 2021, 12:07:30 am »
I've never seen SCREEN 7 used before. Perhaps because you can do
page flipping with 9, and it has more dots to play with (640*350).

The TIMER ON and TIMER OFF are not necessary to use TIMER in the
way you are.  And your CPU might melt when the program crosses
midnite - a loop with no limit (lines 110 and 111). A better end
of loop condition would be:

    Loop Until Timer > ((sngStart + DELAY) mod 86400)

86400 = 24 hours * 60 minutes * 60 seconds, the duration of a day
on this planet. 

Are you aware that LONGs are generally faster then INTEGERs with
QB64?  Goes against the theory I learned, but such is the case.
But since you want backwards compatibility and the ultimate in
speed probably isn't required, INTEGERs are fine.

Nice demo.  I'll call Mr. Plow.



25
Programs / Monitor CPU temperature in Windows
« on: December 18, 2021, 02:40:19 am »
1) delete the first line if you don't download the icon file
2) needs liberati.ttf, a font that used to be included with QB64
3) works as is with XP, requires running as administrator in 10

Code: QB64: [Select]
  1. $ExeIcon:'temp2.ico'
  2. q$ = Chr$(34) '                             quote character
  3. Screen _NewImage(140, 64, 32)
  4. If _FileExists("liberati.ttf") = 0 Then System
  5. f& = _LoadFont("liberati.ttf", 60)
  6.  
  7. Open "ztemp.bat" For Output As #1
  8. Print #1, "@echo off"
  9. Print #1, "for /f " + q$ + "skip=1 tokens=2 delims==" + q$ + " %%A in ('wmic /namespace:\\root\wmi PATH MSAcpi_ThermalZoneTemperature get CurrentTemperature /value') do set /a " + q$ + "HunDegCel=(%%~A*10)-27315" + q$
  10. Print #1, "echo %HunDegCel:~0,-2%.%HunDegCel:~-2% Degrees Celsius"
  11.  
  12.     Shell _Hide "ztemp.bat > ztemp.dat"
  13.     If _FileExists("ztemp.dat") Then
  14.         Cls
  15.         Open "ztemp.dat" For Input As #1
  16.         Line Input #1, z$
  17.         Close #1
  18.         z& = Val(z$)
  19.         _Font f&: _PrintString (10 - (z < 100) * 20, 5), LTrim$(Str$(z&))
  20.         _Font 14: Locate 2, 15: Print Chr$(248); "C";
  21.     End If
  22. Shell "del ztemp*.*"

26
Programs / Re: Chess
« on: December 15, 2021, 01:55:02 am »
1) pieces move smoother
2) was error in viewing funny pix ("Z") - changed a lot of vars to _byte for more speed
3) setup menu available while computer thinking, with the last 2 items not available
4) setup and file playback menus should pop up smoother/faster

I do not understand that mem.h problem.  It *is* in \chessdat, and in the main directory
too.  Works fine for me with XP and 10 (not declared for Linux).

C'mon, someone with a hot machine tell me what speed they get.  I'm up to 1,879,497
moves per second on an 2007 (ancient!) Toshiba A200, albeit after running it over 24
hours.  Average speed is maybe half that.  The speed will start going down if I ever
make it smarter.

Updates:
Dec 16: Substantial CPU load decrease by eliminating some unnecessary string assignments.
Dec 30: Nicer background.
Jan 2: Graphical piece selection for promotion, and last captured piece is highlighted for a bit.
Jan 3: Added CPU load to graph for Linux version.  Because it's fun to watch squiggly lines.
Jan 4: Added another background.
Jan 6: Added a button (lightning) for bare bones mode, which plays faster.  Plus better mouse handling.
Jan 18: Added Fellippe and Spriggsy, with appropriate catchphrases, to the funny set.  Also loads faster.

27
Programs / Re: Chess
« on: December 14, 2021, 12:53:51 am »
7z updated above.  I sure miss the simplicity of a batch file calling ye olde pkzip. 
I could still do that, sure, but DOSBox is a bit slooooooow.

And I updated the file AGAIN because QB64 v2.0.2 , which I just got, didn't like
one of my functions.

The temperature sensing works in XP and Linux Mint.  With Win10, it only works
if the program is run as administrator.  So for Windows I throttle the FPS if the CPU
load is high, not the temperature. 

Temperature is obtained by shelling to wmic with Windows, or sensors with Linux.

28
QB64 Discussion / Re: any idea why the color white is not visible?
« on: December 13, 2021, 03:59:47 am »
Good it's fixed, and no cats have to be dipped in paint.

29
Programs / Re: Chess
« on: December 13, 2021, 03:50:27 am »
"Help, I've fallen and I can't get up!"

I can't help you.  I'm up in Canada, helping Santa wrap presents.
But while you're down there, play chess by using the new rotate
feature (F12 or use the menu).  When rotated +/- 90 degrees only
the board and main menu are visible, but that's usually enough.
This rotate feature, at 180 degrees, is also handy for human vs
human play, esp. for a tablet.

I'd like to know the top MPS (moves per second) everyone gets.
My best computer, a 12 year old dual processor Lenovo portable,
only manages 1.4 million.  And it's only the Lenovo that throttles
the FPS if/when there are processes like video in the background.
My other computers, 2 Dells and a Toshiba running Linux Mint, stay
at about 60% CPU load.

tf.bas & minimax.bas added to zip.  Sorry I forgot before.


30
QB64 Discussion / Re: Forum outages
« on: December 06, 2021, 08:12:33 pm »
The problem with IF is more with flushing/reloading the pipeline, which requires calling up a plumber.

More speed tips:

1) longs are faster than integers, so DEFLNG a-z right off the bat
2) DO/LOOP faster than FOR/NEXT
3) replace a complicated line like IF (a < b) and (b = 0) and (c <> 1) with:

Code: QB64: [Select]
  1. if a < b then
  2. if (b = 0) and (c <>1) then
  3. 'whatever
  4.  
...when a < b is the most common situation.


Pages: 1 [2] 3 4 ... 22