Python Projects

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: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Sun Nov 07, 2021 6:34 pm

blueBOT45.jpg
-
A Blue-Bot can be controlled from an Android phone or tablet, although
it only permits 45 degree turns.

https://www.tts-international.com/blue- ... 15269.html
-
The Valiant Roamer 2 allows turns of any amount from 1 degree upwards.

http://www.valiant-technology.com/uk/pa ... p?cat=8id1
-
vR2.jpeg
vR2.jpeg (4.15 KiB) Viewed 12732 times
-
although they are both fairly expensive.

Blue-Bot €102, Roamer 2 €127

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Sun Nov 07, 2021 6:54 pm

ALL the Turtle graphics exercises can be performed with my NLCT stack:
-
SShot 2021-11-07 at 19.52.14.png
-
OBVIOUSLY those control buttons can be exchanged for others.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Sun Nov 07, 2021 7:08 pm

The second work sheet concerns itself with Turtle graphics (via Python) again.

I am going to skip that and move to: Level three: hangman (activity sheet):
-
SShot 2021-11-07 at 19.58.23.png
-
This introduces the concept of RANDOM, although in a way that slightly misses the mark to my mind
as RANDOM in computers involves numbers.

We can easily illustrate this in LiveCode while developing a Hangman program:
-
SShot 2021-11-07 at 20.06.49.png
-

Code: Select all

on mouseUp
   put random(5) into RLINE
   put line RLINE of fld "fWORDS" into fld "fRWORD"
end mouseUp
Attachments
Hangman.livecode.zip
Here's the stack.
(1.06 KiB) Downloaded 141 times
Last edited by richmond62 on Tue Nov 09, 2021 2:04 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Mon Nov 08, 2021 1:20 pm

Now we need a "shadow" field:
-
SShot 2021-11-08 at 14.18.28.png
-

Code: Select all

on mouseUp
   put empty into fld "fRWORD2"
   put random(5) into RLINE
   put line RLINE of fld "fWORDS" into fld "fRWORD"
   put the number of chars in fld "fRWORD" into LETTERNUM
   put 1 into COUNTUP
   repeat until COUNTUP > LETTERNUM
      put "-" after fld "fRWORD2"
      add 1 to COUNTUP
   end repeat
end mouseUp
Obviously we now have to hide the field with the visible word.
Attachments
Hangman 2.livecode.zip
Next step.
(1.21 KiB) Downloaded 142 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Mon Nov 08, 2021 3:11 pm

It is now time to supply the pictorial element in a way so that each component
can be made visible each time our end-user guesses a letter incorrectly:
-
SShot 2021-11-08 at 16.08.02.png
-
Each component is a graphic object sequentially named r1 . . . r3.
Attachments
Hangman 3.livecode.zip
Here we go.
(1.54 KiB) Downloaded 139 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Mon Nov 08, 2021 4:14 pm

We had better hide the 'gallows' graphics, so I have
popped this into the cardScript:

Code: Select all

on preOpenCard
   put 1 into GALLOWS
   repeat until GALLOWS > 13
      set the visible of grc ("r" & GALLOWS) to false
      add 1 to GALLOWS
   end repeat
end preOpenCard
If you feel that set the visible might be a bit "complicated" for children
you could change the script to:

Code: Select all

n preOpenCard
   put 1 into GALLOWS
   repeat until GALLOWS > 13
      hide grc ("r" & GALLOWS)
      add 1 to GALLOWS
   end repeat
end preOpenCard
I tend to avoid HIDE as it does NOT indicate that things have a VISIBLE property.
Last edited by richmond62 on Wed Nov 10, 2021 9:26 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Mon Nov 08, 2021 4:29 pm

Let's run off some alphabetic tiles:
-
SShot 2021-11-08 at 17.28.02.png
Attachments
Button Maker.livecode.zip
Here it is.
(1.22 KiB) Downloaded 148 times
Last edited by richmond62 on Wed Nov 10, 2021 9:26 am, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Tue Nov 09, 2021 1:12 pm

SShot 2021-11-09 at 14.10.13.png
-
SShot 2021-11-09 at 14.10.50.png
-
The letter buttons involve ridiculously convoluted logic . . .

. . . if anyone can come up with some simpler code that would be great.
Attachments
Hangman 4.livecode.zip
Here's the stack.
(124.03 KiB) Downloaded 138 times

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 327
Joined: Sun Apr 15, 2012 1:17 am
Location: USA
Contact:

Re: Python Projects

Post by Newbie4 » Tue Nov 09, 2021 5:54 pm

