Tag Archives: scratch

Python Project and CCOW Week 6 reflection

What?

During week 4, I took a good look at my multiple motivations for taking part in CCOW.  They were:

1)  I want to master SCRATCH so that I can better teach it to my students, and so  that I know more of it’s potential uses (particularly in the elementary grades that I teach).

2) I want to learn how to code again… not  just as a subject to teach but as a creative outlet for myself.  

3)  I want to read more about and reflect upon Constructivist principles in my teaching and learning.  

Given these 3 objectives here is a first try at framing a project idea:

I want to learn to code.  I would make the leap from Scratch to Python, which is a more multi-purpose language.  I could use it to code for the web or to make apps for my handy android phone.  So…  I will try to use a ‘How to code in python’ manual  as a guide to create a game in scratch

1) I want to build upon my experience using Scratch to teach myself how to Code in Python.

2) I want to document my personal experience and explore how I can help my students make the transition from SCRATCH to real-world programming.

 

So what?

I found some great online resources for teaching yourself scratch (mostly geared at children).  The ones I used most were

I played with a variety of python IDEs (Integrated development environments) before settling upon pyscripter for windows as one that works for me.

I typed, debugged, debugged, debugged, modified, and debug several python programs from the above ebooks and tutorials.

I recreated a starfield simulation created in python by codeNtronix into a scratch program.

I thought, reflected and wrote lots and lots and lots and lots and lots and lots.

Now what?

I want to continue monkeying with python so that I can gain enough proficiency that next time I say, “Someone ought to create an app, program or plugin to do…”,  I might attempt to be that someone.

I am considering starting a lunchtime programming club at my elementary school as an extension to the lessons in SCRATCH I have taught as one of the schools Library&Technology teachers.

 

Thank you to the Creative Computing Online Workshop team for providing such a wonderful opportunity for professional development.

Oh-the-hue-manatee-CI5N

There are Many Reasons to Learn to Program

In the above video from a variety of celebrities make a case for why programming should be taught to all children.  It is worthwhile to watch the full 10 minute video at Code.org.  Code.org also offers links to a variety of learn to program resources, including Scratch.

During this project to transition from Scratch to learning to program in Python,  Madeline Bishop has twice made comments on my post suggesting that my journey moving from scratch to python would help students wishing to pursue career.  She asked:

Do you have any idea of how many kids transition from Scratch into another language?  How many go on to have IT career?

My first reactions were– I don’t know  and I don’t really care.  But this comes off as blunt and doesn’t fully explain my thoughts on teaching myself how to program, or teaching children how to program.

To explain, I have to tell a little bit about myself-  I am a singer- songwriter, I play guitar and bass, I am a podcaster, blogger and have dabbled with creating websites since the early web. I dabble with photography and video. I was an early volunteer for Librivox.org recording public domain audiobooks.  I am a fan and proponent of open source software and make liberal use of public domain and creative commons media.  And I am a slow but persistent home handyman– I told my wife I am restoring our house on the 21 year plan (7 years in and it is starting to look quite nice).

As a regional children’s entertainer and folk songwriter, I have long become accustomed to well meaning questions of “So when can you quit your day job?”  The answer is “Never”.  But I derive immense pleasure from writing and sharing my music with others.  When I get the odd paying gig, it helps subsidize my gear buying habit. But I derive far more value from all my creative endeavors than just monetary value.  I think one of the greatest values is that I approach the world as a creator– rather than a consumer: of music, of media.

So learning to code for me is another creative outlet.  For me it is a liberal art… not just a means to a career path.  I found an article that develops this idea better than I can explain it:  Why Everyone Should Learn to Program by Dan Haggard.  In it, he explains how teaching himself to program in python has enabled him to do his work as a university administrator more efficiently.  Let me share just a brief snippet that gets to the heart of his argument:  (emphasis is all mine)

Given the relative ease in learning the basics of programming in scripting languages like Python, the time has come to challenge the assumption that programming is a specialisation.  If you need an analogy:  is learning to read and write in a spoken language like English – a specialisation?  No, it’s a fundamental tool needed to navigate your contemporary existence.  It’s easy enough to learn that you devote some of your early years to the task – and then it stays with you for life.  You could go on to specialise in language use.  Maybe you’ll go on to become a writer.  But you don’t need to specialise for your language skills to provide you with an incredible level of life-improvement.  Well – so to with programming.

What’s more – I now feel cured of an affliction I never realised I had.  If I had to name this affliction, I’d call it –defaultism.  Always did I just default to the way of things as it was handed to me.  Now I look at every aspect of my life with a hacker’s eye.  How can I free myself of this task? – is the question now at the forefront of my mind at all times.  There is no need to throw out every interface with which we are presented.  If it fits our needs and desires then fine.  But how often do you subvert your own desires and needs because of the constraints imposed by the limitations of the interfaces with which you have been bequeathed?

I also found a nice contrasting view by Jeff Attwood at Coding Horror entitled: Please Don’t Learn to Code.  Atwood’s key arguments centre around the idea that skilled programmers do not just produce lines of code.  The are problem solvers who through years of experience develop certain ways of approaching and solving problems.  He writes:

Look, I love programming. I also believe programming is important … in the right context, for some people. But so are a lot of skills. I would no more urge everyone to learn programming than I would urge everyone to learn plumbing. That’d be ridiculous, right?

In the final paragraphs of his article, Atwood seems to come closer to what I have been getting at:

The general populace (and its political leadership) could probably benefit most of all from a basic understanding of how computers, and the Internet, work. Being able to get around on the Internet is becoming a basic life skill, and we should be worried about fixing that first and most of all, before we start jumping all the way into code.

Please don’t advocate learning to code just for the sake of learning how to code. Or worse, because of the fat paychecks. Instead, I humbly suggest that we spend our time learning how to …

  • Research voraciously, and understand how the things around us work at a basic level.
  • Communicate effectively with other human beings.

