[Microbit-Python] Sky.py Plz make it bettter

Jim Mussared jim at groklearning.com
Thu Dec 15 16:52:05 EST 2016


hi Sven,

Two main things would help you for this program:

1 - Naming the variables based on what they actually are - instead of
'H', call it 'stars'.

2 - Lists get a bit difficult when you have to remember what each of
the individual elements are for. This is exactly what classes are
designed for. Also this helps you with #1 - because you can name each
of the things.

I've attached an example.

There's also something quite subtle in this program which is the way
the display.clear() changes the behaviour from just having the stars
fade in or out, but instead every 15 frames it resets back down to a
single star showing. (Which is quite a neat effect but not what you
described -- the joys of graphics programming :D )

Jim

On 16 December 2016 at 05:08, Sven Turnau via Microbit
<microbit at python.org> wrote:
> Hello.
> I'm not good in teaching, but I have done my best.
> There is a Sky (  5x5 ) Starplaces and
> H (must be tuned H << 25) stars randomly put on the Sky.
> There is a Rest of Lifetime ( N[4] ) for each Star
> and current Brightness  N[2]  (0..9) for each Star.
> The method correct() corrrect the current values
> for each Star.
>    I will be happy if this program will be useful
> for teaching.
>   The program is Debugged on the Micro:Bit board.
> If someone can do it better I will be happy to receive
> a copy of the program.
> Bye.
>
>
> _______________________________________________
> Microbit mailing list
> Microbit at python.org
> https://mail.python.org/mailman/listinfo/microbit
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sky.py
Type: text/x-python
Size: 574 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/microbit/attachments/20161216/55ffeddf/attachment.py>


More information about the Microbit mailing list