Without looking at the logic or the code in detail, you could strip out the common code on each button and put it on the card or stack. Then on each button, call that common routine/command with the appropriate letter that is on the button.

Then you could easily play with the code to simplify it.
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Tue Nov 09, 2021 5:58 pm

you could strip out the common code on each button and put it on the card or stack
of course. 8)

This would be a lesson for children at a later stage.

What is needed at the moment is some sort of simplfication of this:

Code: Select all

on mouseUp
   put empty into fld "ST"
   put 1 into CHEQUE
   put fld "fRWORD" into LEX
   repeat until char CHEQUE of LEX is empty
      put (char CHEQUE of LEX) into fld "fVOX"
      if fld "fVOX" contains "a" then
         put "a" into char CHEQUE of fld "fRWORD2"
         put "X" into fld "ST"
      end if
      add 1 to CHEQUE
   end repeat
   if fld "fRWORD2" contains "a" then
      --do nix
      else
      put 1 into STICK
      repeat until STICK > 13
         if the vis of grc ("r" & STICK) is true then
            --do nix
         else
            if fld "ST" is empty then
               put "X" into fld "ST"
               set the vis of grc ("r" & STICK) to true
            end if
         end if
         add 1 to STICK
      end repeat
   end if
set the vis of me to false
if the vis of grc "r13" is true then
   set the vis of img "dead" to true
end if
if fld "fRWORD2" contains "-" then
   --do nix
else
   set the vis of img "win" to true
end if
end mouseUp
as this was 'built' up by a process of trial and error, which, while, possibly, giving a clever psychologist
some sort of key to the workings of my mind, may not best suit children who are trying to understand
what on earth is going on, or a teacher who has to explain it.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Tue Nov 09, 2021 7:26 pm

SShot 2021-11-09 at 20.24.15.png
-
Drawing a grid seems all a bit redundant given LiveCode's WYSIWYG GUI . . .

Given what that document shows why don't we just have a 3 by 3 grid of textFields?
-
SShot 2021-11-09 at 20.41.33.png
-
each textField contains this code:

Code: Select all

on mouseUp
   if the shiftKey is down then
      put "O" into me
   else
      put "X" into me
   end if
end mouseUp
Attachments
Nowts & Crosses.livecode.zip
Here we go.
(7.75 KiB) Downloaded 133 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Tue Nov 09, 2021 7:49 pm

Here is where we see that LiveCode's in-built visual environment should
wins hands down over Python's "create everything from the utmost primitives"
approach:
-
SShot 2021-11-09 at 20.45.53.png
-
SShot 2021-11-09 at 20.46.14.png
-
SShot 2021-11-09 at 20.46.24.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Tue Nov 09, 2021 7:52 pm

SShot 2021-11-09 at 20.46.36.png
-
SShot 2021-11-09 at 20.47.01.png
-
While LiveCode's in-built visual environment allows us to leapfrog
some pretty tedious stuff, what it just does not do is stop us from
having to deal with the game mechanics of the game.

And that is how things should be, as pupils will learn far more from
the game mechanics than they will ever learn from teaching a computer to
draw a grid on-screen.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Wed Nov 10, 2021 8:00 am

The problem with the Nowts & Crosses stack is that one can replace an X or a O
with another right mouse click: this needs to be prevented:
-

Code: Select all

on mouseUp
   if fld "f5" is empty then
      if the shiftKey is down then
         set the textColor of fld "f5" to red
         put "O" into me
      else
         set the textColor of fld "f5" to black
         put "X" into me
      end if
   end if
end mouseUp
-
The code has been modified in 2 ways:

1. It checks if the field is empty, and if it is NOT a symbol will NOT be entered.

2. It enters a red O or a black X.
-
SShot 2021-11-10 at 8.55.30.png
-
Even if nothing else this should prove how quickly in LiveCode, unlike in Python, we can arrive at a mockup/prototype
which can then be used to develop our program.

I can well remember "pissing about" with paper and pencil under the staircase in my house in Al Ain in 1989
trying to work out something because I was NOT able to pull up a quick-and-dirty visual thing on the screen.
-
BeebB.jpg
BeebB.jpg (9.62 KiB) Viewed 12375 times
Attachments
Nowts & Crosses 2.livecode.zip
(7.92 KiB) Downloaded 138 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Python Projects

Post by richmond62 » Wed Nov 10, 2021 8:24 am

Here's my Master's degree thesis from 18 years ago that explores prototyping in LiveCode
(then called Runtime Revolution) extensively:

https://www.dropbox.com/s/aknlqyovmke61 ... f.zip?dl=0

Post Reply

Return to “Teaching with LiveCode”