I know mouse drivers and functions have been discussed 100 times but I am posting this mouse program because I wrote it myself and might be of some use.
It is not an issue or am I declaring any problem.
Erik
Code: (Select All)
Rem Mouse.bas is the sample mouse trap function for QB64 PD 2023.
DefLng A-Z
Dim Shared MouseX As Integer, MouseY As Integer
Dim Shared MouseButton1 As Integer, MouseButton2 As Integer, MouseButton3 As Integer
Dim Shared MouseWheel As Integer, WheelReverse As Integer
Const ClickCount = 10 ' double click loop counter
Const ClickDelay = .1 ' double click loop delay
Color 15
Print "Mouse detect. Press <esc> to exit."
If WheelReverse Then
Print " Mouse wheel reverse on."
End If
Do
x$ = InKey$
If x$ = Chr$(27) Then Exit Do
x = MouseDriver
If MouseButton1 = 2 Then
Print "Double-Button1": MouseButton1 = 0
Else
If MouseButton1 = 1 Then
Print "Button1": MouseButton1 = 0
End If
End If
If MouseButton2 Then MouseButton2 = 0: Print "Button2"
If MouseButton3 Then MouseButton3 = 0: Print "Button3"
If MouseX Or MouseY Then Print "Coor:"; MouseX; MouseY
If MouseWheel Then
If MouseWheel = -1 Then
Print "Mousewheel Up"
End If
If MouseWheel = 1 Then
Print "Mousewheel Down"
End If
End If
Loop
End
Function MouseDriver
Static X1 As Integer, Y1 As Integer ' store old values
MouseX = 0: MouseY = 0
If _MouseInput Then
X = CInt(_MouseX): Y = CInt(_MouseY) ' X,Y return single
If X <> X1 Or Y <> Y1 Then
X1 = X: Y1 = Y
MouseX = Y: MouseY = X ' X,Y are reversed
While _MouseInput: Wend ' empty buffer
MousePressed = -1
End If
MouseButton1 = _MouseButton(1)
If MouseButton1 Then
MouseButton1 = 1
'MouseX = Y1
'MouseY = X1
MousePressed = -1
MouseCount = 0
Do
_Delay ClickDelay
MouseCount = MouseCount + 1
If MouseCount >= ClickCount Then Exit Do
If _MouseInput Then
If _MouseButton(1) Then
MouseButton1 = 2
Exit Do
End If
End If
Loop
End If
MouseButton2 = _MouseButton(2)
If MouseButton2 Then
'MouseX = Y1
'MouseY = X1
MousePressed = -1
End If
MouseButton3 = _MouseButton(3)
If MouseButton3 Then
MousePressed = -1
End If
MouseWheel = _MouseWheel
If MouseWheel Then
' reverse mousewheel value
If WheelReverse Then
If MouseWheel = -1 Then
MouseWheel = 1
Else
If MouseWheel = 1 Then
MouseWheel = -1
End If
End If
End If
End If
End If
MouseDriver = -1
End Function
Now when the `Home` key is pressed, the cursor will only jump to the `start of line` if its current position is exactly on `start of text`, and from all other positions in the line (including anywhere in the indention space) it will always jump to `start of text`
#367 - Adds support for `FNT`, `FON`, `PCF` and `BDF` fixed width bitmap fonts. - @a740g
#371 - Updates MinGW. It now supports GCC 13.1.0 with MinGW runtime v11. - @a740g
#380 - Adds initial Windows on ARM support using LLVM-MingW. - @a740g
For now, Windows on ARM versions of QB64-PE can only be built by locally cloning the repository and then running `setup_win.cmd`
#379 - Updates `libstem Gamepad` library to the latest version. - @a740g
Bug Fixes
#351 - Fixes an issue where fonts were getting vertically misaligned. - @a740g
One thing that I want to point out that's missing is all the credit that should go to @RhoSigma and everyone else who helps edit, upkeep, and enhance our wiki. The main thing we track in release notes is who pushed what changes into the language, but everyone take a moment out of your day to remember to thank Rho and the rest for keeping the wiki up to date and valid for us!
After all, how useful would any of these nice new features be, without documentation and examples to show us how to use them??
Let me be the first to say that I'm personally very grateful for RhoSigma's hard work on the wiki and keeping it up and going, and integrating it into the IDE for quick Help for us!
RhoSigma -- YOU'RE A HERO, EVEN IF YOU DON'T GET HALF THE CREDIT YOU SHOULD MOST OF THE TIME!!
Playing around with doing a dragon curve fractal, altering the looks of it, making it animated, produced an interesting effect. Uses a recursive SUB.
- Dav
Code: (Select All)
'dragoncurve.bas
'A play on a dragon curve fractal
'Adapted by Dav, OCT/2023
Screen _NewImage(800, 600, 32)
Dim Shared a, p: p = .001
Do
Cls: dragon 400, 300, 90 + (a * 3), a, 16
If a < 200 Then a = a + .15
If p < .002 Then p = p + .00000001
_Limit 15: _Display
Loop Until _KeyHit
Sub dragon (x, y, size, ang, depth)
If depth < 1 Then
PSet (x, y), _RGBA(50, 150, 255, 50 + Rnd * 200)
Else
size2 = size / 1.414214: ang2 = ang - _Pi / p
dragon x, y, size2, ang + _Pi / p, depth - 1
dragon x + size2 * Cos(ang), y + size2 * Sin(ang), size2, ang2, depth - 1
End If
End Sub
Inspired by my code for pipecom for Linux, which uses popen to read from a process, I decided to write up some code for progress bars using Zenity in Linux. I will not post all the code just yet but I wanted to show it at least working. Here is a small recording of a simple progress bar:
The Sep 26, 2023 update to Windows 11 22H2 introduced the ability for File Explorer to extract files from archives of types other than just .zip files. This includes .7z files. However, File Explorer cannot extract contents of the QB64PE .7z distribution. Trying to extract the files results in an error:
"An unexpected error is keeping you from copying the file. If you continue to receive this error, you can use the error code to search for help with this problem.
Error 0x8096002A: No error description is available"
I have tried this with both the 3.8.0 and 3.9.0 distributions.
The workaraound is simple - simply use 7-ZIP.
I'm wondering if there is a known cause for this problem. Is it possible that some advanced compression method is being used that File Explorer simply does not understand?
I feel as though it is probably something I'm doing wrong but I am having so much trouble trying to load a font in Linux QB64pe. I don't know what I am doing wrong. I will provide an absolute path to a TTF file and the font handle is always invalid. Even when using InFormPE, it is unable to load any fonts besides 8 or 16 (the built-in VGA fonts). Is there some mystical-magical thing I need to do in Linux to work around this or are custom fonts not available in Linux? I am very confused and would appreciate any help.
Now when the `Home` key is pressed, the cursor will only jump to the `start of line` if its current position is exactly on `start of text`, and from all other positions in the line (including anywhere in the indention space) it will always jump to `start of text`
#367 - Adds support for `FNT`, `FON`, `PCF` and `BDF` fixed width bitmap fonts. - @a740g
#371 - Updates MinGW. It now supports GCC 13.1.0 with MinGW runtime v11. - @a740g
#380 - Adds initial Windows on ARM support using LLVM-MingW. - @a740g
For now, Windows on ARM versions of QB64-PE can only be built by locally cloning the repository and then running `setup_win.cmd`
#379 - Updates `libstem Gamepad` library to the latest version. - @a740g
Bug Fixes
#351 - Fixes an issue where fonts were getting vertically misaligned. - @a740g
Was adding more textures to my BALL sub Here, and thought why not just use textured images on the balls instead. Spherical mapping is a little above me, but here's 2 ways I've worked out so far that gives and illusion that an image is wrapped around the ball. Will post them here for input (advice/help is more like it...)
There are 2 SUBs. One maps the image in a circular method from the center point, the other SUB just stamps the image it plain jane on the front of the ball. The demo makes a texture& image to use, but can load one yourself instead. Image textures look better with the circular method I think.
if anyone have some routines for doing something like this, could you share them? Thanks!
- Dav
Code: (Select All)
'ImageBalls.bas
'Working on a couple ways to put an image on a ball.
'Two SUB's - either pset it straight, or in a circular method from the center point.
'Coded by Dav, SEP/2023
_Icon
'Get a bird& image from the built-in ICON
bird& = _NewImage(192, 192, 32): _Dest bird&
Cls , _RGB(200, 200, 0)
_PutImage (0, 0)-(192, 192), -11: _Dest 0
Screen _NewImage(800, 600, 32)
'Make sample texture& image to use, or load your own with _LOADIMAGE
texture& = _NewImage(200, 200, 32)
_Dest texture&
Cls , _RGB(33, 66, 99)
For x = 0 To _Width Step 25
For y = 0 To _Height Step 25
Line (x, y)-Step(50, 50), _RGBA(Rnd * 255, Rnd * 255, Rnd * 255, Rnd * 255), BF
Next
Next
'_PutImage (0, 0), bird&
_PrintMode _KeepBackground
_PrintString (50, 90), "QB64-PE POWER"
_Dest 0
'Or load your own image like below
'_FreeImage texture&
'texture& = _LoadImage("brickwall.jpg", 32)
Sub ImageBall (x, y, size, image&)
'Puts image in a center circle
orig& = _Source
_Source image&
For y2 = y - size To y + size
For x2 = x - size To x + size
dis = Sqr((x2 - x) ^ 2 + (y2 - y) ^ 2)
If dis <= size Then
ix = ((_Atan2(y2 - y, x2 - x) + _Pi) / (2 * _Pi)) * (_Width(image&) - 1)
iy = ((_Acos((dis / size) * 2 - 1)) / _Pi) * (_Height(image&) - 1)
c& = Point(ix, iy): r = _Red32(c&): g = _Green32(c&): b = _Blue32(c&)
PSet (x2, y2), _RGB(r - dis, g - dis, b - dis)
End If
Next
Next
_Source orig&
End Sub
Sub ImageBall2 (x, y, size, image&)
'puts image on straight.
'To make it look better, make a temp image to match the size of the ball
temp& = _NewImage(size * 2, size * 2, 32)
'put the image& into temp&, stretch to fill
_PutImage (0, 0)-(_Width(temp&), _Height(temp&)), image&, temp&
orig& = _Source
_Source temp&
For y2 = y - size To y + size
For x2 = x - size To x + size
If Sqr((x2 - x) ^ 2 + (y2 - y) ^ 2) <= size Then
clr = (size - (Sqr((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)))) / size
c& = Point(x2 - x + size, y2 - y + size): r = _Red32(c&): g = _Green32(c&): b = _Blue32(c&)
PSet (x2, y2), _RGB(clr * r, clr * g, clr * b)
End If
Next
Next
_FreeImage temp&
_Source orig&
End Sub