Visual programming with Alice
Finding Nemo
If you can use your desktop environment, then you can also write programs: All you need is your mouse, the Alice IDE, and some time to experiment.
In the Alice development environment, you don't need to type in a single command or learn a cryptic language. Instead, you can create applications and compile all the necessary actions and processes just by clicking your mouse. You start by dragging ready-made items into an empty 3D world. Each item offers several actions that change its appearance, its location, or its behavior. Then, you can just drag and drop the desired actions into a sequence plan, which Alice executes on demand.
Easy-as-pie controls certainly have their limits. For example, the applications created here are always rooted in the 3D world. Alice is therefore suitable mainly for 3D animations or games. The almost mandatory requirement for the 3D world is that Linux supports your video card's 3D acceleration; otherwise, the program you create will run at a snail's pace.
Number Girl
Alice [1] currently exists in two versions. According to the makers, children especially should use the older version 2. Above all, this version teaches logical thinking and the basics of programming. The new version 3, however, focuses on object-oriented programming. It increasingly uses the standard terminology found in this field, thus allowing an easier transition to Java later on.
The basic approach is the same in both versions, with the main difference being the slightly different-looking user interface and slightly different terminology. In this article, I focus on version 3.1, but most of the explanations also apply to Alice 2.3.
The programming environment, developed at Carnegie Mellon University in Pittsburgh, Pennsylvania, USA, is not free software. Although Alice is published under a free license, it is not open source. The installation of the IDE is described in the "Installing Alice" box.
Installing Alice
To download Alice 3.1 for Linux, go to the Alice website [1], look for the Downloads menu and select Get Alice 3.1. In the Universal Installer area, click on Download Alice 3.1 Universal .zip for all platforms. This gives you a zip archive that you can unpack in your home directory. Doing so automatically creates the Alice3
subdirectory.
In the directory, make the alice3.sh
file executable (right-click, select Properties, then click Run as a program or a similarly labeled item in the Permissions tab). If you want to get rid of Alice later, you only need to delete the complete Alice3
directory.
Next, you need to have Java in the form of a Java Development Kit (JDK). The Java runtime environment (JRE) as installed by many distributions is not enough here. On Ubuntu, you can install the JDK quickly in a terminal window with the sudo apt-get install default-jdk
command. You can then launch Alice in the Alice3
directory using the alice3.sh
script.
Setting Up Store
After launching the programming environment, the window shown in Figure 1 pops up. You first need to select the background for your 3D world. In the following example, I want a fish to swim through an underwater world, so I will choose SEA_FLOOR. Clicking OK opens the main window shown in Figure 2. Because the window consumes a lot of space, you will want it to fill your whole screen. The upper left pane is the scene view, the lower left is the methods panel, the large window on the right is the code editor, and the margin on the bottom right holds the control tiles.
For the moment, I'll look at the scene pane, where you will see the currently empty 3D underwater world. Press the Setup scene button to populate it with a fish, or you can or select Window | Perspectives | Setup Scene from the menu. Alice now changes to the view shown in Figure 3, in which the 3D world takes up the largest part of the main window.
In the bottom row, a palette holds all the available items. To help keep track of the objects, Alice sorts them into categories. Flyer Classes, for example, are all objects that can fly – currently only birds. Pressing All Classes returns to the overview. An alternative grouping is available in the Browse Gallery By Theme tab. If you look in ocean, for example, all the objects will be suitable for an underwater scenario. Finally, you can click on the Search Gallery tab to search for a specific object.
For the desired underwater scenario, change to the Browse Gallery By Theme tab and select ocean. Next, hold down the left mouse button on the small yellow clownfish and drag it into the underwater world; however, do not release the mouse button yet. A yellow cube appears in the world (Figure 3). Drag the clownfish to the location you want it to appear.
In the example, I moved it to the left side of the window. You will notice that Alice always locates the object just above the ground – not exactly perfect for a floating fish, but not something you can change at this time. Once you have found a suitable position, release the mouse button. Alice opens the window in Figure 4, which shows that you have created a new object of the type ClownFish in the 3D world. To reuse the object more easily later, you will want to enter a name for the fish in the name box (e.g., Nemo) and then press OK to close the window.
Lift Mechanism
Little Nemo now appears in the underwater world. A green circle indicates that it is currently selected (Figure 5). You can drag and drop to move the fish around freely; clicking on one of the curved arrows at the bottom of the 3D world lets you change the perspective. For this example, however, you can leave the current angle of view.
On the right edge of the window, you will find a palette with all the properties for the object (in Alice 2, they are located in the Properties tab at the bottom left). You can use the Paint drop-down list to specify a different color for Nemo. The Opacity value defines how transparent the fish will be. A value of 1.0 makes Nemo completely visible, and 0.5 makes him semi-visible.
You can use the Vehicle field to chain Nemo to another object. He then automatically follows every movement of the chosen object. Particularly interesting are the values for Nemo's Position and Size. First, you should raise the fish off of the ground somewhat, so that he can swim freely. To do this, enter the value 0.5 under y and press the Enter key. Alice now lifts the fish (Figure 5). Entering a value in x would move Nemo on a horizontal plane, and a z value would move him toward the front or rear. The default size of Nemo is perfect for the example.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.