These are skills that extend far beyond mere coding and will help you in every aspect of your life.

Both articles suggest that knowing how computers and programming work are a life-skill rather than just a career-path.  They teach us a certain approach to problem solving and how to think.

Back to the initial question of how does my Scratch help kids transition to an IT career.  I still don’t know.  But I have found out through my readings and learning a bit about Python, that Python is a great first or second programming language that allows someone lots of opportunity to explore a variety of styles of programming and almost limitless applications: whether it be making games, applications for the web, mobile apps, or complex scientific mathematics.   So yes, I guess it could be a first step to exploring an IT career,  or the first step to becoming a creator rather than consumer.  I find the latter idea much more compelling.

SeaCow-peacenik1-flickr

Photo by peacenik1 on flickr

CCOW Week 5 Wrapup

 

SeaCow- Fritzfranz Fride- flickr

This week I immersed myself in learning the basic principles, structure and commands of Python, so I did not do many of the week’s optional activities.  Here is a summary of how I approached week 5.

Help with Scripts:  I went on to the Help with Scripts discussion forum on the Scratch website a couple of times and read through the posts but I did not find any posts where I could give specific, constructive help that someone else had not already answered better.  Pro-tip:  When asking for help on a forum have a specific question in mind, and give as much detail as you can about the difficulties you are encountering.

Hardware and Extensions:   I did not do anything with this activity other than to think to myself, “Gee whiz there are a lot of neato gadgets that you can interact with using scratch”.

Unfocus Group:  I greatly enjoyed this activity but I ended up having an unfocus group of one.  I sent out emails to a musician friend who is also an open-source advocate and programmer, another tech crazy elementary teach in Nebraska, and a childhood friend who I learned to code with when we were 13 or 14.  Only Brad, my childhood friend was able to take some time  with me to discuss my project.  Unlike me, Brad continued to explore computer programming throughout his life.  He is a freelance programmer and database designer who now lives in northern Minnesota.  We had a wide ranging skype chat that meandered in the manner of  conversations between old friends.

Brad was fascinated by the concept of SCRATCH as a programming language to teach programming.   He also gave me several suggestions about choosing an Integrated Development Environment (IDE) including Eclipse (which is free and open source) and JetBrains, which is a commercial product but it has several cheaper or free options for teachers or open-source projects.  Brad’s point was if you choose get a multi-language, full-featured IDE, then you don’t need to relearn your programming environment every time you have a desire or need to learn a new programming language.

As I am writing this Brad popped up in my skype window… (I love years long, asynchronous text conversations).   He writes:

[10:47:50 AM] Brad: Heh, of course, there is a good argument to be made that no-one appreciates what an IDE does for them until they first use a text-based editor.  Notepad++ is a very nice text editor and has all the hooks into any language you want to use, plus user-customizable language settings too.  So maybe the need to pick an IDE is not as great as the need to just simply starting to build something.

I have used Notepad++ for years when I need to directly work in html code.  I have used it during my python explorations and it is very effective at color coding and indenting python code.  It does not have an integrated python interpreters or debuggers so you have to run your program within python or another IDE.  Otherwise it is a fantastic editor for almost any language or situation when you have to directly edit or write code.

Activity Extension:  I looked at the templates for making a Scratch card, but decided to devote more time to my Python Project instead.

Workshop Project: Reporting Out and Checking In 

Here’s our checklist for this activity…

  • Add a page in your design notebook and share an update about your independent workshop project progress, by responding to the red/yellow/green reflection prompts:

 

traffic_light_red_dan_ge_01

Red: What are some elements of your project that aren’t going well, that you’re worried about, or that you’d love advice about?

The thing I find most frustrating. is the amount of time it takes to type then to debug code.  I think the metaphor of programming language to spoken language is appropriate because they say it takes 1-2 years to gain facility in a new language.  This is beyond the scope of a 3 week project, but I have made a good start at learning.

 

traffic_light_yellow_dan_01

Yellow: What are some elements of your project that you are just OK, or that you’re feeling ambivalent about?

I’m going to reinterpret this question to:  What else do you want to write about or explore?   A couple of times a commenter has asked me about how my project can help students jump into a career in IT.  As a podcaster and musician, I have a knee jerk reaction to “How do you make money doing THAT?” questions of “I don’t know and I don’t care”.  But this question needs a longer and more sensitive blog reflection which I would like to write this week. 

 

 

 

traffic_light_green_dan__01Green: What are some elements of your project that are awesome or that you’re excited about?

I am enjoying the problem solving and puzzle nature of learning to make games in a new programming language.  I would like to continue doing that, even after the CCOW workshop ends.

 

Other Posts for Week 5:  

And One More Thing:

This week I installed two wordpress plugins into my blog to display python code (and indeed almost any kind of programming code) with correct formatting and color coding:   W-P Code Highlight and  Sunburst Code Prettify.

Recreating a Python Simulation in Scratch

Cooriemungle_Water_Tank_Cow_Monster-wikimedia-commonsIn my last post, I added my own modifications to the tutorial  Making Breakout by Leonel at codeNtronix.   He also has a number of tutorials about drawing 3D graphics using python and pygame.  I was intrigued by his simulation of a 3D Starfield made using Python and Pygame.  (Thanks Leonel for creating such useful tutorials).

 

His simulation uses a few basic 3D to 2D algorithms, which I don’t fully understand but they are effective at creating the desired effect.  He created this effect with just 80 lines of source code,  Click here to download the full source code from CodeNTronics.

I analysed the code myself to see if I could recreate this simulation in Scratch.

3D Starfield

Scratch Code:  Takes 31 lines of code and painted backdrop and sprite costume in the paint editor.starfield-scratch-stage-codestarfield-scratch-starsprite-code

 

