Page 1 of 2
Turtle Challenge
Posted: Wed Jun 26, 2024 7:47 am
by richmond62
As some sort of educator I am always getting vaguely stimulating stuff in my email in-box; and this was slightly more stimulating that some insofar as it is something that lends itself to imitation in OXT rather more than some other things:
https://www.bebras.uk/index.php?action=content&id=41
Shades of:
-

- tortuga.jpg (8.01 KiB) Viewed 6002 times
-
[ I have an irreparably bust one of these glued to the wall of my school! ]
-

- Screenshot 2024-06-26 at 10.46.13.png (158.12 KiB) Viewed 6001 times
-
Before I proceed any further I should like to state that I have grave misgivings re code blocks, and am NOT treating this exercise as a way of promoting code blacks, but as an exercise to show how this sort of thing can be imitated in OXT.
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 7:53 am
by richmond62
Obviously the first thing to do is generate an 'action board' (well, I don't know what else to call it):
-

- Screenshot 2024-06-26 at 10.50.35.png (222.9 KiB) Viewed 6000 times
-
This takes snapshots of a field, names each snapshot sequentially, and positions it:
Code: Select all
on mouseUp
put 1 into BOARD
put 1 into KOLUMN -- column counter
put 1 into RROW -- row counter
repeat until BOARD > 25
put BOARD into fld "f1"
import snapshot from fld "f1"
set the name of the last image to ("x" & BOARD)
set the top of the last image to (KOLUMN * 120)
set the left of the last image to (RROW * 120)
add 1 to KOLUMN
if KOLUMN > 5 then
put 1 into KOLUMN
add 1 to RROW
end if
add 1 to BOARD
end repeat
end mouseUp
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 8:01 am
by richmond62
There are various 'artefacts' in the Turtle Challenge.
While I feel perfectly happy about copying the functionality of Turtle Challenge, I do NOT feel comfortable copying their images, so I downloaded free resources from the internet:
-

- Screenshot 2024-06-26 at 11.11.51.png (114.45 KiB) Viewed 5999 times
-
These can be imported and positioned on the action board:
-

- Screenshot 2024-06-26 at 11.18.23.png (167.59 KiB) Viewed 5997 times
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 8:31 am
by richmond62
As can the money:
-

- Screenshot 2024-06-26 at 11.29.47.png (211.19 KiB) Viewed 5996 times
-
You will notice that by the way I generate my action board the numbering is vertical rather than horizontal, as in the original: I do not consider this important; if you do you will have to modify the board generation script.
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 8:34 am
by richmond62
I also do not like the way the pond on my action board does not extend across 2 squares as in the original: this can be easily adjusted:
-

- compare1.png (76.9 KiB) Viewed 5995 times
-

- Screenshot 2024-06-26 at 11.40.07.png (304.07 KiB) Viewed 5994 times
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:05 am
by richmond62
The next thing we have to consider is our codeblocks and how we might implement them:
-

- Screenshot 2024-06-26 at 12.01.55.png (26.31 KiB) Viewed 5992 times
-
Luckily the xTalk concept of GROUPS is at hand to help us.
To understand this we should take a codeblock apart into its components; recreate those components in xTalk and then put them together in xTalk.
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:13 am
by richmond62
Let's start by looking at the
MOVE codeblock:
-

- Screenshot 2024-06-26 at 12.05.49.png (29.49 KiB) Viewed 5992 times
-
It contains 2 menus: a
direction menu and a
distance menu:
-

- direction.png (9.34 KiB) Viewed 5992 times
-

- amount.png (6.16 KiB) Viewed 5992 times
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:14 am
by richmond62
The
direction menu ONLY has 2 possibilities:
-

- Screenshot 2024-06-26 at 12.09.54.png (23.16 KiB) Viewed 5993 times
-
This can easily be replicated in OXT with a drop-down menu:
-

- Screenshot 2024-06-26 at 12.17.10.png (18.94 KiB) Viewed 5993 times
-
We can start by giving the drop-down menu (which I have called 'Direction') this sort of script:
Code: Select all
on menuPick SX
set the label of me to SX
end menuPick
This ensures that whichever direction is chosen it will be properly displayed.
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:30 am
by richmond62
If one wants to be extremely fancy one can lever the Unicode convention like this:
-

- Screenshot 2024-06-26 at 12.27.19.png (8.46 KiB) Viewed 5991 times
-
The decimal encoding of the hexadecimal 1F893 is 129171, and one can use this to make one's drop-down menu look a whole lot more professional:
Code: Select all
on menuPick SX
set the label of me to (SX && numToCodePoint(129171))
end menuPick
HOWEVER if one does not have a Unicode-compliant font containing the glyph range containing the downward pointing chevron the results are not good:
-

- Screenshot 2024-06-26 at 12.34.06.png (18.18 KiB) Viewed 5990 times
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:38 am
by richmond62
Another way to provide a downward facing chevron is by assigning one of OXT's preset icons to the drop-down menu:
-

- Screenshot 2024-06-26 at 12.36.05.png (116.15 KiB) Viewed 5989 times
-
The
amount menu is a simple text field:
-

- Screenshot 2024-06-26 at 12.40.12.png (16.53 KiB) Viewed 5989 times
-
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 9:46 am
by richmond62
To start putting together the
direction codeblock one needs a blank template image:
-

- moveBACK.png (13.33 KiB) Viewed 5988 times
-
Then the
drop-down menu and the
text field can be aligned on top of it:
-

- Screenshot 2024-06-26 at 12.48.00.png (81.47 KiB) Viewed 5988 times
-

- Screenshot 2024-06-26 at 12.48.49.png (75.95 KiB) Viewed 5988 times
Re: Turtle Challenge
Posted: Wed Jun 26, 2024 1:20 pm
by richmond62
Now we should GROUP those 3 objects and call the GROUP 'tMOVE' as that will be our template direction codeblock:
-

- Screenshot 2024-06-26 at 16.16.33.jpg (317.38 KiB) Viewed 5986 times
-
Let's give our template some simple code so we can move it to where we want:
-

- Screenshot 2024-06-26 at 16.16.33.jpg (317.38 KiB) Viewed 5986 times
Re: Turtle Challenge
Posted: Mon Jul 01, 2024 7:58 pm
by TerryL
Richmond, please continue with this nicely done interesting post. Terry
Re: Turtle Challenge
Posted: Tue Jul 02, 2024 8:27 am
by richmond62
Sorry: 2 things made me pause:
1. A bug in OXT Lite (now sorted out) to do with grouping).
2. I was ill.
Re: Turtle Challenge
Posted: Tue Jul 02, 2024 8:34 am
by richmond62
I have decided to shrink the codeblock images to 65% of their previous size so there is a bit more space available on the stack:
-

