Page 10 of 18
Re: Create a button's icon with a part of a big image?
Posted: Fri Aug 26, 2022 2:55 pm
by Zax
The project is progressing well, I'm now in an optimization phase.
Regarding my latest problem, I found the faulty operation: when opening the stack, I redraw all the gaming cards from images residing in a substack. This operation is a bit slow on my old machine and the problem is that the last line of the script is
skipped/forgotten, without any pending message.
Code: Select all
on board_redrawCards
repeat for each item thisImage in myImageList
set the text of img thisImage to (the text of img thisImage of card "GamingCards" of stack "GamingCardsStack")
end repeat
doOtherStuff //////// IGNORED !!!
end board_redrawCards
If
wait... with messages is added,
doOtherStuff statement is well processed.
Code: Select all
on board_redrawCards
repeat for each item thisImage in myImageList
set the text of img thisImage to (the text of img thisImage of card "GamingCards" of stack "GamingCardsStack")
end repeat
wait 500 milliseconds with messages ////////// how long I have to wait ???
doOtherStuff
end board_redrawCards
The real question is how long should I wait. It depends on the machine.
OK, but how to know if the loop is finished and the script can continue, knowing that any statement following the loop is ignored if there is no
wait... with message?
Re: Create a button's icon with a part of a big image?
Posted: Fri Aug 26, 2022 8:59 pm
by jacque
Does this work:
Code: Select all
on board_redrawCards
lock screen
repeat for each item thisImage in myImageList
set the text of img thisImage to (the text of img thisImage of card "GamingCards" of stack "GamingCardsStack")
end repeat
unlock screen
send "doOtherStuff" to me in 1 millisecond
end board_redrawCards
The theory is that LC needs an idle period to redraw the images, and using "send in time" allows that. The board_redrawCards handler should run fairly quickly if you lock the screen, and calling "doOtherStuff" after a short delay should execute after the loop finishes. This way you don't need to guess how long to wait, the other stuff won't happen until the first handler finishes.
Re: Create a button's icon with a part of a big image?
Posted: Sat Aug 27, 2022 10:36 am
by Zax
It's better. But 1 ms is still not enough: I tried with 100 ms with success.
In fact, I already locked the screen before changing images' text but the
unlock screen command was placed at the end of
doOtherStuff statement.
But you're right Jacqueline, SVG process doesn't take much time, so it's all still a bit of a mystery.
Anyway, I repeat, it's much better now, and it works.

Re: Create a button's icon with a part of a big image?
Posted: Sat Aug 27, 2022 1:53 pm
by Zax
OK, this is it! At least a beta version.
The main features I wanted are present (choice of board and card graphics). The cards movements are not very smooth on my machine but it should be fine on newer machines.
I've wanted to make a Beleaguered Castle Solitaire for a long time - you can find some on the web but they are often very ugly or not very pleasant to use.
I couldn't have done it without your help, so again a very big thank you to everyone!
MacOS standalone:
https://sw.ixoft.com/files/BeleagueredC ... 05_OSX.zip
Windows standalone:
https://sw.ixoft.com/files/BeleagueredC ... 05_win.zip
Also, for those who would be interested, I have 2 sets of cards in SVG - one file per card:
Standard:
https://sw.ixoft.com/files/_OLD/Playing ... andard.zip
Textured:
https://sw.ixoft.com/files/_OLD/Playing ... xtured.zip
Re: Create a button's icon with a part of a big image?
Posted: Sat Aug 27, 2022 5:11 pm
by jacque
Did you ever figure out what was causing the delay? I'm curious.
I've never played Beleaguered Castle but you've got me interested. You did spur me to pull out my old solitaire game, based on one called Sir Tommy, and I've been experimenting with turning it into a web app. I also have an old Klondike game I might tinker with.
I'll give your game a try. Congratulations!
Re: Create a button's icon with a part of a big image?
Posted: Sat Aug 27, 2022 6:11 pm
by richmond62
Fantastic . . .
. . . makes me feel bad about my half-finished Onitama.
Back in Bulgaria on 31st, rubbish preterm before 8th, teaching starts on the 8th. Hope by the following week things will have calmed down and I can . . .
You may think you have learnt a few things from me, BUT I think I have learnt at least as much from you.
Oh, and as, while on holiday I only have my Linux 64-bit laptop, could be extra kind and make a Linux 64 standalone?
Re: Create a button's icon with a part of a big image?
Posted: Sun Aug 28, 2022 1:19 pm
by Zax
Thank you for your comments, I appreciate