Python code:  81 lines from CodeNTronics, with comments added by me.

# """
# 3D Starfield Simulation
# Developed by Leonel Machava <leonelmachava@gmail.com>
#
# http://codeNtronix.com
# http://twitter.com/codentronix
# """
import pygame, math
from random import randrange

class Simulation:
    def __init__(self, num_stars, max_depth):  # SM- each star needs an individual variable for x,y,depth.  
        pygame.init()   # SM-- does a bunch of pygame stuff to set up screen and clock.

        self.screen = pygame.display.set_mode((640, 480))
        pygame.display.set_caption("3D Starfield Simulation (visit codeNtronix.com)")

        self.clock = pygame.time.Clock()
        self.num_stars = num_stars
        self.max_depth = max_depth

        self.init_stars()  # SM- Tells the program to make the list of stars

    def init_stars(self):
        """ Create the starfield """
        self.stars = []
        for i in range(self.num_stars):
            # A star is represented as a list with this format: [X,Y,Z]
            star = [randrange(-25,25), randrange(-25,25), randrange(1, self.max_depth)]
            self.stars.append(star)

    def move_and_draw_stars(self):
       # """ Move and draw the stars   """   SM Converts the xy coordinates to cartesian to centre stars on screen
        origin_x = self.screen.get_width() / 2
        origin_y = self.screen.get_height() / 2

        for star in self.stars:
            # The Z component is decreased on each frame. SM-- Star Moves closer
            star[2] -= 0.19

            # If the star has past the screen (I mean Z<=0) then we
            # reposition it far away from the screen (Z=max_depth)
            # with random X and Y coordinates.
            if star[2] <= 0:
                star[0] = randrange(-25,25)
                star[1] = randrange(-25,25)
                star[2] = self.max_depth

            # Convert the 3D coordinates to 2D using perspective projection.
            k = 128.0 / star[2]   # SM I don't know where Leonel got this constant 128/depth but it works
            x = int(star[0] * k + origin_x)  #SM-- moves starfield origin towards centre of screen
            y = int(star[1] * k + origin_y)

            # Draw the star (if it is visible in the screen).
            # We calculate the size such that distant stars are smaller than
            # closer stars. Similarly, we make sure that distant stars are
            # darker than closer stars. This is done using Linear Interpolation.
            if 0 <= x < self.screen.get_width() and 0 <= y < self.screen.get_height():
                size = (1 - float(star[2]) / self.max_depth) * 5
                shade = (1 - float(star[2]) / self.max_depth) * 255
                self.screen.fill((shade,shade,shade),(x,y,size,size))

    def run(self):
        """ Main Loop """
        while 1:
            # Lock the framerate at 50 FPS.
            self.clock.tick(50)

            # Handle events.
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    return

            self.screen.fill((0,0,0))
            self.move_and_draw_stars()
            pygame.display.flip()

if __name__ == "__main__":
    Simulation(256, 32).run()

Reflection:

The python program presents a much more realistic starfield and is much more versatile. But the scratch program accomplishes the same task in 1/4 the length and it is much easier for me to tinker with the variables and formulas to change the appearance in SCRATCH. It is an accomplishment that I can understand enough of Python to recreate the essential features of a program in SCRATCH. To use the analogy of spoken languages, I think that I have progressed to the point that I can understand a bit of what I read and hear in PYTHONESE, but I cannot yet speak it like a native. This is very good progress for 10 days. To extend the spoken language analogy, one of the common exercises for people learning a second language is to translate passages from one language to another.  That is exactly what I attempted here, and I am quite satisfied with the results.

In which I Pursue Progress with Programming in Python

99er MagazineIn  1981 or so, my brother and I were 12 and 13 years old and we both had paper routes.  We pooled the fruits of our paper carrier jobs, and Dad took us down to the Alberta Treasury Branch where he co-signed a $1200 personal loan at a whopping 23% interest so that we could buy our first personal computer– a TI-99/4.  In fact it was the first personal computer anyone had in our neighbourhood.  We poured over the accompanying manuals, got all sorts of books from the library, and subscribed to 99er magazine.  These early computer enthusiast magazines offered articles about the future of computing, ads for enticing new peripherals and gadgets, and most importantly programs.  Each magazine contained printouts– recipes I guess, for dozens of programs.  We learned to program by painstakingly copying programs from printouts in these magazines, even more painstakingly debugging our errors then figuring out how to fix the inevitable mistakes in the magazine’s code.

30 year later, as I make the transition from SCRATCH, to PYTHON, I find myself transported back to the same learning process.  As I undertook to learn a new programming language, I found myself seeking out familiar “Teach yourself programming by copying these game’ books.  But this time I did not need to go to the magazine stand, or the library, or order in by mail.  The resources are all a google away.  I think it says something about my personal learning style that I chose the cookbook style of print resources over the many multimedia and video tutorials available on youtube.

