Posts: 37
Threads: 5
Joined: May 2024
Reputation:
5
i guess this "pwa" thing is something only windows users could enjoy. because i cannot get it to appear for me on vivaldi. i am on linux, debian mate with "bookworm" (current lts) base. and installed from deb file offered by the home website of the browser.
i have tried to refresh. to find how to install extensions. but i'm not used anymore to a browser other than firefox. i installed vivaldi because i needed a chromium-compatible web browser to go around a problem with a service site that otherwise expects me to use their mobile app.
firefox esr is my other choice, but we all know what's the answer for that.
Posts: 279
Threads: 25
Joined: Apr 2022
Reputation:
64
(Yesterday, 10:34 PM)hsiangch_ong Wrote: i guess this "pwa" thing is something only windows users could enjoy. because i cannot get it to appear for me on vivaldi. i am on linux, debian mate with "bookworm" (current lts) base. and installed from deb file offered by the home website of the browser.
It’s not strictly a windows feature. The screenshots on the original post are from an Edge browser running on Linux Mint. I’m afraid I’m not too familiar with Vivaldi, but perhaps this page might help:
https://help.vivaldi.com/desktop/miscell...e_Web_Apps
Posts: 4,085
Threads: 181
Joined: Apr 2022
Reputation:
232
Hi @dbox,
I am stumped once again why this works in QB64 but not QBJS. I took out Timer and tried a couple of versions of mouse button catching but best I can do is move 3 blocks and then nothing???
QB64
Code: (Select All) Option _Explicit
_Title "GUI Sliding Blocks Game "
'Randomize Timer
Dim As Long s, q, r, c, c0, r0, i, update, solved, mc, test, m, mb, mx, my, bx, by
Dim flash$
' get from user the desired board size = s
Do
Locate 1, 3: Input "(0 quits) Enter your number of blocks per side 3 - 9 you want > ", s
If s = 0 Then End
Loop Until s > 2 And s < 10
' screen setup: based on the square blocks q pixels a sides
q = 540 / s 'square size, shoot for 540 x 540 pixel board display
Screen _NewImage(q * s + 1, q * s + 1, 32) ': _ScreenMove 360, 60
'initialize board = solution
Dim board(s, s)
For r = 1 To s
For c = 1 To s
board(c, r) = c + (r - 1) * s
Next
Next
board(s, s) = 0: c0 = s: r0 = s
'scramble board for puzzle
For i = 0 To s ^ 5 ' mix blocks
Select Case Int(Rnd * 4) + 1
Case 1: If c0 < s Then board(c0, r0) = board(c0 + 1, r0): board(c0 + 1, r0) = 0: c0 = c0 + 1
Case 2: If c0 > 1 Then board(c0, r0) = board(c0 - 1, r0): board(c0 - 1, r0) = 0: c0 = c0 - 1
Case 3: If r0 < s Then board(c0, r0) = board(c0, r0 + 1): board(c0, r0 + 1) = 0: r0 = r0 + 1
Case 4: If r0 > 1 Then board(c0, r0) = board(c0, r0 - 1): board(c0, r0 - 1) = 0: r0 = r0 - 1
End Select
Next
update = -1 'OK user here you go!
Do
If update Then 'display status and determine if solved
solved = -1: update = 0
For r = 1 To s
For c = 1 To s
If board(c, r) Then
If board(c, r) <> (r - 1) * s + c Then solved = 0
Color _RGB32(255, 255, 255), _RGB32(0, 0, 255)
Line ((c - 1) * q + 1, (r - 1) * q + 2)-(c * q - 2, r * q - 2), _RGB32(0, 0, 255), BF
_PrintString ((c - 1) * q + .4 * q, (r - 1) * q + .4 * q), Right$(" " + Str$(board(c, r)), 2)
Else
If board(s, s) <> 0 Then solved = 0
Color _RGB32(0, 0, 0), _RGB32(0, 0, 0)
Line ((c - 1) * q, (r - 1) * q)-(c * q, r * q), , BF
End If
Next
Next
If solved Then 'flash the Solved Report until user closes window else report status
'_Display
flash$ = "Solved!" + Str$(mc) + " Moves." ' in " + Str$(Int(Timer - t)) + " secs."
While 1: _Title flash$: _Delay .2: _Title " ": _Delay .2: Wend
Else
_Title Str$(mc) + " Moves." ' in " + Str$(Int(Timer - t)) + " secs." + Str$(test)
End If
'_Display
End If
'get next mouse click, check if on block next to empty space make move or beep
While _MouseInput: Wend
mb = _MouseButton(1): mx = _MouseX: my = _MouseY
If mb And solved = 0 Then 'get last place mouse button was down
_Delay .25 ' for user to release mb
'mb = _MouseButton(1): mx = _MouseX: my = _MouseY
'While mb 'left button down, wait for mouse button release
'm = _MouseInput: mb = _MouseButton(1): mx = _MouseX: my = _MouseY
'Wend
'convert mouse position to board array (x, y) are we near empty space?
bx = Int(mx / q) + 1: by = Int(my / q) + 1: update = -1
If bx = c0 + 1 And by = r0 Then
board(c0, r0) = board(c0 + 1, r0): board(c0 + 1, r0) = 0: c0 = c0 + 1: mc = mc + 1
ElseIf bx = c0 - 1 And by = r0 Then
board(c0, r0) = board(c0 - 1, r0): board(c0 - 1, r0) = 0: c0 = c0 - 1: mc = mc + 1
ElseIf bx = c0 And by = r0 + 1 Then
board(c0, r0) = board(c0, r0 + 1): board(c0, r0 + 1) = 0: r0 = r0 + 1: mc = mc + 1
ElseIf bx = c0 And by = r0 - 1 Then
board(c0, r0) = board(c0, r0 - 1): board(c0, r0 - 1) = 0: r0 = r0 - 1: mc = mc + 1
'Else
'Beep
End If
End If
Loop
This code I think would be great Sample:
b = b + ...
Posts: 279
Threads: 25
Joined: Apr 2022
Reputation:
64
(8 hours ago)bplus Wrote: Hi @dbox,
I am stumped once again why this works in QB64 but not QBJS. I took out Timer and tried a couple of versions of mouse button catching but best I can do is move 3 blocks and then nothing??? Hey @bplus, I found that putting a _Limit 60 before the final Loop statement seemed to do the trick.
Quote:This code I think would be great Sample:
Oh yeah, that's a great one! I can definitely add it to the samples. What did you name this one again?
Posts: 4,085
Threads: 181
Joined: Apr 2022
Reputation:
232
4 hours ago
(This post was last modified: 4 hours ago by bplus.)
@dbox Call the fish thing Texting Fish.
That was it! It just needed a _limit to delay the loop around. I think I fixed someone else problem the same! Yikes what a memory.
I cleaned up the code for Sliding Block Puzzle, you can replace that "15 Squares Puzzle" with this, it's way better!
You can't see it here but title flashes when puzzle is solved with number of moves and time in secs then jumps into another puzzle.
Also I noticed 2 things comparing QBJS code and QB64:
1) str$(number) in QBJS does not leave that space before a positive number as in QB64, so you have to _TRIM$() in QB64 so they look the same in print.
2) the _delay amounts aren't matching up, ie flashing that solved message in QB64 is way faster than in QBJS. had to fiddle to get a compromise.
Yeah I am still into having both codes work as closley to the same way as possible.
b = b + ...
|