Turtle Challenge
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Turtle Challenge
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:
- -
[ I have an irreparably bust one of these glued to the wall of my school! ]
- -
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.
https://www.bebras.uk/index.php?action=content&id=41
Shades of:
- -
[ I have an irreparably bust one of these glued to the wall of my school! ]
- -
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.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
Obviously the first thing to do is generate an 'action board' (well, I don't know what else to call it):
- -
This takes snapshots of a field, names each snapshot sequentially, and positions it:
- -
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
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
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:
- -
These can be imported and positioned on the action board:
-
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:
- -
These can be imported and positioned on the action board:
-
- Attachments
-
- image resources.zip
- images
- (41.91 KiB) Downloaded 64 times
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
As can the money:
- -
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.
- -
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.
- Attachments
-
- coins.zip
- money images
- (18.66 KiB) Downloaded 65 times
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
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:
- -
- -
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
The next thing we have to consider is our codeblocks and how we might implement them:
- -
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.
- -
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.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
Let's start by looking at the MOVE codeblock:
- -
It contains 2 menus: a direction menu and a distance menu:
- -
- -
It contains 2 menus: a direction menu and a distance menu:
- -
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
The direction menu ONLY has 2 possibilities:
- -
This can easily be replicated in OXT with a drop-down menu:
- -
We can start by giving the drop-down menu (which I have called 'Direction') this sort of script:
This ensures that whichever direction is chosen it will be properly displayed.
- -
This can easily be replicated in OXT with a drop-down menu:
- -
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
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
If one wants to be extremely fancy one can lever the Unicode convention like this:
- -
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:
HOWEVER if one does not have a Unicode-compliant font containing the glyph range containing the downward pointing chevron the results are not good:
-
- -
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
-
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
Another way to provide a downward facing chevron is by assigning one of OXT's preset icons to the drop-down menu:
- -
The amount menu is a simple text field:
- -
- -
The amount menu is a simple text field:
- -
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
To start putting together the direction codeblock one needs a blank template image:
- -
Then the drop-down menu and the text field can be aligned on top of it:
- -
- -
Then the drop-down menu and the text field can be aligned on top of it:
- -
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
Now we should GROUP those 3 objects and call the GROUP 'tMOVE' as that will be our template direction codeblock:
- -
Let's give our template some simple code so we can move it to where we want:
-
- -
Let's give our template some simple code so we can move it to where we want:
-
https://richmondmathewson.owlstown.net/
-
- Posts: 107
- Joined: Sat Oct 16, 2021 5:05 pm
- Contact:
Re: Turtle Challenge
Richmond, please continue with this nicely done interesting post. Terry
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
Sorry: 2 things made me pause:
1. A bug in OXT Lite (now sorted out) to do with grouping).
2. I was ill.
1. A bug in OXT Lite (now sorted out) to do with grouping).
2. I was ill.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
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:
- -
- -
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
And another pause as the script:
in the "tMOVE" group still CRASHES the IDE.
-
Code: Select all
on mouseDown
grab me
end mouseDown
-
https://richmondmathewson.owlstown.net/
- tperry2x
- Posts: 2783
- Joined: Tue Dec 21, 2021 9:10 pm
- Location: Somewhere in deepest darkest Norfolk, England
- Contact:
Re: Turtle Challenge
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).
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).
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
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 . . .
- -
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.
Therefore, before proceeding I have to work out another way to effect code blocks . . .
- -
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.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
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)) . . .
- - -
I solved the problem . . .
I deleted the code in the GROUP:
and put this code into the codeblock image:
That was, frankly, an idea that annoyed me immensely that I had not thought of it sooner.
- - -
I solved the problem . . .
I deleted the code in the GROUP:
Code: Select all
on mouseDown
grab me
end mouseDown
Code: Select all
on mouseDown
grab group "tMOVE"
end mouseDown
- Attachments
-
- codeblock problem.oxtstack.zip
- (9.72 KiB) Downloaded 64 times
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 4239
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Turtle Challenge
I would rather you did NOT delete the 2 previous postings as some useful things can be learnt from them.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
After all the CRASH caused by the way I coded the group-grab was my fault, and not yours.
https://richmondmathewson.owlstown.net/
Who is online
Users browsing this forum: No registered users and 0 guests