I’ve spent most of the last week trying to understand some of the basic structure and commands of python, as I worked my way through a variety of tutorial programs.  First impression is compared to scratch there is alot more fiddly typing and figuring out exactly how to initialize then execute each step.  Unlike scratch, it is much harder in python to just poke around and see what will happen.  If you don`t know the precise order, structure, and syntax for any small part… the whole program may not even start.  I think here is a fundamental difference between Scratch and python.  Constructivist philosophy is at the core SCRATCH.  It is designed to be explored, tinkered with and discovered.  On the other hand, Python is designed to be functional, readable, and infinitely extensible.  Alex Martelli, author of the Python Cookbook, summed up the Python Philosophy:

To describe something as clever is not considered a compliment in the Python culture.” Python’s philosophy rejects the Perl “there is more than one way to do it” approach to language design in favor of “there should be one—and preferably only one—obvious way to do it”.  From:  Python Programming Language on Wikipedia.

Bricka by codeNtronix

Download the original Brika Source code from codeNtronix

and here is my revised source code for Bricka.

'''
 bricka (a breakout clone)
 Developed by Leonel Machava <leonelmachava@gmail.com>
 http://codeNtronix.com

with revisions by Sean McGaughey http://edalchemy.mcgaughey.ca
during Creative Computing Online Workshop

'''
import sys, pygame
from pygame.locals import *

SCREEN_SIZE   = 640,480

# Object dimensions
BRICK_WIDTH   = 60
BRICK_HEIGHT  = 15
PADDLE_WIDTH  = 60
PADDLE_HEIGHT = 12
BALL_DIAMETER = 16
BALL_RADIUS   = int(BALL_DIAMETER / 2)   #source code was just BALL_DIAMETER / 2 This through an error of floating point vs Int error
                                        # I added an int function to make sure it is an integer value

MAX_PADDLE_X = SCREEN_SIZE[0] - PADDLE_WIDTH
MAX_BALL_X   = SCREEN_SIZE[0] - BALL_DIAMETER
MAX_BALL_Y   = SCREEN_SIZE[1] - BALL_DIAMETER

# Paddle Y coordinate
PADDLE_Y = SCREEN_SIZE[1] - PADDLE_HEIGHT - 10

# Color constants
BLACK = (0,0,0)
WHITE = (255,255,255)
BLUE  = (0,0,255)
BRICK_COLOR = (200,200,0)

# State constants
STATE_BALL_IN_PADDLE = 0
STATE_PLAYING = 1
STATE_WON = 2
STATE_GAME_OVER = 3

mousex = 0 #x coordinate of mouse event
mousey = 0 # y coordinate of mouse event

class Bricka:

    def __init__(self):
        pygame.init()

        self.screen = pygame.display.set_mode(SCREEN_SIZE)
        pygame.display.set_caption('bricka (a breakout clone by codeNtronix.com)')

        self.clock = pygame.time.Clock()

        if pygame.font:
            self.font = pygame.font.Font('freesansbold.ttf',20)
        else:
            self.font = None

        self.init_game()

    def init_game(self):
        self.lives = 3
        self.score = 0
        self.state = STATE_BALL_IN_PADDLE

        self.paddle   = pygame.Rect(300,PADDLE_Y,PADDLE_WIDTH,PADDLE_HEIGHT)
        self.ball     = pygame.Rect(300,PADDLE_Y - BALL_DIAMETER,BALL_DIAMETER,BALL_DIAMETER)

        self.ball_vel = [5,-5]

        self.create_bricks()

    def create_bricks(self):
        y_ofs = 35
        self.bricks = []
        for i in range(7):
            x_ofs = 35
            for j in range(8):
                self.bricks.append(pygame.Rect(x_ofs,y_ofs,BRICK_WIDTH,BRICK_HEIGHT))
                x_ofs += BRICK_WIDTH + 10
            y_ofs += BRICK_HEIGHT + 5

    def draw_bricks(self):
        for brick in self.bricks:
            pygame.draw.rect(self.screen, BRICK_COLOR, brick)

    def check_input(self):
        for event in pygame.event.get(): # event handling loop
            if event.type == QUIT or (event.type == KEYUP and event.key == K_ESCAPE):
                pygame.quit()
                sys.exit()
            elif event.type == MOUSEMOTION: # I added these mouse controls.  It works well.
                mousex, mousey = event.pos
                if mousex >= MAX_PADDLE_X:
                    self.paddle.left = MAX_PADDLE_X
                else:
                    self.paddle.left = mousex

            elif event.type == MOUSEBUTTONUP:
                mousex, mousey = event.pos
                self.paddle.left = mousex
                mouseClicked = True
                if self.state == STATE_BALL_IN_PADDLE:
                    self.state = STATE_PLAYING

        keys = pygame.key.get_pressed()

        if keys[pygame.K_LEFT]:
            self.paddle.left -= 5
        if self.paddle.left < 0:             self.paddle.left = 0         if keys[pygame.K_RIGHT]:             self.paddle.left += 5         if self.paddle.left > MAX_PADDLE_X:
            self.paddle.left = MAX_PADDLE_X

        if keys[pygame.K_SPACE] and self.state == STATE_BALL_IN_PADDLE:
             self.state = STATE_PLAYING
        elif keys[pygame.K_RETURN] and (self.state == STATE_GAME_OVER or self.state == STATE_WON):

            self.init_game()

    def move_ball(self):
        self.ball.left += self.ball_vel[0]
        self.ball.top  += self.ball_vel[1]

        if self.ball.left <= 0:             self.ball.left = 0             self.ball_vel[0] = -self.ball_vel[0]         elif self.ball.left >= MAX_BALL_X:
            self.ball.left = MAX_BALL_X
            self.ball_vel[0] = -self.ball_vel[0]

        if self.ball.top < 0:             self.ball.top = 0             self.ball_vel[1] = -self.ball_vel[1]         elif self.ball.top >= MAX_BALL_Y:
            self.ball.top = MAX_BALL_Y
            self.ball_vel[1] = -self.ball_vel[1]

    def handle_collisions(self):
        for brick in self.bricks:
            if self.ball.colliderect(brick):
                self.score += 3
                self.ball_vel[1] = -self.ball_vel[1]
                self.bricks.remove(brick)
                break

        if len(self.bricks) == 0:
            self.state = STATE_WON

        if self.ball.colliderect(self.paddle):
            self.ball.top = PADDLE_Y - BALL_DIAMETER
            self.ball_vel[1] = -self.ball_vel[1]
        elif self.ball.top > self.paddle.top:
            self.lives -= 1
            if self.lives > 0:
                self.state = STATE_BALL_IN_PADDLE
            else:
                self.state = STATE_GAME_OVER

    def show_stats(self):
        if self.font:
            font_surface = self.font.render('SCORE: ' + str(self.score) + ' LIVES: ' + str(self.lives), False, WHITE)
            self.screen.blit(font_surface, (205,5))

    def show_message(self,message):
        if self.font:
            size = self.font.size(message)
            font_surface = self.font.render(message,False, WHITE)
            x = (SCREEN_SIZE[0] - size[0]) / 2
            y = (SCREEN_SIZE[1] - size[1]) / 2
            self.screen.blit(font_surface, (x,y))

    def run(self):
        while 1:
            for event in pygame.event.get():     # I added these lines from Sweigart, making Games with Python
                if event.type == pygame.QUIT:
                    sys.exit                    # To check for Quit

            self.clock.tick(50)
            self.screen.fill(BLACK)
            self.check_input()

            if self.state == STATE_PLAYING:
                self.move_ball()
                self.handle_collisions()
            elif self.state == STATE_BALL_IN_PADDLE:
                self.ball.left = self.paddle.left + self.paddle.width / 2
                self.ball.top  = self.paddle.top - self.ball.height
                self.show_message('PRESS SPACE TO LAUNCH THE BALL')
            elif self.state == STATE_GAME_OVER:
                self.show_message('GAME OVER. PRESS ENTER TO PLAY AGAIN')
            elif self.state == STATE_WON:
                self.show_message('YOU WON! PRESS ENTER TO PLAY AGAIN')

            self.draw_bricks()

            # Draw paddle
            pygame.draw.rect(self.screen, BLUE, self.paddle)

            # Draw ball

            pygame.draw.circle(self.screen, WHITE, (self.ball.left + BALL_RADIUS, self.ball.top + BALL_RADIUS), BALL_RADIUS)

            self.show_stats ()
            pygame.display.flip()

if __name__ == '__main__':
    Bricka().run()

  

 Bonus:

Here is my first attempt at programming a game in Scratch from November of 2011.

1921SeaCowFlickr-theirhistory

Coder’s Log Terradate 26.06.2013

pythonI got some great feedback about my post this morning that for my CCOW project what I wanted to do is leave the SCRATCH sandbox and learn to code in Python.

Eric Schilling responded on Google Plus:

Have you checked out Blockly from Google? It’s a web-based, graphical programming editor, similar to Scratch except it will provide the code in a number of different programing languages (phyton, xml, etc.).
http://blockly-demo.appspot.com/static/apps/code/en.htmlAlso, I found Code Academy was a wonderful resource to learn new programming languages.
http://www.codecademy.com/tracks/python

I checked out both resources and they are quite useful.  Blocky seems to be a little more clunky than scratch, and it is also a sandbox type learning environment.  But it may be very useful transition for figuring out how things work in python by snapping somewhat familiar blocks together and viewing the python code that it outputs.
The codeacademy resource looks good, but I went looking for some other free kid friendly “How to code in python books” so that I could recommend some resources for children ready to make the move from Scratch.
Here on the blog, Claude commented:
Your blog is always very interesting Sean! Ok, now I have maybe too straightforward question for you : why don’t you set your objective to simply learn python and make a game with it? I know the course is supposed to be based on scratch, but it sounds like you’re twisting your multiple objectives to fit the course. And I think that when you teach with scratch, at some point you want introduce student too “fuller” languages, and I hear python is the natural second step. So it would be very coherent to prepare like the next step learning Python, wouldn’t it?
Thank you Claude.  You helped clarify to me about my project.  Rather than try to convert python code to scratch or vice versa, I will just document my own transition from the closed sandbox of scratch to the larger playground afforded by python.
So tonight I explored a number of beginner Python resources including:
Al Sweigart has 3 comprehensive free books geared at teaching nonprogrammers and children how to program python through games.

I settled on using the Python Book for Beginners by Jody S. Ginther  because it offers  a very simple short (58 page) primer to downloading and beginning to program with Python.    The first thing I did after I downloaded the book, is followed its instructions to Download Python for Windows and install it.  Don’t worry if you use Mac or Linux, there are flavours of Python for most operating systems.

Then I just started working through the book and following the code examples to make my first programs.  My first impressions of python are that through my use of Scratch and programming in BASIC 30 years ago, I know the basic principals of programming.  I will just have to start to learn the commands, syntax and peculiarities of python.  I like how the IDLE python editor uses color commands to differentiate between different types of commands.  It also automatically indents certain commands to make it easy to see which commands belong with which blocks of code.

My other first impression is that I realize now that the training wheels are definitely off.  Scratch offers a kind of mixed sandbox with it’s integrated graphics and audio editors, background support and focus on making multimedia programs easily.  There is a ton of programming and arranging you can do in scratch without ever snapping together a code block  (Ie setting up a picture or scene with a variety of text, paintings, and sprites).     Not so in python (or other object oriented languages).  If you don’t explicitly tell the computer to do something in the code– it will not happen.

Last thought before bedtime.  Today’s refined project objective for my CCOW project:  Document my transition from using Scratch to learning python on this blog.   Try to keep in my mind tips and resources that would help students make this transition.

Week 4- Workshop Project: Defining and Planning

cube of RubikHere it is.  We are midweek through the crazybusy last week of school, so I have not been able to do much with CCOW except for watching the office hours while packing up my little office/classroom for the summer.

I have been dreading the project part of the workshop because I had too many ideas and many of them were larger than I think I could tackle in 3 weeks.  One of them is worth mentioning just to get a link in here.  There is a good start to an Introduction to Scratch handbook on Wikibooks that is incomplete.  I considered seeing if a group of people would be interested in joining wikibooks to work on completing this scratch book.   It could turn into a project which is waaay larger than the scope of this workshop. It would involve collaborating with another online community and learning it’s culture and way of doing things.  And I think, to a certain degree it would be re-inventing the wheel because the Scratch wiki  contains all the information such a book would have and more, and it is actively maintained.  Also during my too brief explorations of the Resources section of ScratchED, I think that there are plenty of other easily accessible Scratch primers and activities, so this one is not needed.

That got me thinking about Objectives, aka learning goals, aka purpose, aka What are we supposed to do, aka what do I what to do.  My objectives and goals for participating in this online workshop are individual, as are those of each of the other participants in the workshop.  And the facilitators each of reasons (objectives) for participating in CCOW.  Not only that, but each person in the process may have multiple (sometimes conflicting) goals.   For instance, I know that the lead facilitator of CCOW, Karen Brennan, stated that she wanted to try to organize a MOOC using a new google platform that allows one to design and host online courses.  That sounds like a fine personal professional learning goal for her, and we all are benefitting from the fruits of her work on that goal.

But what are my learning goals for participating in this workshop?  I had to reflect on that a bit because in my teaching I often start doing the planning and teaching before I fully realize my objectives.  (I think this is a reality in any kind of teaching and learning environment).

  • I signed up because I have been teaching Scratch to elementary students  (and to other teachers) for about 3 years but I always feel that I never have the time to play with it myself– to really get under the hood and relearn to code.

1)  I want to master SCRATCH so that I can better teach it to my students, and so  that I know more of it’s potential uses (particularly in the elementary grades that I teach).

This spring my nephew got a rubiks cube.  When I was 13, I could solve a cube in under a minute, but I had completely forgotten how.  This spring I bought a couple of cubes and relearned how to do it.  I love problem solving puzzles (like sudoku) and I forgot how much I enjoyed the sheer muscle and brain stimulation of trying to solve a cube as quickly as possible.

The rubiks cube was left behind in a time in my childhood when I was also fascinated with the early personal computers (TI-99, apple II, and commodore 64 primarily).  From the time I was 13 to about 16 I programmed all sorts of things in BASIC, PASCAL, and a bit of assembly language.  I haven’t really programmed since, except for learning the basics of HTML and CSS, and the tiniest bit of Javascript.  I forgot how much I enjoyed programming.  Also as a podcaster, blogger, songwriter, creative-type 21st century internet denizen, I have come to realize that if you want to be more than just a consumer of media, you need to have a basic understanding of how to code.

2) I want to learn how to code again… not  just as a subject to teach but as a creative outlet for myself.  While I have been thinking about CCOW and doing the work of the workshop, I have also been investigating other ways to learn programming.  I have downloaded a bunch of `Teach Yourself Python` resources and I have signed up for the Android App Inventor site (which is based on scratch).

3)  I want to read more about and reflect upon Constructivist principles in my teaching and learning.  I have been enjoying some of the underlying philosophy behind SCRATCH and CCOW… alot.  I know that SCRATCH is based on a constructivist approach,  and I know that the facilitators have intentionally structured the course based on constructivist principles.  But I want to learn more about the basic philosophies, core principles, key writings and proponents, of the constructivist school of learning.

Given these 3 objectives here is a first try at framing a project idea:

I want to learn to code.  I would make the leap from Scratch to Python, which is a more multi-purpose language.  I could use it to code for the web or to make apps for my handy android phone.

So…  I will try to use a ‘How to code in python’ manual  as a guide to create a game in scratch.

In this way I will become familiar with some of the basic structure and syntax of python.  I want to use my growing knowledge of SCRATCH to make myself a rosetta stone to understand other programming languages– (like python).

 I need to dig into some online and downloaded resources, but I think I will try to use a tutorial on how to code a game such as reversi using Python.  If this looks too challenging to adapt to scratch I will choose a simpler game. 

 

My writing/thinking time is just about up for today,   When I revisit this post I want to flesh out my idea to get more specific about which python/scratch resources I would need and narrow down what game I want to make.  I also want to start to answer the Key Questions for Week 4- Workshop Project: Defining and Planning.

 

    1. Workshop project problem/exploration/question statement
      What is the problem you’re trying to address? Maybe it’s not a problem, but rather an area of inquiry to explore. What is the exploration or question that motivates your project? Can you express this in no more than 3 sentences?
    2. Workshop project format
      How are you thinking about responding to your problem/exploration/question? What will you be making or doing for your project?
    3. Workshop project needs
      What do you need in order to successfully make progress on your project? Do you have access to the resources that you need? What do you still need to figure out? Is it a big Scratch project, a series of mini-activities that explore advanced concepts, a proposal for a learning experience, new resources for young learners, or something else entirely?
    4. Workshop project plan
      What are the steps for getting your project done? What is a timeline for getting it done?
    5. Workshop project keywords
      What are five keywords or tags that describe your project?

 

Week 3 Roundup

This week has been quite busy at work with finishing report cards and all the end of the year assemblies and activities.  Just 4 teaching days and 1 PA day to go.

On to my CCOW activities this week.

Cumulative Activity: Games:  In this week’s “big project”, you’ll develop a game — a Scratch project that includes interactions between sprites, score, and levels.

Follow My Song

I was quite excited to try coding a classic pattern game like Simon.  I also wanted it to be a bit of a musical primer so I based the tones on a pentatonic scale.  The game does not have overt scores or levels but it does change in difficulty and speed as the pattern gets longer and longer.  This game is a classic.  Simple enough to need no instructions other than “Follow My Song”, but difficult enough to keep people wanting to play it more.

My imagination kept introducing `feature creep’   with ideas like making alternate costumes for the sprites like piano keys, guitar frets and flute and trumpet fingerings, and making a standard set of variables so that I could code a kind of framework or API to make music games using scratch.  In the end, it was enough of a challenge just to try to make compact, simple code to show the sprites, change their colors, and detect key presses and see if they match a pre determined pattern.  I ended up making 8 almost identical sprites (one for each note in a major scale).  I am pretty sure I could have done this using lists, multiple clones of one sprite, and variables to change the color and tone of each sprite.  In the end it was just easier to duplicate 1 sprite 8 times and change the code for each individual note.

