Page 1 of 2

Hello England

Posted: Wed Oct 26, 2022 10:12 am
by richmond62
There is a 'mag' pumped out by the Raspberry Pi foundation (had 2 'things' published in it a while ago)
aimed at English Primary School teachers (and which, if one turns one's filters on, can yield some useful things)
and their latest offering is this:
-
https://helloworld.raspberrypi.org/book ... ng_content
-
Which is available as a free download . . .

and, on page 71 there is this:
-
HereItIs.jpg
-
which is about as basic as things get (and, as such, might not be a bad idea to start things off with).

So, here's a blank as I would set it up for the 8-11 year old brigade:
-
blank.jpg
-
and I wish you all you wish yourself . . . :shock:

My "cut" will follow later.

Re: Hello England

Posted: Wed Oct 26, 2022 12:30 pm
by richmond62
One of the things that 'ticks me off' about this is that I feel that
children will rapidly lose interest as both the movements of the 'falling stars'
and the 'basket' are random, so there is no game involved and no skill.

So, I would modify things a bit:
-
MOD.jpg

Re: Hello England

Posted: Wed Oct 26, 2022 12:55 pm
by SparkOut
"If the start falls into the bowl"
:roll:

Re: Hello England

Posted: Wed Oct 26, 2022 1:02 pm
by richmond62
"If the start falls into the bowl"
Ha, Ha, ha: you made my day by pointing out my mistake.
-
MOD2.jpg

Re: Hello England

Posted: Wed Oct 26, 2022 2:39 pm
by SparkOut
Oh! I wasn't picking at you, I thought this was a snippet from the publication that got past proofreaders.
:oops:

Re: Hello England

Posted: Wed Oct 26, 2022 2:47 pm
by richmond62
The first step is to set up potential positions the 'star' (here it is a sweetie) can drop from.

AS the stack is 1000 points wide we can set up potential start positions at intervals of 50 points across
the top of the stack, BUT we do NOT want the sweetie dropping at either edge of the stack.

So we need to slice up the stack into equal slices of 50 points:
-
sliced.jpg
-
To address these positions we need to have a random number somewhere between 1 and 19 and then do this:

Code: Select all

put random(18) into RX
put RX * 50 into POZ
then we can use POZ as the horizontal position of our sweetie.
-
Poz.jpg
-
In our finished game we will make sure the sweetie's starting position is above the top of the stack window so it is not initially visible.

Code: Select all

on mouseUp
   put random(18) into RX
   put RX * 50 into POZ
   set the location of image "sweetie" to POZ, -100
end mouseUp

Re: Hello England

Posted: Wed Oct 26, 2022 3:08 pm
by richmond62
I have now removed those 19 lines that I put there just to show where the 'slices' are to be.

Now we can work on the script that will make the sweetie fall out of the sky:
-
move1.jpg
-

the line:

Code: Select all

wait 3 ticks
is there so there are intervals in which the bowl can be moved.

Re: Hello England

Posted: Wed Oct 26, 2022 3:10 pm
by richmond62
Oh! I wasn't picking at you
Well, that's a pity, because with a simple mistake like that I deserved to be picked on. :?

Re: Hello England

Posted: Wed Oct 26, 2022 3:21 pm
by richmond62
Now we can work on the script that can shift the bowl left and right in an attempt to catch the falling sweetie.
-
arrow-keys.png
arrow-keys.png (20.24 KiB) Viewed 7102 times
-
We will use the RIGHT and the LEFT arrow keys on our keyboards to make the bowl move.

in LiveCode we can detect if the LEFT arrow key has been pressed with:

Code: Select all

on arrowKey "left"
and, if the RIGHT arrow key has been pressed with:

Code: Select all

on arrowKey "right"

Re: Hello England

Posted: Wed Oct 26, 2022 3:33 pm
by richmond62
LnR.jpg
-
You will see that we ask if an arrow key has been pressed once, and then we ask if it is the LEFT or the RIGHT key:

Code: Select all

on arrowKey AK
   if AK is "right" then
      put item 1 of the location of image "bowl" into LR
      put item 2 of the location of image "bowl" into UD
      set the location of image "bowl" to (LR + 25), UD
   else
      put item 1 of the location of image "bowl" into LR
      put item 2 of the location of image "bowl" into UD
      set the location of image "bowl" to (LR - 25), UD
      end if
   end arrowKey
The script is saved in the cardScript as we want to detect if an arrow key is pressed even if the START button is not pressed.

Re: Hello England

Posted: Wed Oct 26, 2022 5:41 pm
by richmond62
Now we need to learn about intersect . . .

Re: Hello England

Posted: Thu Oct 27, 2022 8:19 am
by richmond62
It is NOT a bad idea to STOP the bowl going away at either the left or the right edge of the stack window:
-
Screen Shot 2022-10-27 at 10.21.24 AM.png
-

Code: Select all

on arrowKey AK
   if AK is "right" then
      put item 1 of the location of image "bowl" into LR
      put item 2 of the location of image "bowl" into UD
      if (LR + 25) < 1000 then
         set the location of image "bowl" to (LR + 25), UD
         end if
   else
      put item 1 of the location of image "bowl" into LR
      put item 2 of the location of image "bowl" into UD
      if (LR - 25) > 0 then
         set the location of image "bowl" to (LR - 25), UD
         end if
      end if
   end arrowKey

Re: Hello England

Posted: Thu Oct 27, 2022 11:24 am
by richmond62
We must be careful to insert with messages after our wait command so the computer will pick up our arrow keys presses during the animation loop for the sweetie:

Code: Select all

on mouseUp
   put random(18) into RX
   put RX * 50 into POZ
   set the location of image "sweetie" to POZ, -100
   put 5 into XXX
   repeat until XXX > 860
      put item 2 of the loc of image "sweetie" into UD
      add 10 to UD
      add 10 to XXX
      set the location of image "sweetie" to POZ, UD
      wait 2 ticks with messages
   end repeat
   if intersect(image "sweetie", image "bowl", 5) then
      add 3 to field "fSCORE"
      set the visible of image "WD" to true
      wait 30 ticks
      set the visible of image "WD" to false
      send "mouseUp" to button "START"
   else
      set the visible of image "GO" to true
   end if
   set the location of image "sweetie" to POZ, -100
end mouseUp
you will see how intersect comes into play to check whether the sweetie is ending up 'in' the owl.

Re: Hello England

Posted: Thu Oct 27, 2022 11:30 am
by richmond62
As LiveCode is WYSIWYG it is always handy to have a tester around to try out your game,
and tell you what's wrong with it:
-
tester.jpg
-
My tester suggested some visual feedback, so we popped 2 images together almost 100% inwith LiveCode:
-
Screen Shot 2022-10-27 at 1.35.15 PM.png

Re: Hello England

Posted: Thu Oct 27, 2022 11:40 am
by richmond62
My tester told me that, because the bowl and the sweetie were too large, the game was too easy,
so we resized both of them to half of their original sizes:
-
Screen Shot 2022-10-27 at 1.38.54 PM.png
-
The article cited states:

"It can sometimes be difficult to distinguish between the levels of coding/building and running the project,
as learners should be repeatedly cycling through coding and running, to check that their program is working."

LiveCode lends itself particularly well to cycling through coding and running.