One for the Math (or ”outside-the-box-thinking”) gurus:
Given an isoscles triangle ABC, with sides b and c (the sides opposite B and C) both 5 units in length, and with angle A=45degrees, is there a (simple?) way to find the length of side a, without resorting to pre-determined trig tables like sin, cos and tan, or pi?
The reason I don’t want to use these is I’m trying to demonstrate how pi relates to the circumference of a circle, so I don’t want to involve anything that relies on pi – that would be “bootstrapping”, sort of like lifting oneself up by the bootlaces.
BAM is a stand-alone wiki for creation of BASIC programs.
It could also contain the programming reference, but that would make BAM heavier than I like, and would make the programming reference heavier than I like. So the programming reference is a separate wiki.
When I look up documentation, I like to see sample source code, right there, embedded in the documentation.
But I also want to see the running program.
Here is what the programming reference does:
When I lookup a statement or function (let's say "CIRCLE"), the page for that documentation includes an iframe that shows relevant content from the BAM wiki. The URL for the iframe is dynamically created by the programming reference, setup in a way that the BAM wiki is displayed in a way that matches the needs of the programming reference. For CIRCLE, the programming reference generates the following URL fed to the iframe to use as SRC parameter, and now I have CIRCLE documentation enhanced with source code examples which I can run, right there:
So _PUTIMAGE has so many paramaters, and works so differently in so many unique situations, and since the conversation is still going so strongly about it and all its options, let's just devote another day to the subject.
Join us at DAY 009:_PutImage (qb64phoenix.com), and ask all you want about the command and how it interacts with its 8 zillion parameters. We'll do our best to answer all we can and give examples to help clarify any confusion and illustrate what we're talking about there.
Beginning C++ output from QB64 code...
[.............................................. ] 92%
Beginning C++ output from QB64 code...
[..................................................] 100%
Compiling C++ code into EXE...
ERROR: C++ compilation failed.
Check .\internal\temp\compilelog.txt for details.
On:
Code: (Select All)
declare sub main
declare sub get_numeric_args(args() as double)
dim args(4) as double
get_numeric_args(args())
sub get_numeric_args(args() as double)
args(1) = 123
end sub
compilelog.txt:
Quote:internal\c\c_compiler\bin\c++.exe -O2 -w -std=gnu++11 -DGLEW_STATIC -DFREEGLUT_STATIC -Iinternal\c\libqb/include -DDEPENDENCY_NO_SOCKETS -DDEPENDENCY_NO_PRINTER -DDEPENDENCY_NO_ICON -DDEPENDENCY_NO_SCREENIMAGE internal\c/qbx.cpp -c -o internal\c/qbx.o
In file included from internal\c/qbx.cpp:2529:
internal\c/..\\temp\\maindata.txt: In function 'void QBMAIN(void*)':
internal\c/..\\temp\\maindata.txt:13:2: error: 'pass1' was not declared in this scope
pass1;
^~~~~
mingw32-make: *** [Makefile:412: internal\c/qbx.o] Error 1
I found this on the "mmbasic" site and converted it to run on qb64.
Screen 12
n = 255
r = (2 * pi) / 235
x = 0
v = 0
t = 0
sz = 200
s = 0
scrw = 640: scrh = 480
sw = scrw / sz: sh = scrh / sz
offset = scrh / 4.5
Do
Cls
For i = 50 To n
For j = 50 To n
u = Sin(i + v) + Sin(r * i + x)
v = Cos(i + v) + Cos(r * i + x)
x = u + t
q = scrw / 2 + u * offset
a = scrh / 2 + v * offset
PSet (q, a), _RGB32(Int(Rnd * 256), Int(Rnd * 256), Int(Rnd * 256))
Next j
Next i
t = t + .025
Loop
A screen shot really does not look as good so run it and see.
I'd like to put CHR$(240), three small horizontal lines, in my title bar, but the _TITLE function cannot convert extended ASCII characters. Is there another method that wold print the 3 horizontal bars into the title bar so it doesn't look like this: ð
Yikes! but all we are doing is copying an image from Source Image Handle and rectangular section to Destination Image Handle and rectangular section.
After working with it for awhile now this is what I see:
(for the moment ignore all that STEPping)
_PutImage rectangle, handle, handle, rectangle
2 line rectangles on either end of the parameters.
2 Image handles in the middle of the parameters.
What belongs to what, the order is: D,S,D,S
D for Destination where you want the rectangle image to go.
S for Source where the image is coming from.
(Kind of an odd sequence but... let us continue.)
Now Rectangle knowledge from working with Line (left, top)-(right, bottom) format comes in handy here (as does the practice with Step). (top, left) corner to (bottom, right) corner defines the rectangle space we are grabbing from Source and then pasting into the Destination.
If you want to fill the whole destination rectangle with the image, leave destination rectangle blank and it will fill the destination image by default. Same with the other end, if you want to use the whole image from the Source handle leave the Source rectangle blank as default.
Where do image handles come from?
Well most important is the current screen image, it is 0 automatically.
You can start an Image handle, say IH& Long Type from
IH& = _LoadImage("Filename.ext")
or
IH& = _NewImage(width, height, colorMode) ' starts a container to draw and/or _PutImage and/or start font and print.
STEP allows you to use the last graphics command (x, y) as the start for the next graphics, a very handy use of step for images is to start with the (x,y) location of the top left corner of the rectangle and -Step(ImageWidth, ImageHeight) instead of adding width to x height to y and finding the absolute position value for the 2nd (x, y).
I think this covers the most common uses of _PutImage there are plenty more details to go over, maybe pick those off with discussion?
In another post I asked for help in how to determine slower frame rates within a master frame rate for a Pac-Man clone I'm working on. DSMan decoded some of the original Ms. Pac-Man assembly code to reveal how it was being accomplished.
I took that idea and created a function that will determine any frame rate within a master frame rate up to 60 FPS. The function and demo code created to show the function in action are below. With this function you can change the frame rate of a game at any time and still maintain any object's desired slower frame rate.
There is an anomaly in the slope that you'll see as it is drawn. I'm not really sure what to make of this? Any ideas?
Code: (Select All)
' Getting slower frame rates within a master frame rate
DIM F(60) AS INTEGER ' frame counters
DIM FramesPerSecond AS INTEGER ' game's frames per second
DIM Dummy AS INTEGER ' used to set intital data
DIM Frame AS INTEGER ' frame counter
DIM Wipe AS INTEGER ' trigger a clearing of frame counters
DIM x AS INTEGER ' cycle through 1 to FramesPerSecond
'+--------------+
'+ Example code |
'+--------------+
Frame = 0 ' reset frame counter
FramesPerSecond = 60 ' set game FPS
SCREEN _NEWIMAGE(640, 480, 32) ' create graphics screen
DO ' begin various FPS loop
Dummy = FPS(-1, FramesPerSecond) ' create frame data set
DO ' begin demo loop
_LIMIT FramesPerSecond ' limit loop to game's frame rate
CLS ' clear the screen
LOCATE 2, 2: PRINT "Counting down from 60 FPS to 1 FPS" ' inform user of progress
LOCATE 3, 2: PRINT "Frames per second ="; FramesPerSecond
LOCATE 4, 1: PRINT INT(Frame / FramesPerSecond) + 1; "of 5 seconds elapsed"
Frame = Frame + 1 ' increment game frame counter
Wipe = 0 ' reset frame counter wipe trigger
IF Frame = FramesPerSecond * 5 THEN Frame = 0: Wipe = -1 ' when 5 seconds has elapsed reset frame counter and trigger a wipe
FOR x = 1 TO FramesPerSecond ' cycle through all available frame rates
IF Wipe THEN F(x) = 0 ' clear frame counter if wipe triggered
IF FPS(x, Frame) THEN F(x) = F(x) + 1 ' is this frame rate's frame active during this frame in the game?
LINE (10, 200 - x * 2)-(10 + F(x), 200 - x * 2) ' yes, draw a line showing progress of frames counted
NEXT x
_DISPLAY ' update the screen with changes
LOOP UNTIL Wipe OR _KEYDOWN(27) ' leave when user presses the ESC key or a wipe triggered
FramesPerSecond = FramesPerSecond - 1 ' decrease the game's frames per second
IF FramesPerSecond < 1 THEN FramesPerSecond = 60 ' reset the game's frame rate when needed
LOOP UNTIL _KEYDOWN(27) ' leave when user presses the ESC key
SYSTEM ' return to the operating system
'--------------------------------------------------------------------------------------------------------------------------------------------+-----+
FUNCTION FPS (TargetFPS AS INTEGER, Frame AS INTEGER) STATIC ' | FPS |
'+---------------------------------------------------------------------------------------------------------------------------------------+-----+
'| Returns frame rates embedded in a master frame rate |
'| |
'| Usage: dummy = FPS(-1, 60) When the target FPS is less than 1 a new data set is created for the requested frame rate |
'| MoveNow = FPS(24, InputFrame) Will return -1 (TRUE) if input frame is on during the target frame rate |
'| |
'| Example: IF FPS(Object.FPS, GameFrame) then Move(Object) Move the object if the object's frame is on within the game's current frame count |
'+---------------------------------------------------------------------------------------------------------------------------------------------+
DIM f AS INTEGER ' frame counter/value
DIM b AS SINGLE ' bit counter/step rate
DIM FramesCreated AS INTEGER ' numer of frames calculated
IF TargetFPS < 1 THEN ' calculate frame counters?
REDIM FPSnum(Frame) AS _UNSIGNED _INTEGER64 ' yes, resize 64bit value array
REDIM Bit(Frame) AS _UNSIGNED _INTEGER64 ' resize bit value array
FOR b = 1 TO Frame ' cycle through bit values
Bit(b) = 2 ^ (b - 1) ' calculate value of each bit
NEXT b
FOR f = 1 TO Frame ' cycle through requested frames
FOR b = 1 TO Frame STEP (Frame / f) ' cycle through bits at current frames per second
FPSnum(f) = FPSnum(f) + Bit(b) ' calculate which bits are turned on
NEXT b
NEXT f
FramesCreated = Frame ' remember number of frames created
EXIT FUNCTION ' leave function
END IF
IF FramesCreated = 0 THEN EXIT FUNCTION ' no data created yet, leave
f = Frame ' don't modify input value
IF f < 1 THEN EXIT FUNCTION ' invalid frame number requested, leave
IF f > FramesCreated THEN f = f MOD FramesCreated ' keep frame number within range
IF FPSnum(TargetFPS) AND Bit(f) THEN FPS = -1 ' report if bit is on for current frame in requested FPS
END FUNCTION
'---------------------------------------------------------------------------------------------------------------------------------------------------
Can someone please elaborate a bit on the m x,y (and its related +/- options) in the draw command? It doesn't get a mention (that I can find) in the Help file, and the Wiki one is pretty unclear. How is it fitted into a draw string, and does it need parentheses, or commas etc?
I'm just in the process of laying out BAM's "SDLC" Tools, starting out with the basics:
Idea Manager
Requirement Manager
Change Request Manager
Issue Manager
Task Manager
Imagine you're working on a complex QB64PE project.
You have an idea, you add it to BAM via the Idea Manager.
That Idea may eventually get deleted/dropped, or may transition into being a new Requirement, or transition into being a Change Request to a previously fulfilled Requirement (a requirement can be a defined need to solve a defined problem, might be a feature, might be a constraint).
If it is a new requirement, eventually that requirement transitions into being a task. When that task gets completed, it transitions to being a fulfilled requirement AND a completed task.
If a Change Request, that change request is linked to some previously fulfilled requirement, and eventually the change request transitions into being a task. When done, that task transitions to being a completed task AND an implemented change request.
An issue (problem/bug/whatever), that issue might be related to a previously fulfilled requirement, and eventually the issue transitions into being a task (AND an issue in the process of being resolved). Or the issue transitions into being a new requirement, and the new requirement eventually transitions into also is a task (AND an issue being resolved).
Something like that.
Just piecing together "flow" to have an idea how to build the "managers" of all this info, and the "editors" for all of this info.