Somewhere between the keypress and my broadcast to check it against the random list of the computer’s pattern, a glitch appeared in that it does not call game over until one press after you make a mistake.  Thus if you make a mistake on the last note of a pattern, you get to go to the next level.  I have not figured out how to solve it because I can’t find the error in my reasoning or in my code to check the pattern.

One of my third grade students told me that I should just say that this is part of the game, because it is fair to give people 2 chances.  I think I’ll stick with her answer, although the glitch is still bugging me.

Readings:  Illich, I. (1971). Deschooling society (Chapter 6). New York, NY: Harper & Row.

I have not had alot of time to flesh out my thoughts, but I’ve been thinking about how much Illych’s article on education webs foretold what we are doing here.  We have a MOOC with over 1900 members, from all over the world.  We are the self selected peer group, the facilitators are  expert support. We have wikipedia, coursera, and quick access to almost all academic literature, books, and media throughout history at our fingertips.   I think Illych would have quickly grasped the possibilities of the Internet for self-directed learning.   How else does our experience in this course resemble what Illych was describing?

Subtasks

  1. I made a post with this week’s Debug it activities on Sunday.
  2. Levels— I read through this activity and but did not do the assignment of looking for different ways people code levels using scratch.  I think I have a good handle on different ways to have levels in games with increasing speed, increasing difficulty, a change of scene or more adversaries with greater skills.
  3. Score:   In this activity, we needed to remix Fish Chomp by adding a score using variables.   Here is mine:

 

