Unplugged coding aims to teach programming concepts through the use of games or activities that can be done offline using tangible objects, such as paper and markers. Offline coding is a good way to engage younger students without the use of technology. It helps students better understand computer science concepts through role-playing, analogies and other visual exercises.
CS Unplugged Key Principles:
No computers required
Real computer science
Learning by doing
Activity 1 - Event Handlers
The following activity facilitates the understanding of an event (when something in the game happens) and an event handler, specifically the click event (this is what happens when clicking on a sprite).
1. First, you'll need 4 volunteers (see if you can add friends through skype or Facetime!):
Nominate one volunteer to be the “event’s causer”. Their role will be to trigger the event in the game.
Nominate the other three volunteers to respond to an event (or act as the “event handlers” who carry out the event). Decide with the “event handlers” on their actions (for example, volunteer 2 will walk to the window, volunteer 3 will count until 10 in Spanish, volunteer 4 will write “hello” on the board, etc.)
2. Second, tell the “event handlers” that they can only execute their action when the “event causer” taps on their shoulders.
3. Ask the “event causer” to start going around and tap the “event handlers’” shoulders. Each “event handler” should perform his or her action only when the “event causer” taps their shoulder. Ask the “event causer” to also:
tap on other students in the class ( who should not do anything). Ask your class why the students are not doing anything? This is because they were not programmed to execute an action.
tap on other objects in the class (i.e. a chair or desk). Nothing will happen. Ask your students why is nothing happening? This is because these objects do not have the capability of being handled in an event.
Events are actions triggered by the user that take place while the code is running, and as a result affect what is happening.
Computer events are:
Pressing a key on the keyboard
Clicking on the mouse
Moving the mouse
When we click on the mouse, we trigger the ‘mouse click event’ and the ‘onClick’ function is called. Such a function is also called an event handler. The onClick function has no parameters. Anytime the mouse is clicked on, the function onClicked is called. If the function is not defined in the sprite, then nothing will happen when the sprite is clicked on. When the mouse is clicked on anything other than a sprite, nothing will happen, because there is no object that listens (or “waits”) for the trigger.