(Disclaimer: this is more a thought experiment or topic of discussion than a hard proposal!)
One thing I have wanted to see for a while is an IDE that lets you enter your program in the language / syntax of your choice, stores the program, variable names, and comments, in some sort of universal format or intermediate language, and can "render" the source code in a different language or with different variable naming conventions, depending on the user's preference. Maybe there's a dropdown you use to select the language (e.g. QB64, Python, JavaScript, etc.) and as soon as you do, the editor immediately translates or renders the source code into whatever you choose.
I know that this isn't necessarily as simple as it sounds where languages do not support the same features or paradigms - e.g. QB64 is statically typed and Python dynamically typed, QB is strictly procedural whereas Python can be OO or functional - but if a program sticks to the lowest common denominator of functions, or the IDE stores the maximum detail (e.g. explicit type declarations for QB which is stored under the hood, but ignored when using dynamically typed languages like Python & JavaScript) then perhaps it can work?
Or we could take the simple route and just support the features all languages have in common (e.g. strictly procedural) so people who are more familiar
with C/JavaScript syntax can use that, people who like Python can use that, and us BASIC lovers can do that.
Probably the biggest disconnect would be the static vs dynamic typing, so maybe the flavor of Python & JavaScript would be strongly typed (that is, instead of JavaScript we use TypeScript as the option, and is there a strongly typed compiled variant of Python? There would be now! LoL)
Since QB64 uses a source-to-source interrim compiler to first compile to C and then compiles to machine code, perhaps that can be leveraged to multi-language support. Isn't Cython a Python to C compiler?
Anyway, I just thought I would float the idea of a smart IDE that lets people work in whatever syntax they prefer. This would potentially increase the usefulness or the user base for QB64, or lead to a more universal platform for programming.
I'm sure once artificial intelligence gets intelligent enough, and deep learning gets deep enough, that there can be IDEs capable of translating code on the fly between any language or even paradigm. I have to find the link again, but I have even found & used a Web-based AI tool that translated code between languages and it produced working Python code from the JavaScript examples I fed it. Perhaps we could simply have an IDE that calls that Web service with the advanced AI to do the heavy lifting of translating code?
Anyway that's my thought for the day, which came out of another conversation we were having where Python came up... I figured I'd float the idea for discussion for y'all to shoot down or discuss, or as an idea for someone looking for a challenge!
The top code sets the variable "h" to equal the SCREEN() function. It is used so the screen position is read only once. The variable then checks two places in the code where this info is polled. Now the bottom code does exactly the same thing, but it calls the SCREEN() function THREE times. You'd probably think that's the slower way to do things, but it's actually about 5 times faster!
Code: (Select All)
ii = 0
FOR i = 0 TO LEN(a.ship) - 1
h = SCREEN(j, k + i)
IF h = ASC(g.flagship) OR h = g.m_asc THEN
IF h = ASC(g.flagship) THEN
ii = 1
EXIT FOR
ELSE
ii = 2
EXIT FOR
END IF
END IF
NEXT
Code: (Select All)
FOR i = 0 TO LEN(a.ship) - 1
IF SCREEN(j, k + i) = ASC(g.flagship) OR SCREEN(j, k + i) = g.m_asc THEN
IF SCREEN(j, k + i) = ASC(g.flagship) THEN
ii = 1
EXIT FOR
ELSE
ii = 2
EXIT FOR
END IF
END IF
NEXT
Pete
- Looking forward to an afterlife based on attendance.
Would it make understanding graphics easier to follow, specially employing Sin, Cos and _Atan2?
Here I've converted Sin, Cos, _Atan2, DrawArc and ArrowTo to using Degree Units in the Call to the Sub and internalized all the radian conversions inside the Sub.
Here is main Demo:
Code: (Select All)
' OK let's be rid on the confusion caused by Radians
' by using User Defined Functions SinD and CosD that take Degrees 0 to 360 for whole circle,
' and having replaced _Atan2 by returning an angle in Degrees between 2 points: DAtan2(baseX, baseY, angleToX, angleToY)
_Title "Degrees for everything" 'b+ 2022-10-12
Screen _NewImage(800, 600, 32) ' standard screen size 800 wide, 600 height for quick QB64 Demos with full color potential (the 32)
_ScreenMove 250, 50
cx = _Width / 2 ' middle of the screen point center x
cy = _Height / 2 ' center y
radius = 250 ' max is 300 for height 600
ArrowTo cx, cy, 0, radius - 3, &HFFFFFFFF
For degrees = 0 To 359 Step 10 ' go around a full circle in degrees in steps of 10 degrees
' calculate and draw points around the center of the screen
x = cx + radius * CosD(degrees) ' use CosD for x dimensions
y = cy + radius * SinD(degrees) ' use SinD for y dimensions
Circle (x, y), 1 ' draw bigger points than single pixel
' labeling the degree angles before or after the point ?
If x < cx Then Xoffset = -10 * Len(_Trim$(Str$(degrees))): YOffset = 0
If x > cx Then Xoffset = 4 * Len(_Trim$(Str$(degrees))): YOffset = 0
If x = cx Then
Xoffset = -4 * Len(_Trim$(Str$(degrees)))
If y > cy Then YOffset = 20 Else YOffset = -20
End If
_PrintString (x + Xoffset, y - 8 + YOffset), _Trim$(Str$(degrees))
Next
' save our compass dial to image
dial& = _NewImage(_Width, _Height, 32)
_PutImage , 0, dial& ' screen to dial image stored
' Getting use to seeing angles mouse makes to center of screen
Do
Cls
_PutImage , dial&, 0
While _MouseInput: Wend ' this checks where mouse is right now!
mx = _MouseX: my = _MouseY: mb1 = _MouseButton(1) ' left mouse down ' saves mouse status to common variable names
'lets's the angle in degrees the mouse is to the center of the screen
dAngle = DAtan2(cx, cy, mx, my)
Print "The mouse pointer is "; _Trim$(Str$(dAngle)); " Degrees from the screen center." ' then center point is first the mouse point is second
ArrowTo cx, cy, dAngle, radius - 3, &HFFFFFF00
drawArc cx, cy, 70, 0, dAngle, &HFFFFFF00
_Display ' stop the blinking
_Limit 60 ' only loop 60 times per second
Loop Until _KeyDown(27)
' use angles in degrees units instead of radians (converted inside sub)
Function CosD (degrees)
' Note this function uses whatever the default type is, better not be some Integer Type.
CosD = Cos(_D2R(degrees))
End Function
' use angles in degrees units instead of radians (converted inside sub)
Function SinD (degrees)
' Note this function uses whatever the default type is, better not be some Integer Type.
SinD = Sin(_D2R(degrees))
End Function
' use angles in degrees units instead of radians (converted inside sub)
Function DAtan2 (x1, y1, x2, y2) ' The angle in degrees a 2nd point (x2, y2) makes to a first point (x1, y1)
' Note this function uses whatever the default type is, better not be some Integer Type.
' Delta means change between 1 measure and another for example x2 - x1
deltaX = x2 - x1
deltaY = y2 - y1
' To find the angle point(x2, y2) makes to (x1, y1) in Degrees
' Take DegreeAngle = DAtan2(y2 - y1, x2 - x1)
rtn = _R2D(_Atan2(deltaY, deltaX))
If rtn < 0 Then DAtan2 = rtn + 360 Else DAtan2 = rtn
End Function
' use angles in degrees units instead of radians (converted inside sub)
Sub ArrowTo (BaseX As Long, BaseY As Long, dAngle As Double, lngth As Long, colr As _Unsigned Long)
Dim As Long x1, y1, x2, y2, x3, y3
Dim As Double rAngle
rAngle = _D2R(dAngle)
x1 = BaseX + lngth * Cos(rAngle)
y1 = BaseY + lngth * Sin(rAngle)
x2 = BaseX + .8 * lngth * Cos(rAngle - _Pi(.05))
y2 = BaseY + .8 * lngth * Sin(rAngle - _Pi(.05))
x3 = BaseX + .8 * lngth * Cos(rAngle + _Pi(.05))
y3 = BaseY + .8 * lngth * Sin(rAngle + _Pi(.05))
Line (BaseX, BaseY)-(x1, y1), colr
Line (x1, y1)-(x2, y2), colr
Line (x1, y1)-(x3, y3), colr
End Sub
' use angles in degrees units instead of radians (converted inside sub)
Sub drawArc (xc, yc, radius, dStart, dMeasure, colr As _Unsigned Long)
' xc, yc Center for arc circle
' rStart is the Radian Start Angle, use _D2R for conversion from Degrees to Radians
' rMeasure is the measure of Arc in Radain units, use _D2R for conversion from Degrees to Radians
' Arc will start at rStart and go clockwise around for rMeasure Radians
Dim rStart, rMeasure, rEnd, stepper, a, x, y
rStart = _D2R(dStart)
rMeasure = _D2R(dMeasure)
rEnd = rStart + rMeasure
stepper = 1 / radius ' the bigger the radius the smaller the steps
For a = rStart To rEnd Step stepper
x = xc + radius * Cos(a)
y = yc + radius * Sin(a)
If a > rStart Then Line -(x, y), colr Else PSet (x, y), colr
Next
End Sub
With QB64PE V3.3 having new parameters for _SNDPLAYCOPY, I wondered if building a sound and saving it was possible. I mean in the same sort of way that you can build an image by using pset, line, circle etc and then saving it into an image using _PUTIMAGE. I assume there's no way but I thought I'd ask here, just in case.
For example, here is a sort of doppler/fading beep routine:
Code: (Select All)
Dim blip&
blip& = _SndOpen("G025.mp3")
v1 = 0
switch = 0
Do
_Limit 8
If switch = 0 Then
v1 = v1 + .499
If v1 > 1 Then
v1 = 1
switch = 1
End If
Else
v1 = v1 - .1
If v1 < 0 Then
v1 = 0
switch = 0
_Delay 2.
End If
End If
_SndPlayCopy blip&, v1
Loop
If you were making a game and wanted to repeat this overall routine, would you just repeat the routine or try to capture it into a sound file and just use that? Hope I'm making sense. Just curious what a good strategy would be.
_Title "Recurring Star Power" ' b+ 2022-10-12
_Title "Recurring Star Power" ' b+ 2022-10-12
Const xmax = 700
Const ymax = 700
Randomize Timer
Screen _NewImage(xmax, ymax, 32)
_ScreenMove 360, 5
Dim Shared cx, cy, cr, ra, inc
cx = xmax / 2: cy = ymax / 2: cr = ymax / 5.5: inc = _Pi(1 / 360)
Color _RGBA(100, 255, 100, 40), _RGB32(0, 0, 0)
For n = 5 To 5
a = 0
ra = _Pi(2) / n
While 1
Cls
levels = 5 '12 - n
RecurringCircles cx, cy, cr, n, a, levels
a = a + inc
_Display
Wend
Sleep
Cls
RecurringCircles cx, cy, cr, n, 0, levels
_Display
_Limit 5
Next
Sub RecurringCircles (x, y, r, n, rao, level)
star x, y, .4 * r, r, 5, _R2D(_Pi / 10), &HFFFFFF00 ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If level > 0 Then
For i = 0 To n - 1
x1 = x + 1.5 * r * Cos(i * ra + rao + _Pi(-.5))
y1 = y + 1.5 * r * Sin(i * ra + rao + _Pi(-.5))
RecurringCircles x1, y1, r * .45, n, 2 * rao, level - 1
Next
End If
End Sub
Sub star (x, y, rInner, rOuter, nPoints, angleOffset, K As _Unsigned Long)
' x, y are same as for circle,
' rInner is center circle radius
' rOuter is the outer most point of star
' nPoints is the number of points,
' angleOffset = angle offset IN DEGREES, it will be converted to radians in sub
' this is to allow us to spin the polygon of n sides
Dim pAngle, radAngleOffset, x1, y1, x2, y2, x3, y3, i As Long
pAngle = _D2R(360 / nPoints): radAngleOffset = _D2R(angleOffset)
x1 = x + rInner * Cos(radAngleOffset)
y1 = y + rInner * Sin(radAngleOffset)
For i = 0 To nPoints - 1
x2 = x + rOuter * Cos(i * pAngle + radAngleOffset + .5 * pAngle)
y2 = y + rOuter * Sin(i * pAngle + radAngleOffset + .5 * pAngle)
x3 = x + rInner * Cos((i + 1) * pAngle + radAngleOffset)
y3 = y + rInner * Sin((i + 1) * pAngle + radAngleOffset)
ftri x1, y1, x2, y2, x3, y3, K
'triangles leaked
Line (x1, y1)-(x2, y2), K
Line (x2, y2)-(x3, y3), K
Line (x3, y3)-(x1, y1), K
x1 = x3: y1 = y3
Next
Paint (x, y), K, K
End Sub
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
Dim D As Long
Static a&
D = _Dest
If a& = 0 Then a& = _NewImage(1, 1, 32)
_Dest a&
_DontBlend a& ' '<<<< new 2019-12-16 fix
PSet (0, 0), K
_Blend a& '<<<< new 2019-12-16 fix
_Dest D
_MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
End Sub
I've seen this before, probably from B+, but I wanted to see if I could do it from a fresh start. After a few attempts I figured it out! I used radians on the circle and also saved the points in memory so I could then go to a DO/LOOP to use them how I wish. After many triangles it starts over again with a random color again.
Code: (Select All)
'Circular Pattern Using Triangles by SierraKen
'October 11, 2022
'
'Thanks to B+ and others for the inspiration to make my own.
Dim x(1000), y(1000)
Screen _NewImage(800, 600, 32)
_Title "Circular Pattern Using Triangles by SierraKen - Esc to quit"
For t = 0 To 1000 Step 1 / 3
x(t) = (Sin(t) * 180) + 400
y(t) = (Cos(t) * 180) + 300
Circle (x(t), y(t)), 2, _RGB32(0, 255, 0)
Next t
Randomize Timer
c1 = (Rnd * 155) + 100: c2 = (Rnd * 155) + 100: c3 = (Rnd * 155) + 100
Do
_Limit 20
'This uses radians in the circle. I used a radian chart online to get each formula with _PI
Line (x(7 * (_Pi / 6) + a), y(7 * (_Pi / 6) + a))-(x(11 * (_Pi / 6) + a), y((11 * _Pi / 6) + a)), _RGB32(c1, c2, c3)
Line (x(11 * (_Pi / 6) + a), y(11 * (_Pi / 6) + a))-(x((_Pi / 2) + a), y((_Pi / 2) + a)), _RGB32(c1, c2, c3)
Line (x((_Pi / 2) + a), y((_Pi / 2) + a))-(x(7 * (_Pi / 6) + a), y(7 * (_Pi / 6) + a)), _RGB32(c1, c2, c3)
a = a + 1 / 3
If a > 300 Then
a = 0
Cls
For tt = 0 To 2000 Step 1 / 3
xx = (Sin(tt) * 180) + 400
yy = (Cos(tt) * 180) + 300
Circle (xx, yy), 2, _RGB32(0, 255, 0)
Next tt
c1 = (Rnd * 155) + 100: c2 = (Rnd * 155) + 100: c3 = (Rnd * 155) + 100
End If
Loop Until InKey$ = Chr$(27)
Creeping Elegance - Yes it's a thing. It's a description of things which at the request of unqualified people (namely salesmen). Want things for a project which takes away engineering time and costs money with no immediate return.
Backstory: I used to work for a company, which wrote from bottom up an Operating system which duplicated a major vendor in the field and did one better. We were the first to do it in software. Other guy did it in eproms, lots and lots of eproms. The O/S was called Pick O/S. It did all the things the fortune 500/100 companies wanted that IBM did not provide. At the milestone of V2.0, a large number of features was requested in a short time frame and a want to be fixed all known and unknown bugs. Unknown bugs ??? WTF ???. Well that set in motion a whole new department dedicated to breaking the O/S. As time pasted (including the first targeted deadline.) Bugs, unknown bugs (fixed) and features were being created. At record pace IMHO. But an ending was no where in sight. The department head of engineering could see what was happening "Creeping Elegance". Fed up with missed deadlines all around. A little meeting was done. The outcome from the meeting, Sales was given the task of defining what was "REALLY NEEDED" to complete V2. A few top level meets later with our largest users. A shorten list of "needs" was created. And a longer list of "wants". V2 went out quicker and customers got a hint at V3. Everyone was happy with V2.
Bottom line: There was a lot of wasted time trying to give Sales features that customers didn't want or would use.
Here is the question:
Are we getting diverted by Creeping Elegance with QB64pe ?
Should we survey which features to create ?
Don't get me wrong here, I think QB64pe, has a lot of good things and features. Just my 3 cents here.
' Poker.bas 2022-10-10 b+ try ranking hands
Dim Shared Order$
Order$ = " A 2 3 4 5 6 7 8 910 J Q K"
Dim Shared Deck$(52), rankCount(10)
makeDeck
'For i = 1 To 52
' Print i, Deck$(i)
'Next
'end
shuffle
'For i = 1 To 52
' Print i, Deck$(i)
'Next
'end
'make sure we detect rare occurances
h$ = " AC10C JC QC KC"
Print h$; " = "; RankName$(Rank(h$))
h$ = " KS10S JS QS AS"
Print h$; " = "; RankName$(Rank(h$))
h$ = " AC 3C JC QC KC"
Print h$; " = "; RankName$(Rank(h$))
h$ = " AC 2C 3C 4C 5C"
Print h$; " = "; RankName$(Rank(h$))
h$ = " AS 2C 3C 4C 5C"
Print h$; " = "; RankName$(Rank(h$))
Cls
tests = 10000000
While fini = 0
For k = 0 To 9
h$ = ""
For i = 1 To 5
h$ = h$ + Deck$(k * 5 + i)
Next
r = Rank(h$)
rankCount(r) = rankCount(r) + 1
Next
hands = hands + 10
If hands >= tests Then fini = 1 Else shuffle
'input "Quit? ";a$
'if a$ = "y" then fini = 1 else shuffle
Wend
For i = 1 To 10
Print rankCount(i); ", "; Int(rankCount(i) / tests * 100); "%, "; RankName$(i)
Next
Function RankName$ (RNumber)
Select Case RNumber
Case 1: RankName$ = "Royal Flush"
Case 2: RankName$ = "Straight Flush"
Case 3: RankName$ = "Four of a Kind"
Case 4: RankName$ = "Full House"
Case 5: RankName$ = "Flush"
Case 6: RankName$ = "Straight"
Case 7: RankName$ = "Three of a Kind"
Case 8: RankName$ = "Two Pair"
Case 9: RankName$ = "Pair"
Case 10: RankName$ = "High Card"
End Select
End Function
Function Rank (hand$)
Dim arrange(13)
For i = 1 To 5
v$ = Mid$(hand$, i * 3 - 2, 2)
f = (InStr(Order$, v$) + 1) / 2
arrange(f) = arrange(f) + 1
Next
For i = 1 To 13
Select Case arrange(i)
Case 2: pair = pair + 1
Case 3: three = 1
Case 4: four = 1
End Select
Next
If four = 1 Then Rank = 3: Exit Function
If three = 1 And pair = 1 Then Rank = 4: Exit Function
If three = 1 Then Rank = 7: Exit Function
If pair = 2 Then Rank = 8: Exit Function
If pair = 1 Then
Rank = 9: Exit Function
Else ' check flush and straight
suit$ = Mid$(hand$, 3, 1): flush = 1
For i = 2 To 5
If Mid$(hand$, i * 3, 1) <> suit$ Then flush = 0: Exit For
Next
i = 1: straight = 1 ' find lowest card i
While arrange(i) = 0
i = i + 1
Wend
If i = 1 Then
If arrange(10) = 1 And arrange(11) = 1 And arrange(12) = 1 And arrange(13) = 1 Then
straight = 1: royal = 1: GoTo FinishRank
End If
End If
If i >= 10 Then
straight = 0
Else
straight = 1
For j = i + 1 To i + 4 ' check next 4 cards in sequence
If arrange(j) <> 1 Then straight = 0: Exit For
Next
End If
FinishRank:
If (straight = 1) And (flush = 1) And (royal = 1) Then Rank = 1: Exit Function
If (straight = 1) And (flush = 1) Then Rank = 2: Exit Function
If (flush = 1) Then Rank = 5: Exit Function
If (straight = 1) Then
Rank = 6
Else
Rank = 10
End If
End If
End Function
Sub shuffle
For i = 52 To 2 Step -1
r = Int(Rnd * i) + 1
t$ = Deck$(i)
Deck$(i) = Deck$(r)
Deck$(r) = t$
Next
End Sub
Sub makeDeck
suit$ = "CDHS"
For s = 1 To 4
For i = 1 To 13
Deck$((s - 1) * 13 + i) = Mid$(Order$, (i - 1) * 2 + 1, 2) + Mid$(suit$, s, 1)
Next
Next
End Sub
' rank name calc % calc odds
'1data " Royal Flush", 0.000154, 649740
'2data " Straight Flush", 0.00139 , 72193.33
'3data " Four of a Kind", 0.0240 , 4165
'4data " Full House", 0.144 , 694.17
'5data " Flush", 0.197 , 508.8
'6data " Straight", 0.392 , 254.8
'7data "Three of a Kind", 2.11 , 47.3
'8data " Two Pair", 4.75 , 21.03
'9data " Pair", 42.3 , 2.36
'10 data " High Card", 50.1 , 1.995
I'm curious about how "Reputation" is calculated (no, I'm not really worried about mine - I just tag along).
As an example, take Vince (nothing personal, Vince, just an example).
Total Reputation: 8
From Members:0
From Posts: 10
Obviously 2 extra "Reputation" points from somewhere, but where?
#201 - Source files provided on the command line can now be relative to the current working directory - @DualBrain, @mkilgore
The executable name specified by -o is always relative to the location of the source file.
The previous behavior of specifying the source file relative to the location of QB64-PE still works.
#145, #204 - QB64-PE can now generate a ".license.txt" file beside your program - @mkilgore
This file contains the text of all the software licenses that apply to your program based on the dependencies you are using. You can then distribute the license file alongside your program to meet the requirements of those licenses.
The file can be generated either via a toggle option in the `Run` menu, or via the new `-f:GenerateLicenseFile=[true/false]` command line option.
#185, #208 - `_SNDPLAYCOPY` now takes `x`, `y`, and `z` parameters to change the balance of the copied sound - @a740g
Bug Fixes
#177, #197 - Using undeclared variables in a CONST expression now properly gives an error - @mkilgore
#194, #195, #197 - _BLUE and _RGBA now work in CONST expressions - @mkilgore
#202 - Fixed `String * n` and `Bit * n` types when used with Static arrays - @DualBrain, @mkilgore
#199, #203 - Fixed the command line options listed in manpage - @mkilgore