I added a countdown timer to make the game last for 60 seconds, and gave one point for each fish caught. I also added a global High Score Variable stored in the cloud. That means that you can compete against other scratchers for world bragging rights.

I added a Start Game broadcast for the purple fish because for some reason I had to press the green flag twice to get them to move and react with the yellow fish. It didn’t do that in the sample code, so I think it was something to do with my timer code or my if-then-else blocks.

Questions:     What is a variable? A variable is a letter or name that can have a “variety” of values.  Its value can vary.
 How would you explain variables to young learners?  I think that giving variables literal names like ‘score’ and ‘time-left’ can help them to make the connection between what is going on in the game and the idea of variables in math class.  I think the first time the concept of variables really clicked for me was when I was 12 or 13 and learning to program simple games in BASIC.  I think the same thing could happen using SCRATCH with young children.

4.  Interactions:  In this activity, we were given 9 specific tasks to try to code.  Here are my Interactions:

 

  •  Questions: Which puzzles did you work on?,       What was your strategy for solving the puzzles?     Which puzzles, if any, helped you think about your game project?

I got cute and tried to do them all in one project.  This was actually more difficult because some of the activities interacted with the others, creating more complexity.  After about 2-1/2 hours, I stopped with about 6 of them done.   Below each task I reflect on how I did it and answer the questions.

    • Whenever you press the B key, the sprite gets a little bigger. Whenever you press the S key, the sprite gets a little smaller.    This was pretty straightforward.  I programmed the cat to grow and shrink with these keys, and made it move with the arrow keys.
    • Whenever the sprite hears a loud sound, it changes color.  I did not do this one, but I have a pretty good idea how I would do it with the sensing blocks.
    • Whenever the sprite is in the top 25% of the screen, it says “I like it up here.”
      I made a sloping background and had the cat say this above about y 100.  The hardest part of coding this was the code to make sure the characters could not walk into the sky.  I did this with a `not touching green statement` so that it would also not walk through other sprites.
    • When the sprite touches something blue, it plays a high note. When the sprite touches something red, it plays a low note.
      I did not code this one either.  
    • Whenever two sprites collide, one of them says: “Excuse me.”
      Done.
    • Whenever the cat sprite gets near the dog sprite, the dog turns and runs from the cat.
      I had the dog move towards the cat then turn a 180 and move back 50 steps.  It fulfils the task but makes for a yo-yo frenetic effect.
    • Whenever you click on the background, a flower appears at that spot.
      I used clones of one flower sprite.  When the stage is clicked it chooses a random color and size.  I also had a random location, then changed it to the position of the mouse pointer as per then instructions.
    • Whenever you click on a sprite, all other sprites do a dance.
      I did not do this, but I think I was going to do a loop with the whirl effect forward and back on the flowers.  I did end up using this technique with a looks block in my `Follow my song` game the next day so thinking about this challenge helped.
    • Whenever you move the mouse-pointer, the sprite follows but doesn’t touch the mouse-pointer.  At first I had the cat then the dog follow the mouse pointer, then I added the butterfly because it was tricky to add this code along with the other things I had the cat and dog doing.

