|
Post by bplus on Sept 21, 2023 18:29:04 GMT
Starting my own thread so the whole board isn't junked up with my stuff. Plasma Laser Canon Pointer QB64 code: 'Option _Explicit '_Title "Plasma Laser Cannon Pointer" ' for QBJS b+ 2023-09-21 ' start mod from Plasma Laser Canon demo prep for GUI 2020-11-11
Screen _NewImage(1200, 600, 32) Randomize Timer Dim Shared As Long ShipLights Dim Shared As _Unsigned Long ShipColor Dim As Long cx, cy, mx, my, mb, sx, sy Dim As Single ma, md, dx, dy cy = _Height / 2: cx = _Width / 2 ShipColor = &HFF3366AA ' _MouseHide '??? not supported and bad idea anyway Do Cls While _MouseInput: Wend mx = _MouseX: my = _MouseY: mb = _MouseButton(1) dx = mx - cx ' ship avoids collision with mouse dy = my - cy ma = _Atan2(dy, dx) md = Sqr(dy * dy + dx * dx) If md < 80 Then md = 80 sx = cx + md * Cos(ma + 3.1415) sy = cy + md * Sin(ma + 3.1415) drawShip sx, sy, ShipColor If mb Then PLC sx, sy, mx, my, 10 ' Fire! ShipColor = _RGB32(Int(Rnd * 256), Int(Rnd * 136) + 120, Int(Rnd * 156) + 100) End If _Display _Limit 60 Loop Until _KeyDown(27)
Sub PLC (baseX, baseY, targetX, targetY, targetR) ' PLC for PlasmaLaserCannon Dim r, g, b, hp, ta, dist, dr, x, y, c, rr r = Rnd ^ 2 * Rnd: g = Rnd ^ 2 * Rnd: b = Rnd ^ 2 * Rnd: hp = _Pi(.5) ' red, green, blue, half pi ta = _Atan2(targetY - baseY, targetX - baseX) ' angle of target to cannon base dist = _Hypot(targetY - baseY, targetX - baseX) ' distance cannon to target dr = targetR / dist For r = 0 To dist Step .25 x = baseX + r * Cos(ta) y = baseY + r * Sin(ta) c = c + .3 Color _RGB32(128 + 127 * Sin(r * c), 128 + 127 * Sin(g * c), 128 + 127 * Sin(b * c)) fcirc x, y, dr * r Next For rr = dr * r To 0 Step -.5 c = c + 1 Color _RGB32(128 + 127 * Sin(r * c), 128 + 127 * Sin(g * c), 128 + 127 * Sin(b * c)) fcirc x, y, rr Next End Sub
Sub drawShip (x, y, colr As _Unsigned Long) 'shipType collisions same as circle x, y radius = 30 ' shared here ShipLights
Dim light As Long, r As Long, g As Long, b As Long r = _Red32(colr): g = _Green32(colr): b = _Blue32(colr) Color _RGB32(r, g - 120, b - 100) fEllipse x, y, 6, 15 Color _RGB32(r, g - 60, b - 50) fEllipse x, y, 18, 11 Color _RGB32(r, g, b) fEllipse x, y, 30, 7 For light = 0 To 5 Color _RGB32(ShipLights * 50, ShipLights * 50, ShipLights * 50) fcirc x - 30 + 11 * light + ShipLights, y, 1 Next ShipLights = ShipLights + 1 If ShipLights > 5 Then ShipLights = 0 End Sub
' these do work in QBJS without mod see le bombe Sub fcirc (CX As Long, CY As Long, R As Long) Dim subRadius As Long, RadiusError As Long Dim X As Long, Y As Long
subRadius = Abs(R) RadiusError = -subRadius X = subRadius Y = 0
If subRadius = 0 Then PSet (CX, CY): Exit Sub
' Draw the middle span here so we don't draw it twice in the main loop, ' which would be a problem with blending turned on. Line (CX - X, CY)-(CX + X, CY), , BF
While X > Y RadiusError = RadiusError + Y * 2 + 1 If RadiusError >= 0 Then If X <> Y + 1 Then Line (CX - Y, CY - X)-(CX + Y, CY - X), , BF Line (CX - Y, CY + X)-(CX + Y, CY + X), , BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If Y = Y + 1 Line (CX - X, CY - Y)-(CX + X, CY - Y), , BF Line (CX - X, CY + Y)-(CX + X, CY + Y), , BF Wend End Sub
Sub fEllipse (CX As Long, CY As Long, xRadius As Long, yRadius As Long) Dim scale As Single, x As Long, y As Long scale = yRadius / xRadius Line (CX, CY - yRadius)-(CX, CY + yRadius), , BF For x = 1 To xRadius y = scale * Sqr(xRadius * xRadius - x * x) Line (CX + x, CY - y)-(CX + x, CY + y), , BF Line (CX - x, CY - y)-(CX - x, CY + y), , BF Next End Sub
In Forum viewer - move mouse around and see where ship goes, click mouse for Laser Canon Pointer: [qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhw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yYWluIGxvb3Asx0x3aGljaCB3b3VsZCBiZSBhIHByb2JsZW3mCR9ibGVuZGluZyB0dXLkBCBvbi7FOExpbmXlAYItIOYApS3EDSvHDSwgLCBCRuYAruYJ3FggPiBZ6QJ/7gEvzA4rIFnkCGjtBThJZs0jPugBJskhxyVYIDw+IOQGRTHSH+8AtFnlAjItIFjoALjKEecAvN89xGfPPcQR0z3rCP7IAeQCEcRJ6gDjxAH6ARUtIFjkARXJLs9T5AJOxH/KT/ABnuQAte0BosUR7wCt0TUr0DXEEcs15Quj7QZg6QTT+QOcePADh3nOEesDs2NhbGXqDLAsIHjLNe0DssYqPclLL8hm7QKq5wD3xyXlANnFEyvJE+sA2+QFg+QItzHkBX/MTsQB5AiwxnQq5QwHxyAgKsgqIC0g5AwQ5wwP7QFcK+QF7uYAiegBXMYRKyB5+wGRzzXIEc817Qfx [/qbjs] This baby has the potential for some sort of fun little shooter game! You may see this later ;-))
|
|
|
Post by bplus on Sept 25, 2023 0:49:37 GMT
Here is that Horse Race proggie from the 25 Horses Problem Thread. qb64.boards.net/thread/199/25-horses-problem I thought it would be a quickie to get working in QBJS, took a little longer: Horse Race QB64 code port: 'Option _Explicit '_Title "Horse Race 3" ' b+ 2023-09-12 ' fix so the the list of horse is shown in order they came in at
' 2023-09-24 ' Finally got this to work what a frustrating afternoon.
Const track = 100 Const nHorses = 10 Type horse col As Single loops As Integer colr As Integer End Type
Screen _NewImage(120 * 8, (nHorses * 3 + 4) * 16, 12) ' 16 colors Randomize Timer
Dim stillRunning, i Dim horses(1 To nHorses) As horse For i = 1 To nHorses 'load color/id number for after sort horses(i).colr = i Next
stillRunning = 1 While stillRunning = 1 stillRunning = 0 ' clear flag For i = 1 To nHorses If horses(i).col <= track Then horses(i).loops = horses(i).loops + 1 stillRunning = 1 'set flag horses(i).col = horses(i).col + Rnd * .25 End If Next Cls Print For i = 1 To nHorses Color i _PrintString (Int(horses(i).col) * 8, (2 * horses(i).colr) * 16), _Trim$(Str$(horses(i).loops)) Print Next Color 15 Locate 1, 1 For i = 1 To nHorses _PrintString (100 * 8, (2 * i - 1) * 16), "|" Print Next _Limit 60 Wend Color 15 _PrintString (48 * 8, 22 * 16), "And the results are in:" QuickSort 1, nHorses, horses() For i = 1 To nHorses Color horses(i).colr _PrintString (57 * 8, (22 + i) * 16), Str$(horses(i).colr) + " - " + Str$(horses(i).loops) Next
Sub QuickSort (start As Long, finish As Long, array() As horse) Dim Hi As Long, Lo As Long, Middle As Single Hi = finish: Lo = start Middle = array(Int((Lo + Hi) / 2)).loops 'find middle of array Do Do While array(Lo).loops < Middle: Lo = Lo + 1: Loop Do While array(Hi).loops > Middle: Hi = Hi - 1: Loop If Lo <= Hi Then Swap array(Lo), array(Hi) Lo = Lo + 1: Hi = Hi - 1 End If Loop Until Lo > Hi If Hi > start Then Call QuickSort(start, Hi, array()) If Lo < finish Then Call QuickSort(Lo, finish, array()) End Sub
And pluggged in QBJS: [qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhwbGljaXQKJ19UaXRsZSAiSG9yc2UgUmFjZSAzIiAnIGIrIDIwMjMtMDktMTIKJyBmaXggc28gdGhlxQRsaXN0IG9mIGjFN2lzIHNob3duIGluIG9yZGVyxCR5IGNhbWXEE2F0CgonyU8yNAonIEZpbmFsbHkgZ290IHRoaXMgdG8gd29yayB3aGF0IGEgZnJ1c3RyYXRpbmcgYWZ0ZXJub29uLgoKQ29uc3QgdHJhY2sgPSAxMDDHEm7lAMBzxRQKVHlwZeYAmgogICAgY29sIEFzIFNpbmdsxhJsb29wc8QUSW50ZWdlcsgncswURW5kIMRKCgpTY3JlZW4gX05ld0ltYWdlKDEyMCAqIDgsICjIeCogMyArIDQpICogMTYsIDEyKSAnIDE2xFVvcnMKUmFuZG9taXplIFRpbWVyCgpEaW0gc3RpbGxSdW5uaW5nLCBpxRTlALZzKDEgVG/oANQp5ACVxRgKRm9yIGnkAOTLHyAnbG9hZMZpL2lkIG51bWJlciBmb3LmATkgc29ydOUA4cdcaSku5QDrPSBpCk5leHQKCuwAicReCldoaWxl7QCgxRfERc8VMCAnIGNsZWFyIGZsYWfFIvQApcUZxAFJ5wIz6ACHIDw95wHOVGhlbskn7gCv5gGvPdESK+cAlMgB8ACxICdzZXTqAJnSWeQAgcxXxBArIFJuZCAqIC4yNck25AILSWbFD+UBMsQJQ2zmANZQcmluxhL9APlD5AGgIGnJEF/FOFN0cuQArChJbnQo7QCH5AJJ5AJgMiAq7wG4xBoxNiksIF9UcmltJChTdHIkyzzlARopKclo6gCf6gC65QCLMeYA30xvY2F0ZSAxLOcBTP0Axe4AtTEw6AMG5ACmaSAtIDHpAJ0ifCL8AINfTGltaXQgNjAKV2VuZArpAJLOYTQ4xmAyxGDGV0FuZOUEgHJlc3VsdHMgYXLkBGI6IgpRdWlja1NvcnTkAMvnALgs6AE7KfUDOusBDe4BY8UZ7gCLNTfoAOsyICsgaekA6O8BfsQ+KSArICIgLSAiICvQH+YBnecDdlN1YiDqALYoc3RhcnTkA+tMb+QED2ZpbmlzaMoQYXJyYXko6gQM5gHi5AQzSGnKJkxvygxNaWRkbGXvBPpI5AEFxlw6xC49IMV4xRzHMT3HbOQClChMbyArIEhpKSAvIDIp6AN4J2ZpbmQgbcYvb2bGMMVDRG/pAfZEbyDmBEfGTkxvyD48x2nnAIDFYjHEDW9w2D1I6QPzPsk95QDKSOUCds89SWbEVTzFHvEEVlN3YXDHVkxvKegBWEhp6gMyxAHtAJrLavQEEsR8IFVudGlsxDI+IEjmA+VJZsQ0PuYBYOUAiCBDYWxs6gHz5gHyLCBIaekB3uYAhecAwOgCA9Q7TG/oAiLLPOQAlFN1Yg==[/qbjs] OK now in this forum viewer you will have to scroll down to see the results of all 10 Horses (color coded). I don't really like scrolling down images because I am old and hate change from QB standard screens but I suppose it is an advantage than trying to design something that works: #1 In QB64 first and foremost in my book #2 In QBJS of course! #3 In a forum qbjs code box too! Yikes!
|
|
|
Post by bplus on Sept 25, 2023 1:32:24 GMT
Oh hey this is working now as I originally coded in QB64: 15 Squares Puzzle QB64 code port: _Title "15 Squares Puzzle" 'b+ mod for QBJS 2022-02-19
' 2023-09-24 This is working from my QB64 code
Dim Shared As Integer board(4, 4) Dim Shared As Integer r0, c0, d Dim As Integer r, c, i, solved Dim As String b, k For r = 1 To 4 For c = 1 To 4 board(c, r) = c + (r - 1) * 4 Next Next board(4, 4) = 0 c0 = 4 r0 = 4 Cls For i = 0 To 50 * 4 * 4 d = Val(Mid$("0358", Int(Rnd * 4) + 1, 1)) handle Next While 1 Locate 1, 1 b = "" solved = 1 For r = 1 To 4 For c = 1 To 4 If board(c, r) Then If board(c, r) <> c + (r - 1) * 4 Then solved = 0 End If b = b + Right$(" " + Str$(board(c, r)), 3) + " " Else b = b + " " End If Next Print b b = "" Next Print If solved Then Locate 4 + 2, 2 Print "Solved!" _Delay 5 'End End If k = InKey$ If Len(k) = 2 Then d = (Asc(Right$(k, 1)) - 72) handle End If _Limit 30 Wend
Sub handle Select Case d Case 3 If c0 < 4 Then board(c0, r0) = board(c0 + 1, r0) board(c0 + 1, r0) = 0 c0 = c0 + 1 End If Case 5 If c0 > 1 Then board(c0, r0) = board(c0 - 1, r0) board(c0 - 1, r0) = 0 c0 = c0 - 1 End If Case 0 If r0 < 4 Then board(c0, r0) = board(c0, r0 + 1) board(c0, r0 + 1) = 0 r0 = r0 + 1 End If Case 8 If r0 > 1 Then board(c0, r0) = board(c0, r0 - 1) board(c0, r0 - 1) = 0 r0 = r0 - 1 End If End Select End Sub
Use up/down left/right arrow keys to move number blocks into space: [qbjs]https://qbjs.org/?code=RGltIFNoYXJlZCBBcyBJbnRlZ2VyIGJvYXJkKDQsIDQpCtYicjAsIGMwLCBkxSDMGSwgYywgaSwgc29sdmXJH1N0cmluZyBiLCBrCkZvciByID0gMSBUbyA0CiAgICDEE2POE8QB5gCIYywgcikgPSBjICsgKHIgLSAxKSAqxyZOZXh0CsUF6wC0ID0gMApjMCA9IDQKcsYHQ2xzxXhpxBzEZTUwxETJSGQgPSBWYWwoTWlkJCgiMDM1OCIs5ADUKFJuZMQlKSArIDEsIDEpKcUvaGFuZGxlxnlXaGlsZSAxxRhMb2NhdGXFKsUQYiA9ICIixQvmARDkAOTpAPLvAQX7AQnEAUlm7QEQVGhlbs0g0yQ8PvABNdY37QCgMNEfRW5kIElm0RfkAN1iICsgUmlnaHQkKCIgICAiICvkAeskKOsAhiksIDPkAT8iIOYBCclWbHNl2VTETdAw7gCG5QF8yA1QcmludCBiyRDrAXjJKMUkxQpJZugA7u0BDucBvTQgKyAyLCAyz10iU8UzIeoAlV9EZWxheSA1yREnRW5kxQ3rAKtrID0gSW5LZXkkyHtMZW4oa+QCpDLOf+QBfChBc2Mo5wFQa+UCbyAtIDcy5gJ1xAHnAnnPZV9MaW1pdCAzMApXZW5kCgpTdWLMKlNlbGVjdCBDYXNlIOYAocQBxQ8z8AJjYzAgPPgCJ+cB1TAsIHIw5ADByBDmAxxyMOoAp9AyySL1AmDlA6vGJfwB8uUAseoBbsQB5gCxPuQDL/8Ase4AsS3/ALHKIv0AsS3/ALHkALHOPklmIHL/AWL0ALHEEOQBH/oAscki9QCx5QUGxiH/ALFlIDjNIuYAsf8BYvcAseQEdd0yxSL9ALH7AWLEC+YC2grFC3Vi[/qbjs] Honestly this one takes practice to get use to using arrow keys instead of mouse to move "blocks" I will try to get my GUI mouser version going in QBJS because it plays way more natural! I liked this for brevity of code but obviously we paid a price here
|
|
|
Post by bplus on Sept 25, 2023 18:28:43 GMT
Just fixing up my own collection of QBJS work and found this beauty! But needed dbox help to get it working again. Cheese + Sphere = Moon Qb64 and QBJS: 'Option _Explicit '_Title "Cheese + Sphere = Moon" 'b+ 2022-05-20
' 2023-09-25 testing code in qBJS not working because ' circle? no fixed added Plasma Snake fix for circles ' Point needs integer arguments, thanks dbox!
$If WEB Then import G2D From "lib/graphics/2d.bas" $End If
Randomize Timer Const wW = 1280, wH = 720 Screen _NewImage(wW, wH, 32) '_ScreenMove 80, 0 '_MouseHide Dim As Long stars, i stars = _LoadImage("stars.png") Dim map(1 To 2) As Long For i = 1 To 2 map(i) = growCheese _PutImage , map(i), 0 Next Dim As Long xoff, x, y, rr Do While _KeyDown(27) = 0 Cls For i = 1 To 2 Select Case i Case 1: x = 300: y = 175: rr = 120 Case 2: x = 900: y = 500: rr = 350 Case 3: x = 1175: y = 525: rr = 90 Case 4: x = 300: y = 540: rr = 151 End Select xoff = (_Width(map(i)) + xoff - _Height(map(i)) / 360) Mod _Width(map(i)) projectImagetoSphere map(i), x, y, rr, xoff Next _Display _Limit 60 Loop
Sub projectImagetoSphere (image, x0, y0, sr, xo) Dim pc As _Unsigned Long Dim r, iW, IH, y, x Dim scale, x1, tv, tu r = _Height(image) / 2 iW = _Width(image) - 20 IH = _Height(image) scale = sr / r For y = -r To r x1 = Sqr(r * r - y * y) tv = (_Asin(y / r) + 1.5) / 3 For x = -x1 + 1 To x1 tu = (_Asin(x / x1) + 1.5) / 6 _Source image pc = Point(Int((xo + tu * iW) Mod iW), Int(tv * IH)) _Dest 0 PSet (x * scale + x0, y * scale + y0), pc Next x Next y End Sub
Function growCheese () 'make this more self contained than first version, all hole stuff just in here Dim As Long curr, map, nHoles, maxHoleLife, maxHoleRadius, tfStart, i, r, g, b, layr, radius
curr = _Dest map = _NewImage(wW, wH, 32) _Dest map nHoles = Rnd * 200 + 50: maxHoleLife = 10: maxHoleRadius = Rnd * 10 + 7: tfStart = 1 Dim hx(nHoles), hy(nHoles), hLife(nHoles) For i = 1 To nHoles hx(i) = wW * Rnd hy(i) = wH * Rnd If tfStart Then hLife(i) = Int(Rnd * maxHoleLife) Else hLife(i) = 1 Next r = Rnd * 155 + 100: g = Rnd * 255: b = Int(Rnd * 2) * (Rnd * 155 + 100) tfStart = 0 For layr = 1 To 30 Line (0, 0)-(wW, wH), _RGBA32(r, g, b, 50), BF 'layer of cheese For i = 1 To nHoles 'holes in layer If hLife(i) + 1 > maxHoleLife Then hx(i) = wW * Rnd hy(i) = wH * Rnd If tfStart Then hLife(i) = Int(Rnd * maxHoleLife) Else hLife(i) = 1 Else hLife(i) = hLife(i) + 1 End If hx(i) = hx(i) + Rnd * 2 - 1 hy(i) = hy(i) + Rnd * 2 - 1 If hLife(i) < maxHoleRadius Then radius = hLife(i) ElseIf maxHoleLife - hLife(i) < maxHoleRadius Then radius = maxHoleLife - hLife(i) Else radius = maxHoleRadius End If FCirc hx(i), hy(i), radius, _RGBA32(0, 0, 0, 80) Next Next _Dest curr growCheese = map End Function
' modified for QBJS AND QB64 Sub FCirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
' put this at top of QB64 to QBJS code '$If WEB Then ' import G2D From "lib/graphics/2d.bas" '$End If
$If WEB Then G2D.FillCircle CX, CY, R, C $Else Dim Radius As Long, RadiusError As Long Dim X As Long, Y As Long Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0 If Radius = 0 Then PSet (CX, CY), C: Exit Sub Line (CX - X, CY)-(CX + X, CY), C, BF While X > Y RadiusError = RadiusError + Y * 2 + 1 If RadiusError >= 0 Then If X <> Y + 1 Then Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If Y = Y + 1 Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF Wend $End If End Sub
In forum viewer, esc stops spinning moons [qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhwbGljaXQKJ19UaXRsZSAiQ2hlZXNlICsgU3BoZXJlID0gTW9vbiIgJ2IrIDIwMjItMDUtMjAKCifEDjMtMDktMjUgdGVzdGluZyBjb2RlIGluIHFCSlMgbm90IHdvcmvEGWJlY2F1c2UKJyBjaXJjbGU/IG5vIGZpeGVkIGFkZGVkIFBsYXNtYSBTbmFrZcQZIGZvcscscwonIFBvaW50IG5lZWRzIGludGVnZXIgYXJndW1lbnRzLCB0aGFua3MgZGJveCEKCiRJZiBXRUIgVGhlbgogxwFpbX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g86IFjkBWLHDFnpBTDEAUlmykUw5gQv5ggi5gDLKSwgQzogRXhpdOUH8cg25gVPQ1ggLSDGJy3EDSvHDSwgQ+QFRsku5gw6WCA+IFnJFOoAvugArcwOKyBZ5QPu8ARR6QCuxic+6AC09AUDWCA8PiBZxEPWI+8AyFnlApYtIFjoAMzKEfAA0N1CK9BCxBHYQvMDyMQB5AGvxFLuAP3EAfoBMy0gWOQBM/8EJ+UB/uUBFc0W8AHQ5ADO7QHUxRH0AMbROivQOsQR0DpXZecGt+gDZ+gKUg==[/qbjs]
|
|
|
Post by bplus on Sept 25, 2023 19:49:07 GMT
I found this in reviewing my posts at Friends Of Basic: Spinner QB64 and QBJS: 'Option _Explicit '_Title "Spinner" 'b+ 2021-06-18
' 2023-09-25 convert to QBJS
Dim As Long b, r, i Dim a Screen _NewImage(500, 500, 32) Const rad = _Pi / 180 While 1 Cls b = b + 5 For r = 20 To 200 Step 20 ' tsh73 suggested fix for inner most a = b * r / 20 For i = r - 15 To r arc 250, 250, i, a, 180 Next Next _Display _Limit 5 ' slowed down for QBJS Wend
Sub arc (xCenter, yCenter, arcRadius, dAStart, dAMeasure) 'notes: 'you may want to adjust size and color for line drawing 'using angle measures in degrees to match Just Basic ways with pie and piefilled 'this sub assumes drawing in a CW direction if dAMeasure positive
'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
'dAStart is degrees to start Angle, due East is 0 degrees
'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
Dim rAngleStart, rAngleEnd, Stepper, lastX, lastY, rAngle, nextX, nextY rAngleStart = rad * dAStart rAngleEnd = rad * dAMeasure + rAngleStart Stepper = rad / (.1 * arcRadius) 'fixed lastX = xCenter + arcRadius * Cos(rAngleStart) lastY = yCenter + arcRadius * Sin(rAngleStart) For rAngle = rAngleStart + Stepper To rAngleEnd Step Stepper nextX = xCenter + arcRadius * Cos(rAngle) nextY = yCenter + arcRadius * Sin(rAngle) Line (lastX, lastY)-(nextX, nextY) 'int speeds things up lastX = n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ux37HLC8gKC4xICrqApopICdmaXjnAfDlAKEgPSDnAsogK8ooICogQ29zKMte5gLAxDNZID3oAvTPM1NpbtIz5QQUxRXkAJXKHiAr6QCt5APK6QDmxBXIGukDu+UBNv8Aq8RBxnPIMv8Aqs8yTOQDZSjsAbYpLSjsAa8pICdpbnQgc3BlZWRzIHRoaW5ncyB1cMlB6AFQxTQ6xkPHD+YB6+UEeOUA5HViCg==[/qbjs] Yep! dbox not the best code to show in QBJS, not only slower than QB64 but notice the beautiful cross pattern shadow! ;-)) I like it!
|
|
dbox
Junior Member
Posts: 89
|
Post by dbox on Sept 25, 2023 23:32:00 GMT
Just for fun here's a version of Spinner that uses LineWidth to reduce the total lines of code needed:
[qbjs]https://qbjs.org/?code=SW1wb3J0IEcyRCBGcm9tICJsaWIvZ3JhcGhpY3MvMmQuYmFzIgpHMkQuTGluZVdpZHRoIDE2CidfVGl0bGUgIlNwaW5uZXIiICdiKyAyMDIxLTA2LTE4CifEDTMtMDktMjUgY29udmVydCB0byBRQkpTCgpEaW0gQXMgTG9uZyBiLCByLCBpLCByYcUYYQpTY3JlZW4gX05ld0ltYWdlKDUwMCwgxQUzMikKQ29uc3QgcmFkID0gX1BpIC8gMTgwCldoaWxlIDEKICAgIENsc8UIYiA9IGIgKyA1xQ5Gb3IgciA9IDIwIFRvIDIwMCBTdGVwxA8nIHRzaDczIHN1Z2dlc3RlZCBmaXggZm9yIOUA3SBtb3N0xUPEAWHFVSogciAvIDIwyRdyxBjkAJUqIGHJFUNpcmNsZSAoMjUwLCAyNTAp5QDsMTXkAO3EBCszLjE0xS5OZXjGY19EaXNwbGF5xg1MaW1pdCA25ACjc2xvd2VkIGRvd27lAJvkAUogLSBub3QgYW55bW9yZQpXZW5kCg==[/qbjs]
|
|
|
Post by bplus on Sept 26, 2023 0:40:17 GMT
Well I am trying to have a set of proggies that work both in QB64 and QBJS without change. It is interesting to see the arcs with square edges. Let's see if I can rework spinner for both QB64 and QBJS. Currently my QBJS version sucks speed wise plus odd pset artifacts in QBJS a slight shaded cross interference pattern which might explain why dbox interrupted my monologue ;-)) Man! you get so use to doing monologues at forums of low activity that you start planning on things but then you get people heckling you with better ideas. Sheez what is this a forum or something? LOL My pet peeve about using QB's circle keyword to do arcs. It sucks because it doesn't follow Trig functions, but few people can follow what I say because few people want to deal with Trig functions. This is BASIC for god's sake we don't do trig functions unless we absolutely have to because there is no other way! Oh god don't make me do math! LOL I actually did Spinner to show off my Arc function and then dbox comes along and erases it. True the spinner program really doesn't pick up the difference between doing Arcs with Circle and my Arcs subroutine because it's all symmetric, so there's that. WTH is bplus talking about? Draw one arc say from 90 degrees to 90 + 45 = 135 degrees with my Arc sub, it would start at pi/2 which is due South in Basic Trig Sin and Cos. And it would go to Pi(3/4) which is due SW or 7:30 on anyone's wrist watch from the 60's. Now WTH does circle method do? _Title "bplus pet peeve against circle arcs" ' b+ 2023-09-25 Screen _NewImage(680, 480, 12) Print " A Tale of Two Arcs: that are drawn from Pi/2 to Pi*3/4" Circle (340, 250), 200, 8 Color 14, 0 Print " Here the Arc in question drawn with Circle method." Circle (340, 250), 200, 14, _Pi(1 / 2), _Pi(3 / 4) Color 9, 0 Locate 15, 1 Print " Here is the Arc in question plotted out using Trig Functions:" For angle = _Pi(1 / 2) To _Pi(3 / 4) Step _Pi(1 / 180) Circle (340 + 200 * Cos(angle), 250 + 200 * Sin(angle)), 2, 9 Next Color 15 Sleep
There is a bit of a difference! If you are like me use to plotting allot with Sin and Cos, just view my history of proggies!, then you might understand why the Circle Method of drawing Arcs is inconsistent with the Trig Functions and how they get plotted (ie crazy!).
|
|
dbox
Junior Member
Posts: 89
|
Post by dbox on Sept 26, 2023 14:25:42 GMT
Let's see if I can rework spinner for both QB64 and QBJS. Currently my QBJS version sucks speed wise plus odd pset artifacts in QBJS a slight shaded cross interference pattern which might explain why dbox interrupted my monologue ;-)) Man! you get so use to doing monologues at forums of low activity that you start planning on things but then you get people heckling you with better ideas. Sheez what is this a forum or something? LOL Ha! Sorry bplus , but it's your own fault for interrupting the peaceful serenity of inactivity with such interesting posts! At the risk of further interruptions to this lovely monologue... I did see that a PSet version is way more efficient in your original arc code but it doesn't have the benefit of the anti-aliasing that QBJS uses with the Line and Circle Methods: [qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhwbGljaXQKJ19UaXRsZSAiU3Bpbm5lciIgJ2IrIDIwMjEtMDYtMTgKCifEDjMtMDktMjUgY29udmVydCB0byBRQkpTCgpEaW0gQXMgTG9uZyBiLCByLCBpxRRhClNjcmVlbiBfTmV3SW1hZ2UoNTAwLCDFBTMyKQpDb25zdCByYWQgPSBfUGkgLyAxODAKV2hpbGUgMQogICAgQ2xzxQhiID0gYiArIDXFDkZvciByID0gMjAgVG8gMjAwIFN0ZXDEDycgdHNoNzMgc3VnZ2VzdGVkIGZpeCBmb3Ig5QDaIG1vc3TFQ8QBYcVVKiByIC8gMjDJF8ReaSA9IHIgLSAxNcRicskcxTdyYyAyNTAsxgVpLCBhLOUAuMggTmV4xmTJCV9EaXNwbGF5xg1MaW1pdCA25ACtc2xvd2VkIGRvd27lAKXkAVAgLSBub3QgYW55bW9yZQpXZW5kCgpTdWLFeCh4Q2VudGVyLCB5yAlhcmNSYWRpdXMsIGRBU3RhcnTECU1lYXN1cmUpxXMnbm90ZXM6xgx5b3UgbWF5IHdhbuUBxGFkanVzdCBzaXplIGFuZCBjb2xvcuUAjmxpbmUgZHJhd2luZ8Y8dXNpbmcgYW5nbGUgbcZicyBpbiBkZWdyZWVzxE9tYXRjaCBKxFNCYXNpYyB3YXlzIHdpdGggcGnGYnBpZWZpbGxlZMZVdGhpcyBz5ADhc3N1bWVzyHPEWWEgQ1cgZGlyZWPlArRpZuoA2yBwb3NpdGl2ZQrGR+QAsst35gClMOkAm2lzIGR1ZSBFYXPkAVxkxyBpbmNyZWFzZXMgY2xvY2t3aXNlIHRvd2FyZHMgU291dGjHXecBWsVGx1F0byBzxRRBxEosyl5pc8p3yT/oALXLQWFkZGVkIChDyHkpxFNkQcZV5ADOZW5kIG9m5AHhxkfkA1RyxW7nAefGDUVuZCzlAwFw5AIPbGFzdFjGB1nIIiwgbmV4xBbEB1nFTMtI5ALrYWQgKugCP8sgRW7kA5vIHugAxCvMPsUux37HLC8gKC4xICrqApopICdmaXjnAfDlAKEgPSDnAsogK8ooICogQ29zKMte5gLAxDNZID3oAvTPM1NpbtIz5QQjxRXkAJXKHiAr6QCt5APZ6QDmxBXIGukDyuUBNv8Aq8RBxnPIMv8Aqs8yJ0zkA2Yo7AG3KS0o7AGwKSAnaW50IHNwZWVkcyB0aGluZ3MgdXDJQlBTZXTPQckc6AFtxVA6xh7HD+YCCOUEpOUBAXViCg==[/qbjs] My pet peeve about using QB's circle keyword to do arcs. It sucks because it doesn't follow Trig functions, but few people can follow what I say because few people want to deal with Trig functions. This is BASIC for god's sake we don't do trig functions unless we absolutely have to because there is no other way! Oh god don't make me do math! LOL I seem to remember a complaint Bill/Sprezzo/StxAxtic had about the trig functions in QB/QB64 (before he up and left the internet), that they were inverted somehow.
|
|
|
Post by bplus on Sept 26, 2023 15:12:50 GMT
OK Bill's first issue might be better understood that Basic's Y axis does not increase going up screen like it does in all Math and Physics.
But as x increase from 0 to 90 and beyond the plot of Trig functions sin and cos do go clock-wise consistent to a proper reflection of y axis going down screen as it increases. So the plots go counter-clock if the y axis goes up and clockwise reflection when flip y axis.
Bill reversed his plotting by using special conversion functions of x, y... but he could'a, should'a used Window to reset the direction of axis. And then the battle would be carried to the Circle command doing Arcs.
Bill also trying to maintain the Right hand Rule for 3rd Dimension and pointing of Z axis positive side.
It really gets confusing when Circle's arcs go in the inconsistent opposite direction to the trig functions. To Bill they probably looked like. "Good at least that's right ie (no need to run x, y's through conversion functions)".
i don't know what was the thinking or lack of 1. leaving out fill circle 2. not doing arcs consistently with Trig function plotting
Possibly it was an attempt to keep new versions compatible with old and another QWERTY inefficiency carried into the future.
|
|
|
Post by bplus on Sept 26, 2023 18:04:44 GMT
Oh look what I found today! Tiny Mandelbrot QB64 code: 'Option _Explicit _Title "Tiny Mandelbrot" 'b+ 2021-07-5 Dim y, x, m, r, k, j, l Screen _NewImage(100, 80, 12) For y = -35 To 35 For x = -5 To 69 m = 0: r = 0 For k = 0 To 111 j = r ^ 2 - m ^ 2 - 2 + x / 25 m = 2 * r * m + y / 25 r = j l = (k + 15) Mod 16 If j ^ 2 + m ^ 2 > 11 Then k = 112 Next PSet (x + 18, y + 40), l Next Next Sleep
[qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhwbGljaXQKX1RpdGxlICJUaW55IE1hbmRlbGJyb3QiICdiKyAyMDIxLTA3LTUKRGltIHksIHgsIG0sIHIsIGssIGosIGwKU2NyZWVuIF9OZXdJbWFnZSgxMDAsIDgwLCAxMikKRm9yIHkgPSAtMzUgVG8gMzUKICAgIMQWeMQWxRU2OcUVxAFtID0gMDogcsQHyRXELmvEEsQtMTExyRnEAWogPSByIF4gMiAtIG3HCDIgKyB4IC8gMsZuzF0yICogciAqIG0gKyB50iPEeWrNEmwgPSAoayArIDE1KSBtb2QgMTbNIElmIGrFdyvHfz4gMTEgVGhlbuUAtDExMskvTmV4dMkNUFNldCAoeMRZOCwgeSArIDQwKeQBUMkqxAU=[/qbjs]
|
|
|
Post by bplus on Sept 27, 2023 18:51:53 GMT
New and Improved Spinner 2 QB64 'Option _Explicit _Title "Spinner 2" 'b+ 2021-06-18
' 2023-09-25 convert to QBJS ' 2023-09-27 use FArc for Fat Arcs!
$If WEB Then import G2D From "lib/graphics/2d.bas" $End If
Dim As Long b, r Dim a Dim K As _Unsigned Long Screen _NewImage(500, 500, 32)
While 1 Cls b = b + 1 For r = 10 To 200 Step 10 ' tsh73 suggested fix for inner most a = _D2R(b * r / 20) If Int(r / 10) Mod 2 Then K = &HFF009900 Else K = &HFF0000FF FArc 250, 250, r, 3, a, a + _Pi, K Next _Display _Limit 20 ' slowed down for QBJS Wend
'2023-02-04 Fill Arc draw an arc with thickness, tested in Profile Pong 3-0 ' this sub needs sub FCirc(CX As Long, CY As Long, R As Long, C As _Unsigned Long) for dots Sub FArc (x, y, r, thickness, RadianStart, RadianStop, c As _Unsigned Long) Dim al, a 'x, y origin of arc, r = radius, thickness is radius of dots, c = color 'RadianStart is first angle clockwise from due East = 0 in Radians ' arc will start drawing there and clockwise until RadianStop angle reached
If RadianStop < RadianStart Then FArc x, y, r, thickness, RadianStart, _Pi(2), c FArc x, y, r, 0, thickness, RadianStop, c Else al = _Pi * r * r * (RadianStop - RadianStart) / _Pi(2) For a = RadianStart To RadianStop Step 1 / r FCirc x + r * Cos(a), y + r * Sin(a), thickness, c Next End If End Sub
' modified for QBJS AND QB64 Sub FCirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
' put this at top of QB64 to QBJS code '$If WEB Then ' import G2D From "lib/graphics/2d.bas" '$End If
$If WEB Then G2D.FillCircle CX, CY, R, C $Else Dim Radius As Long, RadiusError As Long Dim X As Long, Y As Long Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0 If Radius = 0 Then PSet (CX, CY), C: Exit Sub Line (CX - X, CY)-(CX + X, CY), C, BF While X > Y RadiusError = RadiusError + Y * 2 + 1 If RadiusError >= 0 Then If X <> Y + 1 Then Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If Y = Y + 1 Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF Wend $End If End Sub
[qbjs]https://qbjs.org/?code=J09wdGlvbiBfRXhwbGljaXQKX1RpdGxlICJTcGlubmVyIDIiICdiKyAyMDIxLTA2LTE4CgonxA4zLTA5LTI1IGNvbnZlcnQgdG8gUUJKU8wdNyB1c2UgRkFyYyBmb3IgRmF0IEFyY3MhCgokSWYgV0VCIFRoZW4KIMcBaW1wb3J0IEcyRCBGcm9tICJsaWIvZ3JhcGhpY3MvMmQuYmFzIgokRW5kIElmCgpEaW0gQXMgTG9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WAn8QWlJ+gAxP8FqucFqsZF6AWvxQ/RU8gBRzJELuQER+QA42xlIENY5ADcLCBSLCBDxjntAffkA4XkAaV1c+sA/8UQRXJyb3LIFc0w6wE26QE1ySHHTT0gQWJzKFIpOs1OPSAtxg86IFjnAi3EDFnkA37JQucDJsVFMOYFslBTZXTkAa/kAMspLCBDOiBFeGl05QHtyDZMaW5lxCMgLSDGJy3EDSvHDSwgQywgQuoF2OYGo1ggPiBZyRTqAL7oAK3MDisgWSAqIDLpBsPxAK7GJz7oALTNJccpWCA8PiBZxEPWI8QB6wDIWeUCli0gWOgAzMoR8ADQ3UIr0ELEEdhC5wJl0BfkAa/EUu4A/cQB+gEzLSBY5AEzzTLTX+QB/uUBFc0W8AHQ5ADO7QHUxRH0AMbROivQOsQR0DrlB4zECegDZ+gETg==[/qbjs]
|
|
|
Post by bplus on Oct 19, 2023 17:41:57 GMT
Plasma PLUS Vonoroi Press any key to change setup, escape to quit (or qbjs box on left top) [qbjs]https://qbjs.org/?code=JElmIFdFQiBUaGVuCiDHAUltcG9ydCBHMkQgRnJvbSAibGliL2dyYXBoaWNzLzJkLmJhcyIKJEVuZCBJZgoKJ09wdGlvbiBfRXhwbGljaXQKX1RpdGxlICJSZWFsIFBsYXNtYSBhbmQgVm9yb25vaSwgcHJlc3Mga2V5IGZvciBuZXcgc2NoZW1lIiAnMjAyMy0xMC0xOSAgYisgb3ZlcmhhdWwgb2YKJ2Zha2UtdsZFLXDFWOQAjCBEYXYsIE9DVC/EPQoKU2NyZWVuIF9OZXdJbWFnZSg2MDAsIMUFMzIpCidfxiFNb3ZlIDI5MCwgNDAKUmFuZG9taXplIFRpbWVyCgoKJyBjYXAgYWxsIHNoYXJlZCB2YXJpYWJsZXMKRGltIFPGFUFzIExvbmcgQ1gsIENZLCBSYWRpdXMKJyBtb2RpZmllZCBieSBTZXR1cM82U2luZ2xlIFJkLCBHbiwgQmwgJyDmANMgY29sb3Jz5AEaUkdC1G1OUCAnIOcBCCBwdCBjb3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IkKDI3KQrLHV9LZXlkb3duxRgKU3Vi5gCDICcg5gCk5gaExWMn5QW46AQL5wYn5wRWxCBS5AIXUm7kAetSbmQ6IEduzhBCbMwQ5wGmxlToBXLpBuvFX+UFNMUnTlDlAY50KMY/MTDkAt0zICcgOcUIbWF4xCZudW1iZXIgb2blBT/nBb/FQOYDQD3pAfLmBehhxRZiZXR35AYhxCjqBoE9IDIgKstzMinlBDAn5QaN7gaKdGhlIG90aGVyIMQSCuQBolN1YuQGmXRo5AUmdWLmAM5pcmNsZSBmaeQH2m8gY2FuIHVzZSBjb2Rl5AU0UUJKUyB3b+QG+OUBh+YC7ChDWOgF8OQH6MoMUssX8gWy5gM39QllxAFHMkQuRmlsbMRjbGXqCEQsIEPGOeQCpsky5AYW5wSSyn/FEEVycm9yyBXNMOsAtukAtckhx009IEFicyhSKegF6cZOPSAtxg86IOQGIsgM5AYd6gMSSWbKRTDmBLpQU2V05AEv5ADLKSwgQzogRXhpdOUBisg2TOQGuOQBUi0gxictxA0rxw0sIEMsIEJGyS5XaGlsZSBYID4gWckU6gC+6ACtzA4rIFnkAirkBMjNMukArsYnPugAtPQFj1ggPD4g5AYEMdYjxAHrAMhZ5QIWLSBY6ADMyhHwANDdQivQQsQR2ELrBITMAeQBr8RS7gD9xAH6ATMtIFjkATPNMtNf5AH+5QEVzRbwAdDkAM7tAdTFEfQAxtE6K9A6xBHQOldl5wXK6AyD6APr[/qbjs][code]
Thanks again to dbox for getting this to work in QBJS now for some more Help notes ;-))
|
|
|
Post by bplus on Oct 19, 2023 21:39:17 GMT
Another Plasma Plus Vonoroi! [qbjs]https://qbjs.org/?code=JyRJZiBXRUIgVGhlbgonIMcBSW1wb3J0IEcyRCBGcm9tICJsaWIvZ3JhcGhpY3MvMmQuYmFzIgonJEVuZCBJZgpTY3JlZW4gX05ld0ltYWdlKDQwMCwgM8UFMikKRGltIFNoYXJlZCBBcyBTaW5nbGUgUmQsIEduLCBCbM8gTG9uZyBOUApSZdMYUHgoMSBU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RbEQWnEGsRBTlDNHMU2aXN0ID0gX0h5cG90KHggLeQBJWkpLCB5xAt5KGkpKdE0SWbGNzwgZOUB+sV7xBLNKk5leM4RxSYgKyDOFmPEflJHQjMyKDEyNyArIMQGKuQBVihSZCAqIGQpLMUTzBlHbtcZQmzFGe4As0xpbmUgKOQB1ykt5AE4KDQsIDQpLCBjLCBCRskq6QCvyQnkARh0xF/FDmskID0gSW5LZXkkxRBJZiBMZW4oayQp5gL+yEjlAec6xT3mAYrnAubEC19EaXNwbGF5xg1MaW1pdCAzMCAnaGEhCkxvb3AgVW50aWwgX0tleURvd24oMjcpCgpTdWLGVcU27gKDxBJS5AFYUm7kASxSbmQ6IEduzhBCbMwQxTNOUOUAzHQoxhc1MCkgKyAzxk7lAzj/AzHmAWD4AlvlAkHNYeYCueoBluUCWM4i5gMDxiPlAYLkATdTdWIK[/qbjs] That is an awesome program. Of course, I had to get that ported to BAM: basicanywheremachine-news.blogspot.com/2023/10/plasma-plus-vonoroi-qbjs-program-by-b.html
|
|
|
Post by bplus on Oct 20, 2023 13:29:07 GMT
Thanks Charlie, I live for making people having to make their own versions! You are welcome!
|
|