- Screenshot 2024-07-02 at 11.31.24.png (296.89 KiB) Viewed 5898 times
-

- moveBACK65.png (11.36 KiB) Viewed 5898 times
Re: Turtle Challenge
Posted: Tue Jul 02, 2024 8:41 am
by richmond62
And another pause as the script:
Code: Select all
on mouseDown
grab me
end mouseDown
in the "tMOVE" group still CRASHES the IDE.
-

- Screenshot 2024-07-02 at 11.44.21.png (272.51 KiB) Viewed 5899 times
Re: Turtle Challenge
Posted: Tue Jul 02, 2024 8:52 pm
by tperry2x
Just going to try your stack, but I can't try it on MacOS 12 (or 15) as I don't have a mac that will run either of them here...
Edit: your stack crashes on Linux too, and it also crashes in LCC 9.6.3 on Linux - so it's not a bug specific to OXT Lite.
I've amended it a bit
here.
(note: I'll delete these posts if that's okay, when you are ready - so this section just shows your "Turtle Challenge" with none of these comments).
Re: Turtle Challenge
Posted: Wed Jul 03, 2024 8:07 am
by richmond62
So: there is a
conflict of interests insofar as a
group containing a
drop-down menu (which contains an in-built [hence invisible]
mouseDown command) mucks up any other
mouseDown command inwith the group: hence my code block causing the IDE to crash.
Therefore, before proceeding I have to work out another way to effect code blocks . . .
-

- diagram.png (16.29 KiB) Viewed 5870 times
-
A mouseDown in area #1 allows the group to be moved without any problems.
A mouseDown in area #2 (the drop-down menu) crashes the IDE.
Re: Turtle Challenge
Posted: Wed Jul 03, 2024 8:44 am
by richmond62
So, having had a "dark night of the soul" (meaning going down to the fridge and grabbing a can of beer at 4 in the morning and fooling around with a pencil and paper (always, always, always got to be better than turning a computer on during the
Brahma Muhurta)) . . .
-

- Screenshot 2024-07-03 at 11.38.44.png (62.71 KiB) Viewed 5868 times
-

- Screenshot 2024-07-03 at 11.42.41.png (686.91 KiB) Viewed 5868 times
-
I solved the problem . . .
I deleted the code in the GROUP:
Code: Select all
on mouseDown
grab me
end mouseDown
and put this code into the codeblock image:
Code: Select all
on mouseDown
grab group "tMOVE"
end mouseDown
That was, frankly, an idea that annoyed me immensely that I had not thought of it sooner.
Re: Turtle Challenge
Posted: Wed Jul 03, 2024 8:50 am
by richmond62
I'll delete these posts if that's okay, when you are ready - so this section just shows your "Turtle Challenge" with none of these comments
I would rather you did NOT delete the 2 previous postings as some useful things can be learnt from them.
After all the CRASH caused by the way
I coded the group-grab was my fault, and not yours.
