Create a button's icon with a part of a big image? - Beleaguered Castle

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Wed Sep 14, 2022 8:17 am

0.20 is out.
The real cause of the main bug is still not found, but this bug does not cause a problem if you don't click too quickly on the cards or on the history.
Some sounds have been added.

Mac OS: https://sw.ixoft.com/files/_OLD/Beleagu ... 20_OSX.zip
Windows: https://sw.ixoft.com/files/_OLD/Beleagu ... 20_win.zip
Linux: https://sw.ixoft.com/files/_OLD/Beleagu ... inux64.zip

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sun Sep 18, 2022 6:42 pm

I like the sound effects you've added, unobtrusively marking the start and end of a game.

Two things I've noticed:
- The auto-move of a card when clicking it is sometimes "dumb". Example: Clicking on a 2 can send it to the top of a three in the side stacks, instead of the obvious move to the ace. I would expect the first priority of the code that checks where a card can go to check if the suit's middle pile is available, and if not then check if it can go on a side stack, and as last option to an empty slot.
- The resize of the cards when building a tall side stack still happens too soon, when there is still room for 4-5 more cards on the stack without the top card touching the edge of the playing area. And after a resize, if you manually enlarge the app window to make the playing area bigger, expecting the cards to enlarge too, the cards instead resize to even smaller!

Nevertheless, I enjoy this game very much. My current record is now 67 moves, and I still ache for that simple local highscore (or lowscore :) ) list to keep track... :D
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sun Sep 18, 2022 8:03 pm

Thanks for your report Andreas.
I'll check the auto-move, and I'll try to improve the resize.

67 moves is a great score, gratz :)
Displaying igh scores is quite easy to manage. I'll add this feature soon.

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Wed Sep 28, 2022 10:49 am

I actually have a few days to update the app.

Given the following items:
13_2,12_1,11_1,10_4,9_2,8_1,7_3,6_2,5_4,4_2
Underscore is the delimiter fore ach item.

What do you think is the fastest way to know if the first part of the items form a descending sequence?
So, somethink like the following items will be OK:
13,12,11,10,9,8,7,6,5,4
But these one are not OK:
13,11,12,10,9,8,7,6,5,4 -- bad order
13,12,11,10,10,9,8,7,6,5,4 -- duplicated value
13,12,11,9,8,7,6,5,4 -- missing value
I have several ideas of how to make it slowly, but the speed is really the most important criteia. Maybe it wll be faster with regex?

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by stam » Wed Sep 28, 2022 11:40 am

Don't think regex would help re-order your list, which is the main issue (missing or extra entries can be picked up instantly with 'number of items').

Actually i'm wondering why you don't just use an array for this instead of a hybridised list with each item being a couplet of values, which complicates things?

If you want to stick with the list i would suggest using a space instead of an underscore, so that you can sort by word 1 of each item.
There's no reason why your source list couldn't be 13 2,12 1,11 1,10 4,9 2,8 1,7 3,6 2,5 4,4 2 is there?

example:

Code: Select all

put"6 2,13 2,11 1,10 4,9 2,12 1,8 1,7 3,5 4,4 2"  into tCards
sort items of tCards descending numeric by word 1 of each
tCards now contains 13 2,12 1,11 1,10 4,9 2,8 1,7 3,6 2,5 4,4 2

If you want to check if the order is really a descending order in your source list, you can put this into a variable, sort the variable as above and if (tSource = tCards) is false, you'll instantly know the order was wrong...

HTH
S.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Wed Sep 28, 2022 12:40 pm