Random Coding Fun

Last week, the facilitators introduced a change to the process of submitting and reviewing design notebooks.  Now we just need to submit the link to our design notebook (or noteblog), then choose peer notebooks ourselves from a numbered list of all the submitted notebooks for the week.  One of the participants on the forums requested a way to choose a random notebook on the forums.   kb8ywp used SCRATCH to code a perfectly useful, but visually plain  Random Notebook Number Generator

On a whim, I remixed it to add a bunch of randomly placed notebooks, and included a cloud variable which remembers when someone enters the number of notebooks for the week, so you only need to re-enter that number if it has changed.  My changes were mostly cosmetic, and not needed, but it made for a fancier Random Notebook Number Generator remix.

Here it is nearly midnight on a Friday night. I think my CCOW week 3 is finished. I`m looking forward to the next three weeks and my self-directed project, but I still have no idea what that might be. I`m sure something will come to me. And only one more week of doing both schoolwork and workshop work. Yipee.

Week 2 Overview- Alice in Scratchland

Alice in Scratchland

When I first wrote this post, I thought I had completed Alice in Scratchland for the Scenes assignment of Week 2 of CCOW.  Then I went back and added Characters using {Make a Block} to define two character’s unique behaviours.  Then I added just enough puzzles and gameplay that players start to get drawn into Wonderland.  Then I added a final scene with an invitation to remix and continue the story.  So, In large part, this one project encompasses  over half of my week 2 activities.

 

