Hello England

Teaching software development? Using LiveCode to build your curriculum? This is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Hello England

Post by richmond62 » Wed Oct 26, 2022 10:12 am

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.
Attachments
HWxample1.livecode.zip
Stack.
(138.88 KiB) Downloaded 121 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 12:30 pm

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

SparkOut
Posts: 2894
Joined: Sun Sep 23, 2007 4:58 pm

Re: Hello England

Post by SparkOut » Wed Oct 26, 2022 12:55 pm

"If the start falls into the bowl"
:roll:

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 1:02 pm

"If the start falls into the bowl"
Ha, Ha, ha: you made my day by pointing out my mistake.
-
MOD2.jpg

SparkOut
Posts: 2894
Joined: Sun Sep 23, 2007 4:58 pm

Re: Hello England

Post by SparkOut » Wed Oct 26, 2022 2:39 pm

Oh! I wasn't picking at you, I thought this was a snippet from the publication that got past proofreaders.
:oops:

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 2:47 pm

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
Attachments
HWxample2.livecode.zip
Stack.
(139.4 KiB) Downloaded 110 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 3:08 pm

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.
Attachments
HWxample3.livecode.zip
Stack.
(139.13 KiB) Downloaded 107 times
Last edited by richmond62 on Wed Oct 26, 2022 8:33 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 3:10 pm

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. :?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 3:21 pm

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 7099 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"
Last edited by richmond62 on Sat Oct 29, 2022 7:42 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 3:33 pm

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.
Attachments
left & right.livecode.zip
Stack.
(11.33 KiB) Downloaded 123 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Wed Oct 26, 2022 5:41 pm

Now we need to learn about intersect . . .

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Thu Oct 27, 2022 8:19 am

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Thu Oct 27, 2022 11:24 am

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.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Thu Oct 27, 2022 11:30 am

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9746
Joined: Fri Feb 19, 2010 10:17 am

Re: Hello England

Post by richmond62 » Thu Oct 27, 2022 11:40 am

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.

Post Reply

Return to “Teaching with LiveCode”