Reordering is not the issue here, as the sequence represents the actual order of cards in a pile (if I'm not mistaken).

Comparing a sorted sequence with the source doesn't work either, as this would not catch duplicates.

Here's what I would do:

Code: Select all

function checkSequence pSource
   replace "_" with space in pSource
   
   repeat with i = 1 to the number of items of pSource -1
      if word 1 of item i+1 of pSource is not word 1 of item i of pSource -1 then return false
   end repeat
   
   return true
end checkSequence
The function only needs to loop until it finds a "sequence-breaker", unless the whole pile is actually in sequence.

I think it works correctly, even with just one value as source, if one card is to be considered a "sequence". It's not a non-sequence at least... :)
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by stam » Wed Sep 28, 2022 1:21 pm

SWEdeAndy wrote:
Wed Sep 28, 2022 12:40 pm
Reordering is not the issue here, as the sequence represents the actual order of cards in a pile (if I'm not mistaken).
Hi Andy,
Zax's post suggests that's not the case, and that he's looking for descending order:
Zax wrote:
Wed Sep 28, 2022 10:49 am
But these one are not OK:
13,11,12,10,9,8,7,6,5,4 -- bad order

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Wed Sep 28, 2022 1:44 pm

Thanks for your quick answers :)
SWEdeAndy wrote:
Wed Sep 28, 2022 12:40 pm
the sequence represents the actual order of cards in a pile (if I'm not mistaken).
Yep.

I try to test if the game is won. Such a game can be considered as won:
bca.jpg

Andreas' function does the job.
stam wrote:
Wed Sep 28, 2022 11:40 am
Actually i'm wondering why you don't just use an array for this instead of a hybridised list with each item being a couplet of values, which complicates things?
It was a choice made at the very beginning, but I defined the delimiter as a global, so I can change it if it's not a good choice.

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Fri Oct 07, 2022 12:41 pm

0.31 is out.
Lots of optimizations and small bug fixes. The weird bug caused by too fast clicks is still present but occurs much less frequently. In addition, the repair of the board in the event of an error is more efficient.
Statistics and high-scores added.

bca30.jpg

Concerning "dumb" auto-moves, this also happened to me sometimes but I don't understand where the error comes from: I checked the algorithm and it is correct.

Mac OS: https://sw.ixoft.com/files/_OLD/Beleagu ... 31_OSX.zip
Windows: https://sw.ixoft.com/files/_OLD/Beleagu ... 31_win.zip
Linux: https://sw.ixoft.com/files/_OLD/Beleagu ... inux64.zip

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Fri Oct 07, 2022 7:16 pm

Cool! :D

But what happened to the card deck called "Default"? I liked that artwork more than the current "Classic" and "Castle special".

The statistics look great, but I experience some bugs:
BC.png
After playing 6 games and winning one, the stats said I had won 3. Then after several failed attempts, I won a second game; the stats still say 3 won, and the Top 10 list appears to be a Top 1 list. Except my last win had a better score than the one on the list...

Since the date at the top seems a bit random, I suspect there's some kind of old prefs stored somewhere, that need to be reset? But I can't find any? How do you store the stats?

When repairing the board, the count is reduced to 0 (logic, since the move history is cleared). But have you taken measures to save the move count value, so that if winning the game, the correct number of moves is summed? I haven't been able to test this yet, so just a thought. :)
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sat Oct 08, 2022 7:12 am

SWEdeAndy wrote:
Fri Oct 07, 2022 7:16 pm
After playing 6 games and winning one, the stats said I had won 3. Then after several failed attempts, I won a second game; the stats still say 3 won, and the Top 10 list appears to be a Top 1 list. Except my last win had a better score than the one on the list...

Since the date at the top seems a bit random, I suspect there's some kind of old prefs stored somewhere, that need to be reset? But I can't find any?
File -> Reset Preferences

In fact, I should have forced a reset of the preferences during the first launch of 0.3x version.
Concerning a "repaired" game, you are right: I forgot to manage the case in the statistics. I'll see what can be done in the next version.

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sat Oct 08, 2022 8:40 am

Zax wrote:
Sat Oct 08, 2022 7:12 am
File -> Reset Preferences
Ah, I had missed that menu option!

OK, I've reset prefs, played a few games and then won one. My stats are now eh... amazing... :lol:

BC2.png
BC2.png (29.18 KiB) Viewed 8323 times

Not that I want to spoil such a legendary winning ratio, but nevertheless looking forward to v0.32... :wink:

Oh, one more thing: After an auto-resize by the game, the set now correctly resizes up again when manually enlarging the window. But it doesn't stay that way. As soon as the next move is done, it goes back to (too) small again.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sat Oct 08, 2022 10:49 am

You're too good for the game, Andreas! :shock:

Zax
Posts: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by Zax » Sat Oct 08, 2022 12:24 pm

0.32 is out, thanks to Andreas.

Statistics bug should be fixed.
"dumb" auto-moves fixed.

Mac OS: https://sw.ixoft.com/files/_OLD/Beleagu ... 32_OSX.zip
Windows: https://sw.ixoft.com/files/_OLD/Beleagu ... 32_win.zip
Linux: https://sw.ixoft.com/files/_OLD/Beleagu ... inux64.zip

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Create a button's icon with a part of a big image? - Beleaguered Castle

Post by SWEdeAndy » Sat Oct 08, 2022 3:17 pm

Zax wrote:
Sat Oct 08, 2022 12:24 pm
Statistics bug should be fixed.
Unfortunately, it seems not. I deleted the previous version, installed the new one, saw that the stats were reset but did a manual reset anyway to be really sure. Then played 4 games that I had to give up. Stats looked correct so far.
Then I won one game, and the stats say I won 8 games (again), and have 160% won games...

Are the prefs/stats saved to a text file or similar somewhere?

Another bug: When using Check for updates, and there is one, the link to the download page is incorrect and gives a 403 error on your site. So the only way to get the latest version is currently here in this thread.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”