Programming Explorer
  • Blog
  • About
  • Contact

A Blended Approach to Event Handling

7/2/2015

0 Comments

 
Picture
Figure 1: A robust approach to event hadling

Combining the two approaches I mentioned in my earlier post fixed the issues I was having using only one or the other approach.  Now the cat can move and jump without issues.  This logic is very similar to the type used in all event handling, with the difference being that the forever loop is often implied rather than explicit, and the if statements may be switch statements instead for convenience.  However, the logic stays the same.

Picture
Figure 2: The butterfly sprite recieves messages from the cat

I also used some message handlers to pass messages between the cat and butterfly sprites.  Each time the cat moves left, right, or jumps, the butterfly sprite will detect and respond to the action in a different way.
0 Comments

Installing Scratch 2 on Ubuntu Linux 14.04 64 bit

7/2/2015

58 Comments

 
Picture
Figure 1: A fresh Scratch 2 install on Ubuntu 14.04 64-bit

While Mac and Windows have relatively simple Scratch installs, the install via Ubuntu is more complicated, particularly if it is a 64 bit system.  While the older version of Scratch is available via the Ubuntu package manager, Scratch 2 is not.  Since Scratch 2 has some important new features, such as code blocks, you may want to install it instead, or in addition to, the older Scratch version.  Here is a step-by-step instruction guide to install Scratch 2 on an Ubuntu Linux 64 bit system:

  1. Download the Adobe Air and Scratch files from:

    https://scratch.mit.edu/scratch2download/

  2. The following libraries are needed:

    sudo apt-get install libxt6:i386 libnspr4-0d:i386 libgtk2.0-0:i386 libstdc++6:i386 libnss3-1d:i386 lib32nss-mdns libxml2:i386 libxslt1.1:i386 libcanberra-gtk-module:i386 gtk2-engines-murrine:i386

  3. Now you have to create a symbolic link to your gnome keyring:

    sudo ln -s /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0

    sudo ln -s /usr/lib/x86_64-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0

  4. cd into the directory with the AdobeAIRInstaller.bin

  5. sudo ./AdobeAIRInstaller.bin

  6. Now install Scratch 2:

    sudo "Adobe AIR Application Installer" /path/to/scratch2/installer/Scratch-437.air

    NOTE: The information for installing Adobe Air on Ubuntu 14.04 64-bit given above was found in this Ask Ubuntu post.




58 Comments

Event Detection in Scratch

7/1/2015

33 Comments

 
Today I'm working on adding some event detection to the cat in the Scratch programming language.   The cat can move left and right and jump.  However, due to the ordering of the commands, they cannot all be done at any time.  So I'll be working on that.  Earlier I was using if statements instead of 'wait until' statements, and they actually worked better but I was getting unexpected behavior with the cat.

Here is the code I created based on the 'wait until' statements:
Picture
33 Comments

    Programming Explorer

    Computers and programming

    Archives

    July 2015

    Categories

    All

    RSS Feed

Powered by Create your own unique website with customizable templates.