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

Pages: 1 2 [3] 4 5 ... 29
31
Programs / Re: courtesy cubes :)
« on: February 15, 2022, 05:30:20 pm »
wow nice! here is a nice screensaver us newbs here can appreciate.  Now are the momenta and velocities gaussian distributed?

32
QB64 Discussion / Re: Just a Code Sample: EXIT SUB
« on: February 14, 2022, 06:02:15 pm »
So everyone's getting on-board with OPTION _EXPLICIT but DECLARE is a waste of space..

33
Programs / Re: Draw any curve using only circles
« on: February 14, 2022, 11:07:03 am »
You can't use a circle to solve that problem because the slope of the slope of the slope won't slope the slope of the sloping, making a sloping mess!  All you can do is use a bezier curve to find the solution, and that's not possible with circles.

Imagine having to mow the lawn or run a tractor/combine harvester in a bezier curve, Bill needs to learn to face reality and think outside the box every once in a while.

34
damn, Steve, it took you a whole page to explain what bplus said in six characters

35
QB64 Discussion / Re: Just a Code Sample: EXIT SUB
« on: February 13, 2022, 04:45:36 pm »
This is QB64 man! You don't have to Declare Sub nor "Call" Subs. :)

The IDE doesn't even cap Declare Sub, interesting...

That sure is a lot of liberty, but where is the justice?

36
Programs / Re: Ken's U.S. Flag version 4 - With moving clouds
« on: February 12, 2022, 05:55:44 pm »
B+ mod time, you know the drill