(and I also thank you to be so patient for my "exotic" english).
What I appreciate in Beleaguered Castle is the balance between chance and reflection. After the random draw of the cards, it becomes a puzzle game.
Jacqueline, concerning the mysterious delay, I finally had to roll back to my previous version with a wait for 500 ms with messages.
Maybe the solution could be:
Code: Select all
on openingStuff
doSomeStuff
send "board_redrawCards" to me in 10 milliseconds // 53 images from 15 to 920 ko !
doOtherStuff
end openingStuff
richmond, I compiled a Linux version... without any guarantee because I'm unable to test Linux version.
A new version is available. It fixes some minor bugs :
MacOS standalone:
https://sw.ixoft.com/files/BeleagueredC ... 06_OSX.zip
Windows standalone:
https://sw.ixoft.com/files/BeleagueredC ... 06_win.zip
Linux standalone:
https://sw.ixoft.com/files/_OLD/Beleagu ... _linux.zip
Re: Create a button's icon with a part of a big image?
Posted: Sun Aug 28, 2022 5:00 pm
by bn
Hi Zax,
I like the design of your game and the game looks great and works for me on a fast Mac without a hitch.
Kind regards
Bernd
Re: Create a button's icon with a part of a big image?
Posted: Sun Aug 28, 2022 7:00 pm
by richmond62
-
Something not quite right.
The 'trick' is to get hold of an old, unwanted PC and install Xubuntu on it: perfect for testing.

Re: Create a button's icon with a part of a big image?
Posted: Sun Aug 28, 2022 8:11 pm
by jacque
I ran your game on my iMac and it was smooth and worked very well. Very nice implementation. You thought of all the tricks to make the game easily functional.
I only saw one thing that wouldn't reproduce; after clicking a card to auto-play it, the window size changed slightly, back to a default size I think. I resized it a bit larger and after that it stayed that way. That's a minor thing though, you did a great job. I haven't tried your revised release yet but I will.
Have you ever won this game? Several deals produced Kings at the end of several rows and no playable cards elsewhere.
Re: Create a button's icon with a part of a big image?
Posted: Sun Aug 28, 2022 10:39 pm
by stam
richmond62 wrote: Sun Aug 28, 2022 7:00 pm
Something not quite right.
The 'trick' is to get hold of an old, unwanted PC and install Xubuntu on it: perfect for testing.
I’m guessing this isn’t something the author can do much about. I guess it could be something funky with 10.0.0 DP4, and it may be worth rebuilding the Linux standalone with 9.6.8 stable, but not being able to load the gdk library may well be due (and I’m completely guessing here) to the particular flavour of Linux or setup for example.
Googling gdk:
https://en.wikipedia.org/wiki/GDK?wprov=sfti1
This falls under the category of Linux gobbledygook for me, but i suspect it’s something to do with Linux setup or the way LiveCode builds for Linux rather than something with the the code… don’t think the author can resolve this. May be worth opening a support ticket…
Re: Create a button's icon with a part of a big image?
Posted: Mon Aug 29, 2022 6:46 am
by Zax
Glad to hear the game doesn't seem too jerky on newer machines.
Jacqueline, the adaptative board size has been a problem for me since the start of development. I tried numerous thing without yet finding a good solution.
And yes, the game is winnable. I win about 1 game out of 6. The trick is to empty rows. Once you have 2 empty rows, you are on your way to winning.
This is for example a game I recently played, and win after 122 moves. Just put the savedgame file into your Preferences folder and launch the game. You can use the history back to see the cards mouvements, or Reload Game to see its initial state.
Sorry
richmond but I haven't enough time and strength to explore Linux world.
Re: Create a button's icon with a part of a big image?
Posted: Mon Aug 29, 2022 10:21 am
by richmond62
Please try a build as suggested with 9.6.8.
Re: Create a button's icon with a part of a big image?
Posted: Mon Aug 29, 2022 2:46 pm
by Zax
richmond62 wrote: Mon Aug 29, 2022 10:21 am
Please try a build as suggested with 9.6.8.
The standalone Linux version I posted was made with LC MacOSX 9.6.8 stable.
What do you want me to do exactly?
Re: Create a button's icon with a part of a big image?
Posted: Mon Aug 29, 2022 5:09 pm
by jacque
Maybe he needs the x64 build? I'm not sure you need the Inclusions either.