SCENES

This assignment was primarily to experiment how sprites and stage backgrounds can be used to change scenes in scratch.  I felt like I did this already in my About me project last week, but I gave it a go.  I went with an Alice in Wonderland theme.  Use the arrow keys to move around in the vignettes.

  What does the Stage have in common with sprites?   The stage has backgrounds, while sprites have costumes.  It is possible to change the appearance of each.   Stage Backgrounds differ from sprites in that they are fixed in place, and can have no motion or size effects.

 How do you initialize sprites in a scene?   You can hide them at the green flag until a certain background comes on or have them react to a broadcast command from the background or another sprite.
 What other types of projects (beyond animations) employ scene changes?   Games, especially 2d platformers, slide shows, digital story books, demonstrations and simulations.  Pretty much any application in scratch may use scene changes of one kind or another.
   How did others use backdrops in the studio?   To change colors or moods, to show pictures, to advance a story, or to show another screen in a game.

MartyH. made use of scenes and recorded narration to tell the wonderful story of Sadie and Fluffy.

Characters

The Make a Block Feature is a way to blend a variety of actions into one command unique to a sprite.  For my 2 characters, The White Rabbit and the Cheshire Cat, I used make a block to define those actions and movements that make the character unique.   The White Rabbit starts upstage left and moves toward the rabbit hole or the door with a distinctive double hop then step forward.  Randomly, he stops to say he’s late or other typical White Rabbit sayings.  I used a randomized list to mix up about 7 sayings.  Here is the script for the white rabbit.

WhiteRabbitScript

For the Cheshire Cat, I used a costume of just eyes and the {ghost} effect, along with some random code to have scratch pop up anywhere on the top half of the screen at any time.   This gave the Cheshire Cat his characteristic feature of randomly appearing in the story.

CheshireCatScript

Make a blocks are a great new feature of Scratch, which enables you to automate custom, repetitive or distinctive actions into one command.  This can make the rest of the scripts much more compact and easy to understand.  It is great for giving characters unique features, but it could also be useful to define certain algorithms or computations used as part of a larger program.  I can think of a teaching program for 2-d geometric shapes where you could define a block that would draw  each 2-d figure, ie) rectangle, square, octagon, etc…

Pass it On…  Remix Challenge.

It is nearly 150 years since Alice`s Adventures in Wonderland were first published and the story is beloved around the world.  I am interested to see where other people take my starter adventure with Alice and her companions (if anyone does take up the challenge with all the other potential remix projects to choose from).

 What is your definition of remixing?

As a folk singer, photographer, songwriter, elementary school teacher, podcaster, and recorder of public domain audiobooks (whew?),  I have come to realize that we stand on the shoulders of giants.  All creative endeavours borrow somewhat from the creativity of others before them.  I am passionate about the public domain and preserving this treasure of our forbearers which we can use to retell their stories, and remix to tell our own.   I try to use creative commons or public domain sources, such as open clipart as much as possible for these reasons.

How did it feel to remix? How did it feel to be remixed?

People are very proud of their work.  They can be quite protective of it.  But I have learned to let mine go into the world and see what stories it brings back to me.   For instance, here is a story from my songwriting blog a few years ago.  Take the time to listen to the podcast.  It is a great story.  (and it has an Alice in Wonderland connection too).

Filed by Sean on November-29-2009
 Special- King of Carrowocky [ 7:44 ] Download (5102)

This story is too random and too cool to fully explain.  Go ahead, try to explain the story in this podcast to your 1990 self.  I bet you can’t do it.  It began for me on November 24 when I received this tweet from Adam Gratrix @transpondency of theTranspondency Podcast.

RIAA’s Crafty King of Carrowocky http://bit.ly/7tgD4O mashup ft. @Sean_McGaughey http://bit.ly/7H9IL5 Librivox reading of Jabberwocky.

Listen to the show to hear what happened next.

Links in this show:

Jabberwocky on Librivox.org

Mr. Fab: The Crafty King of Carrowocky

I love adding new words to old melodies or a new twist to an old story.  It is important to acknowledge and give credit to those whose work you build upon.    Having said that, I get sloppy about giving specific attribution for each of the images in my scratch projects.  I have to get better about that because I know how people who freely share their work love to hear back about how it was used.  I think I will go back into my projects and give proper attribution for the images.

     What are the opportunities and challenges with this activity for your students?  

Attribution is a huge one.  They just don’t understand or care about the issue of having permission to use images and media in their own works.

For my own remix, I chose: Jazzy the Outward Hound by rrtika.

I took rritka’s original concept, added a doghouse from http://www.clipartdb.com/gif-dog-house-115.htm and turned the story back on itself to change the ending?

It was interesting working with another person’s code. She handles turning around by making another costume. I just set rotation to left-right and point it in the other direction.

Here is my remix: Homeward Hound

 

Debug It

Earlier this week, I posted my Week 2 Debug It solutions.

Conversations

Conversations Between Sprites: Week 2- Penguin Jokes

Week 2 Wrap-Up

This week I ran into several limitations of Scratch, particularly  when I wanted to enable cloud based lists to make a database of user submitted Knock, Knock jokes in the Conversations activity.  Then I realized that Scratch is not meant to be a robust, all purpose programming environment.  It is necessarily constrained and limited to introduce children to key programming concepts.  Once they develop an understanding of these general programming concepts, they can move on to other fuller-featured languages.