Code: QB64: [Select]
  1. _Title "U.S. Flag - Use space bar to change hills background."
  2. const sw = 800
  3. const sh = 600
  4. Screen _NewImage(sw, sh, 32)
  5. x = 150
  6. y = 100
  7. Dim cf&(113000)
  8.  
  9. Const nn = 1
  10. Const twidth = sw, theight = sh, zoom = 128
  11. Dim Shared noise(nn * twidth * theight) '//the noise array
  12. Dim Shared texture(nn * twidth * theight) '//texture array
  13. Dim Shared pal(256) As _Unsigned Long '//color palette
  14.  
  15. MakePalette 255, 155, 255, 10, 100, 180
  16. GenerateNoise
  17. buildtexture
  18.  
  19. vs = _NewImage(twidth, theight, 32)
  20. drawtexture 0
  21.  
  22. GoSub hills:
  23.  
  24. dim vvs as long
  25. vvs = _newimage(sw, sh, 32)
  26. vvs2 = _newimage(sw, sh, 32)
  27. _dest vvs
  28.  
  29. 'Stars
  30. Line (x, y)-(x + 185, y + 130), _RGB32(0, 0, 255), BF
  31. For xx = 155 To 345 Step 32
  32.     For yy = 105 To 220 Step 28
  33.         Line (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  34.         Line (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  35.         Line (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  36.         Line (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  37.         Line (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  38.         Paint (xx + 7, yy + 2), _RGB32(255, 255, 255)
  39.         Paint (xx + 7, yy + 6), _RGB32(255, 255, 255)
  40.         Paint (xx + 11, yy + 10), _RGB32(255, 255, 255)
  41.         Paint (xx + 4, yy + 10), _RGB32(255, 255, 255)
  42.         Paint (xx + 3, yy + 6), _RGB32(255, 255, 255)
  43.         Paint (xx + 12, yy + 6), _RGB32(255, 255, 255)
  44.     Next yy
  45. Next xx
  46.  
  47. For xx = 172 To 329 Step 32
  48.     For yy = 118.9 To 213.05 Step 28
  49.         Line (xx + 2, yy + 12)-(xx + 7, yy), _RGB32(255, 255, 255)
  50.         Line (xx + 7, yy)-(xx + 13, yy + 12), _RGB32(255, 255, 255)
  51.         Line (xx + 13, yy + 12)-(xx, yy + 5), _RGB32(255, 255, 255)
  52.         Line (xx, yy + 5)-(xx + 15, yy + 5), _RGB32(255, 255, 255)
  53.         Line (xx + 15, yy + 5)-(xx + 2, yy + 12), _RGB32(255, 255, 255)
  54.         Paint (xx + 7, yy + 2), _RGB32(255, 255, 255)
  55.         Paint (xx + 7, yy + 6), _RGB32(255, 255, 255)
  56.         Paint (xx + 11, yy + 10), _RGB32(255, 255, 255)
  57.         Paint (xx + 4, yy + 10), _RGB32(255, 255, 255)
  58.         Paint (xx + 3, yy + 6), _RGB32(255, 255, 255)
  59.         Paint (xx + 12, yy + 6), _RGB32(255, 255, 255)
  60.     Next yy
  61. Next xx
  62.  
  63. 'Stripes
  64. For rs = 100 To 230 Step 37.2
  65.     w = w + 1
  66.     Line (335, rs)-(612.5, rs + 18.6), _RGB32(255, 0, 0), BF
  67.     If w > 3 Then GoTo nex:
  68.     Line (335, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 255, 255), BF
  69. Next rs
  70. nex:
  71. w = 0
  72. dim z(98) as _unsigned _integer64 'Marshawn polynomial coefficients of the nth order
  73. z(0)=&h3000000~&&:z(1)=&hFFF8~&&:z(2)=&h0~&&:z(3)=&h830E000000000000~&&
  74. z(4)=&h47FF080000000~&&:z(5)=&h1BFFFE6000~&&:z(6)=&h37FFFE~&&
  75. z(7)=&h900000000000006E~&&:z(8)=&hFFFFC80000000000~&&:z(9)=&h5FFFFFE8000000~&&
  76. z(10)=&hBFFFFFF400~&&:z(11)=&h17FFFFE~&&:z(12)=&hF80000000000017A~&&
  77. z(13)=&hFFFFFA0000000000~&&:z(14)=&h2F7FFFFFA000000~&&:z(15)=&h2EDFFFFFF00~&&
  78. z(16)=&h2DBFFFE~&&:z(17)=&hFD000000000002D6~&&:z(18)=&hFFFFED0000000000~&&
  79. z(19)=&h2B7FFFFAD000000~&&:z(20)=&h6B41FC7AD00~&&:z(21)=&h6E3EFB8~&&
  80. z(22)=&hAD0000000000066C~&&:z(23)=&h17463D0000000000~&&:z(24)=&h2D016C0B5000000~&&
  81. z(25)=&h2B00A805900~&&:z(26)=&h2A00A80~&&:z(27)=&h1B000000000002A0~&&
  82. z(28)=&h9801A0000000000~&&:z(29)=&h3A00A801A000000~&&:z(30)=&hA008805A00~&&
  83. z(31)=&h901660~&&:z(32)=&h580000000000026E~&&:z(33)=&hEC90D00000000000~&&
  84. z(34)=&h2F0096F2F000000~&&:z(35)=&h6FFE9B0F100~&&:z(36)=&h2FFD0BE~&&
  85. z(37)=&hFD000000000002C6~&&:z(38)=&hD2DFFD0000000000~&&:z(39)=&h33BD55F1B000000~&&
  86. z(40)=&h16DEDBDEA00~&&:z(41)=&h54F27A~&&:z(42)=&hF400000000000046~&&
  87. z(43)=&hEEFAA80000000000~&&:z(44)=&h4B5D5EA0000000~&&:z(45)=&h6BD1AFA000~&&
  88. z(46)=&h69FFFA~&&:z(47)=&h64~&&:z(48)=&h57AB400000000000~&&:z(49)=&h25D7AF40000000~&&
  89. z(50)=&h2BF3BF4000~&&:z(51)=&h2B7FEE~&&:z(52)=&h4000000000000024~&&
  90. z(53)=&h6EAEC00000000000~&&:z(54)=&h19FEBC80000000~&&:z(55)=&h4FFBC8000~&&
  91. z(56)=&hE000003C0002AFC8~&&:z(57)=&h1080000420000~&&:z(58)=&h7032000204000040~&&
  92. z(59)=&hBFEC00020400~&&:z(60)=&h8080009FC80004~&&:z(61)=&h400004060004010~&&
  93. z(62)=&h18040000C19C00~&&:z(63)=&h3FE0007604000080~&&:z(64)=&h8700000003860400~&&
  94. z(65)=&h100F0E000000C1E~&&:z(66)=&h2000100E61C0000~&&:z(67)=&hE1CC010001009FC2~&&
  95. z(68)=&hC0078FF601000100~&&:z(69)=&h3B8703837020200~&&:z(70)=&h101803F2FC3B002~&&
  96. z(71)=&h2000101FC07F83E~&&:z(72)=&h80FE0200008207C0~&&:z(73)=&hF01C0F810600005C~&&
  97. z(74)=&h3C00007800E800~&&:z(75)=&h1F00036000~&&:z(76)=&h1DFE01E~&&
  98. z(77)=&hEE00000000001E7E~&&:z(78)=&h8307F9E000000000~&&:z(79)=&hE3FC1CE07F1C0000~&&
  99. z(80)=&h381E3FC1C00E0FF0~&&:z(81)=&hC03047F1FF0F0002~&&:z(82)=&hC3FE3FC8C31E7078~&&
  100. z(83)=&h3839C10C83E2~&&:z(84)=&h8180000006071B04~&&:z(85)=&hC2180C00000000C0~&&
  101. z(86)=&h610442E070000000~&&:z(87)=&h381D085B018000~&&:z(88)=&h60348360C~&&:z(89)=&h181B0~&&
  102. z(90)=&h2430000000000000~&&:z(91)=&h30D0C04000000000~&&:z(92)=&h80D00800000~&&
  103. z(93)=&h4070100~&&:z(94)=&h202~&&:z(95)=&h8200000000000000~&&:z(96)=&h1045C0000000000~&&
  104. z(97)=&hEC60000000~&&
  105. dim as _unsigned _integer64 b, i, n, j,d
  106. redim f(320, 240) as double
  107. redim ff(320, 240) as double
  108. dim p(300) as long
  109. for i=1 to 100
  110.         fr = 240*i/100 + 15
  111.         p(i) = _rgb(fr,0,0)
  112.         p(i + 100) = _rgb(255, fr, 0)
  113.         p(i + 200) = _rgb(255, 255, fr)
  114. For rs = 230 To 341.6 Step 37.2
  115.     r = r + 1
  116.     Line (150, rs)-(612.5, rs + 18.6), _RGB32(255, 255, 255), BF
  117.     If r > 3 Then GoTo nex2:
  118.     Line (150, rs + 18.6)-(612.5, rs + 37.2), _RGB32(255, 0, 0), BF
  119. Next rs
  120. i = 0
  121. n = 0
  122. b = z(n)
  123. xstep = 3
  124. ystep = 2
  125. for y=0 to 79-1
  126. for x=0 to 80-1
  127.         if (b and _shl(1~&&, 63)) then
  128.                 line (280 + x*xstep, 150 + y*ystep)-step(xstep,ystep),_rgb(0,0,0),bf
  129.                 f (x + 120, y + 80) = 300
  130.                 ff(x + 120, y + 80) = 300
  131.         end if
  132.         b = _shl(b, 1~&&)
  133.         i=i+1
  134.         if i = 64 then
  135.                 n = n + 1
  136.                 b = z(n)
  137.                 i = 0
  138.         end if
  139. paint (370,190),_rgb(0,0,0)
  140. paint (420,190),_rgb(0,0,0)
  141. _source vvs2
  142. nex2:
  143. r = 0
  144. For fy = 100 To 341.6
  145.     For fx = 150 To 612.5
  146.         t5 = t5 + 1
  147.         cf&(t5) = Point(fx, fy)
  148.     Next fx
  149. Next fy
  150. t = 20
  151.  
  152. 'On Timer(2) GoSub hills:
  153. 'Timer On
  154.  
  155. ii = 0
  156. jj = -1
  157.  
  158.     'Sky
  159.     ii = ii + 1
  160.     If ii >= sw Then
  161.         ii = 0
  162.         jj = Not jj
  163.     End If
  164.  
  165.     If jj Then
  166.         _PutImage (ii, 0)-Step(sw, sh), vs
  167.         _PutImage (ii, 0)-Step(-sw, sh), vs
  168.     Else
  169.         _PutImage (ii + sw, 0)-Step(-sw, sh), vs
  170.         _PutImage (ii - sw, 0)-Step(sw, sh), vs
  171.     End If
  172.  
  173.     'hour$ = Left$(Time$, 2)
  174.     'hour = Val(hour$)
  175.     'If hour < 21 And hour >= 6 Then
  176.         'Paint (2, 2), _RGB32(0, 205, 255)
  177.     'End If
  178.     _PutImage , hills&, 0
  179.     'Flag Pole
  180.     For sz = .25 To 10 Step .25
  181.         Circle (145, 80), sz, _RGB32(122, 128, 166)
  182.     Next sz
  183.     Line (142, 80)-(147, 600), _RGB32(122, 128, 166), BF
  184.  
  185.         _dest vvs2
  186.         _putimage ,vvs
  187.         for y=1 to 240-1
  188.         for x=1 to 320-1
  189.                 dim r as double
  190.                 r = rnd
  191.                 if r > 0.65 then f(x,y) = ff(x,y)
  192.         next
  193.         next
  194.         for y=0 to 240-2
  195.         for x=1 to 320-1
  196.                 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)
  197.                 line (x*xstep - 81, y*ystep - 6)-step(xstep, ystep), p(f(x,y)),bf
  198.         next
  199.         next
  200.  
  201.         _source vvs2
  202.         r = 0
  203.         t5 = 0
  204.         For fy = 100 To 341.6
  205.                 For fx = 150 To 612.5
  206.                         t5 = t5 + 1
  207.                         cf&(t5) = Point(fx, fy)
  208.                 Next fx
  209.         Next fy
  210.         t = 20
  211.         _source 0
  212.         _dest 0
  213.  
  214.     fx2 = fx2 + 1.2
  215.     If fx2 > 5 Then fx2 = 1.2
  216.     For fy = 100 To 341.6
  217.         For fx = 150 To 612.5
  218.             t6 = t6 + 1
  219.                         if cf&(t6) <> _rgb(0,0,0) then
  220.                         PSet ((Sin(fy * 0.017453 / fx2) * t) + fx, (Sin(fx * 0.017453 / fx2) * t) + fy), cf&(t6)
  221.                         end if
  222.         Next fx
  223.     Next fy
  224.  
  225.     t6 = 0
  226.     If tt = 0 Then t = t + 1
  227.     If t > 10 Then tt = 1
  228.     If tt = 1 Then t = t - 1
  229.     If t < -10 Then tt = 0
  230.     a$ = InKey$
  231.     If a$ = Chr$(27) Then End
  232.     'If a$ = " " Then
  233.         GoSub hills:
  234.  
  235.     _Display
  236.     _Limit 50
  237.  
  238. hills:
  239. 'Random Hills
  240. hills& = _NewImage(_Width, _Height, 32)
  241. _Dest hills&
  242. hills = 8'Int(Rnd * 40) + 3
  243. For h = -3 To hills + 1
  244.     hx = 800*h/hills + (ii*8 mod 300) 'Int(Rnd * 800) + 1
  245.     size = 300'Int(Rnd * 450) + 75
  246.     cl = 15'Int(Rnd * 55)
  247.     shape = 0.7'Rnd
  248.     For sz = .25 To size Step .25
  249.         cl = cl + .05
  250.         Circle (hx, 599), sz, _RGB32(10, cl, 20), , , shape
  251.     Next sz
  252. hills = 5'Int(Rnd * 40) + 3
  253. For h = -3 To hills + 1
  254.     hx = 800*h/hills + (ii*5 mod 300) 'Int(Rnd * 800) + 1
  255.     size = 250'Int(Rnd * 450) + 75
  256.     cl = 35'Int(Rnd * 55)
  257.     shape = 0.7'Rnd
  258.     For sz = .25 To size Step .25
  259.         cl = cl + .05
  260.         Circle (hx, 599), sz, _RGB32(10, cl, 20), , , shape
  261.     Next sz
  262. hills = 3'Int(Rnd * 40) + 3
  263. For h = -3 To hills + 1
  264.     hx = 800*h/hills + (ii mod 300) 'Int(Rnd * 800) + 1
  265.     size = 180'Int(Rnd * 450) + 75
  266.     cl = 55'Int(Rnd * 55)
  267.     shape = 0.7'Rnd
  268.     For sz = .25 To size Step .25
  269.         cl = cl + .05
  270.         Circle (hx, 599), sz, _RGB32(10, cl, 20), , , shape
  271.     Next sz
  272.  
  273. function max(a, b)
  274.         if a > b then max = a else max = b'+
  275.  
  276. '//interpolation code by rattrapmax6
  277. Sub MakePalette (sr, sg, sb, er, eg, eb) ' (b+) start and end RGB's ? yes
  278.     Dim i, istart(3), iend(3), ishow(3), rend(3), interpol(3)
  279.  
  280.     interpol(0) = 255
  281.     istart(1) = sr
  282.     istart(2) = sg
  283.     istart(3) = sb
  284.     iend(1) = er
  285.     iend(2) = eg
  286.     iend(3) = eb
  287.     interpol(1) = (istart(1) - iend(1)) / interpol(0)
  288.     interpol(2) = (istart(2) - iend(2)) / interpol(0)
  289.     interpol(3) = (istart(3) - iend(3)) / interpol(0)
  290.     rend(1) = istart(1)
  291.     rend(2) = istart(2)
  292.     rend(3) = istart(3)
  293.  
  294.     For i = 0 To 255
  295.         ishow(1) = rend(1)
  296.         ishow(2) = rend(2)
  297.         ishow(3) = rend(3)
  298.  
  299.         pal(i) = _RGB32(ishow(1), ishow(2), ishow(3))
  300.  
  301.         rend(1) = rend(1) - interpol(1)
  302.         rend(2) = rend(2) - interpol(2)
  303.         rend(3) = rend(3) - interpol(3)
  304.     Next i
  305.  
  306. '//generates random noise.
  307. Sub GenerateNoise ()
  308.     Dim As Long x, y
  309.  
  310.     For x = 0 To nn * twidth - 1
  311.         For y = 0 To theight - 1
  312.             zz = Rnd
  313.             noise(x + y * twidth) = zz
  314.         Next y
  315.     Next x
  316.  
  317.  
  318. Function SmoothNoise (x, y)
  319.     '//get fractional part of x and y
  320.     Dim fractx, fracty, x1, y1, x2, y2, value
  321.     fractx = x - Int(x)
  322.     fracty = y - Int(y)
  323.  
  324.     '//wrap around
  325.     x1 = (Int(x) + nn * twidth) Mod twidth
  326.     y1 = (Int(y) + theight) Mod theight
  327.  
  328.     '//neighbor values
  329.     x2 = (x1 + nn * twidth - 1) Mod twidth
  330.     y2 = (y1 + theight - 1) Mod theight
  331.  
  332.     '//smooth the noise with bilinear interpolation
  333.     value = 0.0
  334.     value = value + fractx * fracty * noise(x1 + y1 * twidth)
  335.     value = value + fractx * (1 - fracty) * noise(x1 + y2 * twidth)
  336.     value = value + (1 - fractx) * fracty * noise(x2 + y1 * twidth)
  337.     value = value + (1 - fractx) * (1 - fracty) * noise(x2 + y2 * twidth)
  338.  
  339.     SmoothNoise = value
  340.  
  341. Function Turbulence (x, y, size)
  342.     Dim value, initialsize
  343.  
  344.     initialsize = size
  345.     While (size >= 1)
  346.         value = value + SmoothNoise(x / size, y / size) * size
  347.         size = size / 2.0
  348.     Wend
  349.     Turbulence = (128.0 * value / initialsize)
  350.  
  351. '//builds the texture.
  352. Sub buildtexture
  353.     Dim x, y
  354.  
  355.     For x = 0 To nn * twidth - 1
  356.         For y = 0 To theight - 1
  357.             texture(x + y * nn * twidth) = Turbulence(x, y, zoom)
  358.         Next y
  359.     Next x
  360.  
  361. '//draws texture to screen.
  362. Sub drawtexture (dx)
  363.     Dim x, y
  364.     Dim As Long c, r, g, b
  365.  
  366.     For x = 0 To twidth - 1
  367.         For y = 0 To theight - 1
  368.             c = pal(texture(((x + dx) + y * nn * twidth)))
  369.             r = _Red(c)
  370.             g = _Green(c)
  371.             b = _Blue(c)
  372.             c = _RGB(r - 0.2 * y, g - 0.2 * y, b - 0.2 * b)
  373.             PSet (x, y), c 'pal(texture(((x + dx) + y * nn*twidth)))
  374.         Next y
  375.     Next x
  376.  

37
QB64 Discussion / Re: February Number Challenge
« on: February 11, 2022, 04:39:03 pm »
Is that not a JustBasic user?  What is the difference between JB and LB -- where is the line drawn between liberty and justice?  Which one would you recommend to a beginner?  In an ideal world, would you prefer that everyone here used JB instead of QB64 instead, the same as I would but for FB?

38
QB64 Discussion / Re: True and False
« on: February 09, 2022, 05:55:17 pm »
if a> 5 then b = b +1

this can also be the case:
b = b + abs (a> 5)

nice mod!

39
Programs / Re: Ken's U.S. Flag version 4 - With moving clouds
« on: February 09, 2022, 12:30:54 pm »
I am not seeing all that cloud making code being activated which BTW came from here:
https://qb64forum.alephc.xyz/index.php?topic=4615.msg140454#msg140454

Because it happens to be daytime with clear sunny skies

40
Programs / Re: 4 Letter Word Invaders Game
« on: February 08, 2022, 04:48:47 pm »
B+ mod!

Code: QB64: [Select]
  1. _Title "Quick Falling Letters Game B+ mod" 'b+ 2022-02-08
  2.  
  3. const nn = 1
  4. Const twidth = 640, theight = 480, zoom = 128
  5. Dim Shared noise(nn*twidth * theight) '//the noise array
  6. Dim Shared texture(nn*twidth * theight) '//texture array
  7. Dim Shared pal(256) As _Unsigned Long '//color palette
  8.  
  9. Dim letters$(1 To 25), lx(1 To 25) As Integer ' screen 0 25 lines 80 letters across
  10. Dim hits, letterPos, i, K$, GameOver
  11.  
  12. screen _newimage(640,480,32)
  13. MakePalette 255, 155, 255, 10, 100, 180
  14. GenerateNoise
  15. buildtexture
  16.  
  17. vs = _newimage(twidth, theight, 32)
  18. drawtexture 0
  19.  
  20. ii = 0
  21. jj = -1
  22. kk = 0
  23.         kk = kk + 1
  24.         ii = ii + 1
  25.         if ii >= 640 then
  26.                 ii = 0
  27.                 jj = not jj
  28.         end if         
  29.  
  30.         if jj then
  31.                 _putimage (ii , 0)-step(640,480), vs
  32.                 _putimage (ii , 0)-step(-640,480), vs
  33.         else
  34.                 _putimage (ii + 640, 0)-step(-640,480), vs
  35.                 _putimage (ii - 640 , 0)-step(640,480), vs
  36.         end if
  37.  
  38.     'Cls
  39.         if kk mod 50 = 0 then
  40.                 letterPos = letterPos + 1 ' generate new letter at each round
  41.                 If letterPos > 24 Then GameOver = -1
  42.                 For i = letterPos - 1 To 1 Step -1 ' cycle letters and positions down
  43.                         letters$(i + 1) = letters$(i)
  44.                         lx(i + 1) = lx(i)
  45.                 Next
  46.                 letters$(1) = Chr$(Int(Rnd * 26) + 97) ' start a new letter
  47.                 lx(1) = Int(Rnd * 80) + 1 ' at a new place
  48.                 K$ = InKey$ ' check key presses for match to current letterPos
  49.                 While K$ = letters$(letterPos) ' catch up with all keypresses
  50.                         hits = hits + 1 '            add to score
  51.                         letterPos = letterPos - 1
  52.                         K$ = InKey$ '                check next keypress
  53.                 Wend
  54.         end if
  55.  
  56.         For i = 1 To letterPos 'show board what's left of letters
  57.                 Locate i, lx(i): Print letters$(i);
  58.         Next
  59.         Locate 25, 36: Print "Hits:"; hits
  60.  
  61.         _display
  62.     _Limit 50
  63. Loop Until GameOver
  64. Locate 25, 26: Print "Game Over"
  65.  
  66. '//interpolation code by rattrapmax6
  67. Sub MakePalette (sr, sg, sb, er, eg, eb) ' (b+) start and end RGB's ? yes
  68.     Dim i, istart(3), iend(3), ishow(3), rend(3), interpol(3)
  69.  
  70.     interpol(0) = 255
  71.     istart(1) = sr
  72.     istart(2) = sg
  73.     istart(3) = sb
  74.     iend(1) = er
  75.     iend(2) = eg
  76.     iend(3) = eb
  77.     interpol(1) = (istart(1) - iend(1)) / interpol(0)
  78.     interpol(2) = (istart(2) - iend(2)) / interpol(0)
  79.     interpol(3) = (istart(3) - iend(3)) / interpol(0)
  80.     rend(1) = istart(1)
  81.     rend(2) = istart(2)
  82.     rend(3) = istart(3)
  83.  
  84.     For i = 0 To 255
  85.         ishow(1) = rend(1)
  86.         ishow(2) = rend(2)
  87.         ishow(3) = rend(3)
  88.  
  89.         pal(i) = _RGB32(ishow(1), ishow(2), ishow(3))
  90.  
  91.         rend(1) = rend(1) - interpol(1)
  92.         rend(2) = rend(2) - interpol(2)
  93.         rend(3) = rend(3) - interpol(3)
  94.     Next i
  95.  
  96. '//generates random noise.
  97. Sub GenerateNoise ()
  98.     Dim As Long x, y
  99.  
  100.     For x = 0 To nn*twidth - 1
  101.         For y = 0 To theight - 1
  102.                         zz = rnd
  103.             noise(x + y * twidth) = zz
  104.         Next y
  105.     Next x
  106.  
  107.  
  108. Function SmoothNoise (x, y)
  109.     '//get fractional part of x and y
  110.     Dim fractx, fracty, x1, y1, x2, y2, value
  111.     fractx = x - Int(x)
  112.     fracty = y - Int(y)
  113.  
  114.     '//wrap around
  115.     x1 = (Int(x) + nn*twidth) Mod twidth
  116.     y1 = (Int(y) + theight) Mod theight
  117.  
  118.     '//neighbor values
  119.     x2 = (x1 + nn*twidth - 1) Mod twidth
  120.     y2 = (y1 + theight - 1) Mod theight
  121.  
  122.     '//smooth the noise with bilinear interpolation
  123.     value = 0.0
  124.     value = value + fractx * fracty * noise(x1 + y1 * twidth)
  125.     value = value + fractx * (1 - fracty) * noise(x1 + y2 * twidth)
  126.     value = value + (1 - fractx) * fracty * noise(x2 + y1 * twidth)
  127.     value = value + (1 - fractx) * (1 - fracty) * noise(x2 + y2 * twidth)
  128.  
  129.     SmoothNoise = value
  130.  
  131. Function Turbulence (x, y, size)
  132.     Dim value, initialsize
  133.  
  134.     initialsize = size
  135.     While (size >= 1)
  136.         value = value + SmoothNoise(x / size, y / size) * size
  137.         size = size / 2.0
  138.     Wend
  139.     Turbulence = (128.0 * value / initialsize)
  140.  
  141. '//builds the texture.
  142. Sub buildtexture
  143.     Dim x, y
  144.  
  145.     For x = 0 To nn*twidth - 1
  146.         For y = 0 To theight - 1
  147.             texture(x + y * nn*twidth) = Turbulence(x, y, zoom)
  148.         Next y
  149.     Next x
  150.  
  151. '//draws texture to screen.
  152. Sub drawtexture (dx )
  153.     Dim x, y
  154.         dim as long c, r, g, b
  155.  
  156.     For x = 0 To twidth - 1
  157.         For y = 0 To theight - 1
  158.                         c = pal(texture(((x + dx) + y * nn*twidth)))
  159.                         r = _red(c)
  160.                         g = _green(c)
  161.                         b = _blue(c)
  162.                         c = _rgb(r - 0.2*y, g - 0.2*y, b - 0.2*b)
  163.             PSet (x, y), c'pal(texture(((x + dx) + y * nn*twidth)))
  164.         Next y
  165.     Next x
  166.  

41
Programs / Canonical Logarithm
« on: February 08, 2022, 09:13:32 am »
Code: [Select]
defdbl a-z
dim shared pi as double
pi = 4*atn(1)

sw = 800
sh = 600

screen _newimage(sw, sh, 32)

zoom = 100

a = 0.5
k = 0.09

sx = 2
sy = 1

tx = a*exp(k*16)*cos(16) + sx
ty = a*exp(k*16)*sin(16) + sy

x = a*exp(k*0)*cos(0) + sx - tx
y = a*exp(k*0)*sin(0) + sy - ty

r = sqr(x*x + y*y)
arg = _atan2(y, x)

for tt = r to 0 step -1
xl = tt*cos(arg)
yl = tt*sin(arg)

for yy=0 to sh
for xx=0 to sw
u = (xx - sw/2)/zoom
v = (sh/2 - yy)/zoom

cdiv uu, vv, u - xl, v - yl, u + xl, v + yl
clog uu, vv, uu, vv

mm = sqr(uu*uu + vv*vv)
aa = (pi + _atan2(vv, uu))/(2*pi)
pset (xx, yy), hrgb(aa, mm)
next
next

sleep
next

dim pp(5)
pp(5) = 0
pp(4) = 7
pp(3) = 10
pp(2) = 12
pp(1) = 15
pp(0) = 15.9

for ttt= 0 to 5
tt = pp(ttt)
for yy=0 to sh
for xx=0 to sw
u = (xx - sw/2)/zoom
v = (sh/2 - yy)/zoom

uu = 0
vv = 0
for t=tt to 16 step 0.1
x = a*exp(k*t)*cos(t) + sx - tx
y = a*exp(k*t)*sin(t) + sy - ty

cdiv p, q, 1, 0, x - u, y - v

dx = a*exp(k*t)*(k*cos(t) - sin(t))
dy = a*exp(k*t)*(k*sin(t) + cos(t))

cmul p, q, p, q, dx, dy

uu = uu + 0.1*p
vv = vv + 0.1*q
next

for t=16 - 0.1 to tt step -0.1
x =-a*exp(k*t)*cos(t) - sx + tx
y =-a*exp(k*t)*sin(t) - sy + ty

cdiv p, q, 1, 0, x - u, y - v

dx = a*exp(k*t)*(k*cos(t) - sin(t))
dy = a*exp(k*t)*(k*sin(t) + cos(t))

cmul p, q, p, q, dx, dy

uu = uu + 0.1*p
vv = vv + 0.1*q
next

cmul uu, vv, uu, vv, 0, -1/(2*pi)

mm = sqr(uu*uu + vv*vv)
aa = (pi + _atan2(vv, uu))/(2*pi)
pset (xx, yy), hrgb(aa, mm)
next
next

sleep
next

sleep
system

function hrgb&(h, m)
r =  0.5 - 0.5*sin(2*pi*h - pi/2)
    g = (0.5 + 0.5*sin(2*pi*h*1.5 - pi/2)) * -(h < 0.66)
    b = (0.5 + 0.5*sin(2*pi*h*1.5 + pi/2)) * -(h > 0.33)

    n = 128

    mm = m*10000 mod 500
p = abs((h*n) - int(h*n))

rr = 200*r - 0.15*mm - 35*p
gg = 200*g - 0.15*mm - 35*p
bb = 200*b - 0.15*mm - 35*p

if rr < 0 then rr = 0
if gg < 0 then gg = 0
if bb < 0 then bb = 0

hrgb& = _rgb(rr, gg, bb)
end function

function cosh#(x as double)
    cosh# = 0.5*(exp(x) + exp(-x))
end function

function sinh#(x as double)
    sinh# = 0.5*(exp(x) - exp(-x))
end function

'u + iv = (x + iy)^(a + ib)
sub cexp(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb
   
    lnz = x*x + y*y
   
    if lnz = 0 then
        u = 0
        v = 0
    else
        lnz = 0.5*log(lnz)
        argz = atan2(y, x)
       
        mag = exp(a*lnz - b*argz)
        ang = a*argz + b*lnz
       
        u = mag*cos(ang)
        v = mag*sin(ang)
    end if
end sub

'u + iv = (x + iy)*(a + ib)
sub cmul(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb
    u = x*a - y*b
    v = x*b + y*a
end sub

'u + iv = (x + iy)/(a + ib)
sub cdiv(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb

    d = a*a + b*b
    u = (x*a + y*b)/d
    v = (y*a - x*b)/d
end sub

sub clog(u, v, xx, yy)
x = xx
y = yy

    lnz = x*x + y*y
   
    if lnz = 0 then
        u = 0
        v = 0
    else
u = 0.5*log(lnz)
v = _atan2(y, x)
end if
end sub

42
Programs / Re: 4 Letter Word Invaders Game
« on: February 08, 2022, 03:05:26 am »
Plays OK, slow too much, fast too much (can't read word as it blurs or doubles going down screen). Frankly I'd rather do something else.

That is brutally devastating, bplus.  Perhaps all it needs is a quick mod?

Code: QB64: [Select]
  1. const nn = 1
  2. Const twidth = 800, theight = 600, zoom = 128
  3. Dim Shared noise(nn*twidth * theight) '//the noise array
  4. Dim Shared texture(nn*twidth * theight) '//texture array
  5. Dim Shared pal(256) As _Unsigned Long '//color palette
  6.  
  7. Dim a$(100)
  8. Dim x(100), y(100), letter$(100)
  9. _Title "Letters Invasion B+ mod"
  10. Screen _NewImage(800, 600, 32)
  11.  
  12. MakePalette 255, 155, 255, 10, 100, 180
  13. GenerateNoise
  14. buildtexture
  15.  
  16. vs = _newimage(twidth, theight, 32)
  17. drawtexture 0
  18.  
  19. Color _RGB32(255, 255, 255)
  20. For t = 65 To 90
  21.     r = r + 1
  22.     a$(r) = Chr$(t)
  23.  
  24. start:
  25.  
  26. Line (0, 501)-(800, 501), _RGB32(255, 255, 255)
  27. For skyy = 0 To 500
  28.     col = Int(skyy / 2)
  29.     Line (0, skyy)-(800, skyy), _RGB32(0, 0, col)
  30. Next skyy
  31.  
  32. '_putimage (i , 0)-step(800,600), vs
  33.  
  34. For groundy = 502 To 600
  35.     g = g + 2
  36.     colg = Int(g / 2)
  37.     Line (0, groundy)-(800, groundy), _RGB32(0, colg, 0)
  38. Next groundy
  39. g = 0
  40. Locate 15, 40
  41. Print "Letter Invasion!"
  42. Locate 17, 40
  43. Print "By SierraKen"
  44. Locate 19, 40
  45. Print "Type the letters that fall down"
  46. Locate 20, 40
  47. Print "Before they reach the ground!"
  48. Locate 21, 40
  49. Print "450 points wins the game."
  50. Locate 23, 40
  51. Color _RGB32(255, 0, 0)
  52. Print "TURN ON CAPS LOCK"
  53. Color _RGB32(255, 255, 255)
  54. Locate 26, 40
  55. Print "Good luck!"
  56. Locate 27, 40
  57. Input "Press Enter To Start.", en$
  58. l = 0: ll = 0
  59. tt = 0
  60. score = 0
  61. speed = .1
  62. lives = 5
  63. score$ = Str$(score)
  64. lives$ = Str$(lives)
  65. s$ = "Score: " + score$ + " Lives: " + lives$
  66. amount = 10
  67. timing = 15
  68.  
  69. GoSub makingletters:
  70.  
  71. i = 0
  72. j = -1
  73.         i = i + 5
  74.         if i >= 800 then
  75.                 i = 0
  76.                 j = not j
  77.         end if         
  78.  
  79.         if j then
  80.                 _putimage (i , 0)-step(800,600), vs
  81.                 _putimage (i , 0)-step(-800,600), vs
  82.         else
  83.                 _putimage (i + 800, 0)-step(-800,600), vs
  84.                 _putimage (i - 800 , 0)-step(800,600), vs
  85.  
  86.         end if
  87.     '_Limit 25
  88.  
  89.     'Line (0, 501)-(800, 501), _RGB32(255, 255, 255)
  90.     'For skyy = 0 To 500
  91.     '    col = Int(skyy / 2)
  92.     '    Line (0, skyy)-(800, skyy), _RGB32(0, 0, col)
  93.     'Next skyy
  94.  
  95.  
  96.  
  97.     For groundy = 502 To 600
  98.         g = g + 2
  99.         colg = Int(g / 2)
  100.         Line (0, groundy)-(800, groundy), _RGB32(0, colg, 0)
  101.     Next groundy
  102.     g = 0
  103.     For rl = 1 To l
  104.         If letter$(rl) <> "" Then _PrintString (x(rl), y(rl)), letter$(rl)
  105.     Next rl
  106.  
  107.     Locate 25, 1
  108.     Print "->";
  109.     w$ = InKey$
  110.     If w$ = Chr$(27) Then End
  111.     Locate 25, 3: Print w$
  112.  
  113.     ll = ll + 1
  114.     If ll > timing Then GoSub makingletters:
  115.     For yy = 1 To l
  116.         If letter$(yy) <> "" Then y(yy) = y(yy) + 10
  117.     Next yy
  118.  
  119.     For yyy = 1 To l
  120.         If y(yyy) > 500 Then
  121.             Sound 250, 1
  122.             Sound 150, 1
  123.             lives = lives - 1
  124.             score$ = Str$(score)
  125.             lives$ = Str$(lives)
  126.             s$ = "Score: " + score$ + " Lives: " + lives$
  127.             _Title s$
  128.             If lives = 0 Then
  129.                 Locate 15, 40
  130.                 Print "G A M E   O V E R"
  131.                 Locate 17, 40
  132.                 Input "Again (Y/N)"; ag$
  133.                 If Left$(ag$, 1) = "y" Or Left$(ag$, 1) = "Y" Then GoTo start:
  134.                 End
  135.             End If
  136.             GoSub makingletters:
  137.             GoTo skip1:
  138.         End If
  139.     Next yyy
  140.     skip1:
  141.     If w$ <> "" Then
  142.         For check = 1 To l
  143.             If w$ = letter$(check) Then
  144.                 Sound 850, .5
  145.                 If score < 320 Then speed = speed - .001
  146.                 score = score + 10
  147.                 If score / 50 = Int(score / 50) Then amount = amount + 1
  148.                 score$ = Str$(score)
  149.                 lives$ = Str$(lives)
  150.                 s$ = "Score: " + score$ + " Lives: " + lives$
  151.                 _Title s$
  152.                 If score > 450 Then
  153.                     Locate 15, 40
  154.                     Print "Y O U   W I N ! ! ! ! ! ! ! ! ! !"
  155.                     Locate 17, 40
  156.                     Input "Again (Y/N)"; ag$
  157.                     If Left$(ag$, 1) = "y" Or Left$(ag$, 1) = "Y" Then GoTo start:
  158.                     End
  159.                 End If
  160.                 letter$(check) = ""
  161.                 GoSub makingletters:
  162.                 GoTo skip2:
  163.             End If
  164.         Next check
  165.     End If
  166.     skip2:
  167.  
  168.         _LIMIT 10
  169.     '_Delay speed
  170.     _Display
  171.     Cls
  172.  
  173. makingletters:
  174. w$ = ""
  175. ll = 0
  176. l = l + 1
  177. If l > amount Then l = 1
  178. x(l) = (Rnd * 750) + 5
  179. y(l) = 5
  180. tt = Int(Rnd * 24) + 1
  181. letter$(l) = a$(tt)
  182.  
  183.  
  184. '//interpolation code by rattrapmax6
  185. Sub MakePalette (sr, sg, sb, er, eg, eb) ' (b+) start and end RGB's ? yes
  186.     Dim i, istart(3), iend(3), ishow(3), rend(3), interpol(3)
  187.  
  188.     interpol(0) = 255
  189.     istart(1) = sr
  190.     istart(2) = sg
  191.     istart(3) = sb
  192.     iend(1) = er
  193.     iend(2) = eg
  194.     iend(3) = eb
  195.     interpol(1) = (istart(1) - iend(1)) / interpol(0)
  196.     interpol(2) = (istart(2) - iend(2)) / interpol(0)
  197.     interpol(3) = (istart(3) - iend(3)) / interpol(0)
  198.     rend(1) = istart(1)
  199.     rend(2) = istart(2)
  200.     rend(3) = istart(3)
  201.  
  202.     For i = 0 To 255
  203.         ishow(1) = rend(1)
  204.         ishow(2) = rend(2)
  205.         ishow(3) = rend(3)
  206.  
  207.         pal(i) = _RGB32(ishow(1), ishow(2), ishow(3))
  208.  
  209.         rend(1) = rend(1) - interpol(1)
  210.         rend(2) = rend(2) - interpol(2)
  211.         rend(3) = rend(3) - interpol(3)
  212.     Next i
  213.  
  214. '//generates random noise.
  215. Sub GenerateNoise ()
  216.     Dim As Long x, y
  217.  
  218.     For x = 0 To nn*twidth - 1
  219.         For y = 0 To theight - 1
  220.                         zz = rnd
  221.             noise(x + y * twidth) = zz
  222.         Next y
  223.     Next x
  224.  
  225.  
  226. Function SmoothNoise (x, y)
  227.     '//get fractional part of x and y
  228.     Dim fractx, fracty, x1, y1, x2, y2, value
  229.     fractx = x - Int(x)
  230.     fracty = y - Int(y)
  231.  
  232.     '//wrap around
  233.     x1 = (Int(x) + nn*twidth) Mod twidth
  234.     y1 = (Int(y) + theight) Mod theight
  235.  
  236.     '//neighbor values
  237.     x2 = (x1 + nn*twidth - 1) Mod twidth
  238.     y2 = (y1 + theight - 1) Mod theight
  239.  
  240.     '//smooth the noise with bilinear interpolation
  241.     value = 0.0
  242.     value = value + fractx * fracty * noise(x1 + y1 * twidth)
  243.     value = value + fractx * (1 - fracty) * noise(x1 + y2 * twidth)
  244.     value = value + (1 - fractx) * fracty * noise(x2 + y1 * twidth)
  245.     value = value + (1 - fractx) * (1 - fracty) * noise(x2 + y2 * twidth)
  246.  
  247.     SmoothNoise = value
  248.  
  249. Function Turbulence (x, y, size)
  250.     Dim value, initialsize
  251.  
  252.     initialsize = size
  253.     While (size >= 1)
  254.         value = value + SmoothNoise(x / size, y / size) * size
  255.         size = size / 2.0
  256.     Wend
  257.     Turbulence = (128.0 * value / initialsize)
  258.  
  259. '//builds the texture.
  260. Sub buildtexture
  261.     Dim x, y
  262.  
  263.     For x = 0 To nn*twidth - 1
  264.         For y = 0 To theight - 1
  265.             texture(x + y * nn*twidth) = Turbulence(x, y, zoom)
  266.         Next y
  267.     Next x
  268.  
  269. '//draws texture to screen.
  270. Sub drawtexture (dx )
  271.     Dim x, y
  272.         dim as long c, r, g, b
  273.  
  274.     For x = 0 To twidth - 1
  275.         For y = 0 To theight - 1
  276.                         c = pal(texture(((x + dx) + y * nn*twidth)))
  277.                         r = _red(c)
  278.                         g = _green(c)
  279.                         b = _blue(c)
  280.                         c = _rgb(r - 0.2*y, g - 0.2*y, b - 0.2*b)
  281.             PSet (x, y), c'pal(texture(((x + dx) + y * nn*twidth)))
  282.         Next y
  283.     Next x
  284.  

43
Programs / Re: Program for neat display of long text
« on: February 06, 2022, 10:27:23 pm »
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!

nejsam to co si myslis, ne, nejsam ja tot

44
Prime spiral with zoom in / out and number ID at mouse point:

is this a Golden Spiral?

45
Programs / Re: Program for neat display of long text
« on: February 06, 2022, 09:58:31 am »
With non-monospaced fonts, the routine has to check and build width pixel by pixel as it goes. A "W" might spread and use 64 pixels, an "i" might use 8...  non-monospaced fonts are *much* slower to calculate print widths with, and that's something I wanted to emphasize with my demo.

Is this a one dimensional form of OCR? the difference in aka screen 0 printing

Pages: 1 2 [3] 4 5 ... 29