Daily Archives: September 4, 2012

The Dew Review – Intel Next Generation Ultrabook™ with Windows 8: Initial Impressions

Intel Ultrabooks have been around for a little while now. They are thin, light, powerful and (until now) run Windows 7. With the official Windows 8 launch coming in less than 60 days, Intel is readying the next generation of Ultrabooks. These devices will feature similar form factors and power as their predecessors. However, they will have new hardware inside to take advantage of the capabilities of Windows 8.

Last week I received an Ultrabook from Intel. I will be running it through its paces from a developer’s perspective over the next several months. As I have more time to spend with the Ultrabook, I will be publishing additional reviews with my more information around how Windows 8 developers can use this type of device to develop Windows 8 Modern UI style apps. This particular device will not be made available for purchase. It is a proof of concept from Intel. The only manufacturer branding on it is Intel’s, as you can see from this shot of the lid.

WP_000397

Hardware and Form Factor

As one would expect from an Ultrabook, this computer is thin, light and fast. On the outside it’s got a mini HDMI port, a pair of USB 3.0 ports, an HD webcam and a 13.3” multi-touch display. Inside, it’s rockin’ an Intel Core i7  CPU running at 2.00 GHZ, 4 GB of DDR3L RAM, a 180 GB SSD hard drive, and the following specifications (to name just a few):

  • 802.11 b/g/n WiFi
  • Bluetooth
  • NFC
  • Multi-Touch Pad
  • Sensors galore (see below)

WP_000401WP_000400

Windows 8, Sensors & Advanced Features

The machine came with the Windows 8 Release Preview (64 bit) pre-installed. Now that Windows 8 is released to manufacturing (RTM) and available to MSDN subscribers, I am hoping to install the final bits for future reviews. However, I have to wait for confirmation from Intel to ensure the included drivers are all compatible with RTM.

Most new tablets and Ultrabooks running Windows 8 are going to have a slew of sensors. Here are the sensors and other advanced features included in this proof of concept device:

  • Accelerometer
  • Magnetometer
  • Gyro
  • Ambient Light Sensor
  • GPS
  • NFC
  • Multi-Touch (display and touchpad)

start screen dev tools

In future reviews, I will write some sample apps to take advantage of this advanced hardware.

Getting Started

I have been using Windows 8 on other machines and virtual machines, however none of them have touch screens. I have to say that using Windows 8 on a clam shell form factor with touch feels very natural to me. The physical keyboard is great for desktop apps, obviously. When using modern Windows 8 style apps, I found myself instinctively using the touch screen in combination with the keyboard and touchpad.

The hardware is very fast and smooth in every app I have used so far. Here are a few things I have installed to evaluate the machine.

Windows Store Apps

  • Evernote
  • Fresh Paint
  • Slacker
  • Rowi
  • Fruit Ninja
  • Box
  • OneNote MX

Desktop Apps

  • Visual Studio 2012 RC
  • SQL Server 2012 Developer Edition
  • JetBrains WebStorm
  • Eclipse (for Android development)
  • Paint.NET
  • Git for Windows

Coming Up

In about two weeks, after I have had some time to develop on the Intel Ultrabook, I will write a more in-depth review. If the first few days are any indication, I think I will love building apps on this computer. I cannot wait to dive in!

 

Disclosure of Material Connection: I received one or more of the products or services mentioned above for free in the hope that I would mention it on my blog. Regardless, I only recommend products or services I use personally and believe my readers will enjoy. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”

 

Programming with Scratch – Relative Motion

scratch1

Programming with Scratch

By Majed S. Marji

Scratch is a simple, yet powerful, programming language that is intended to make computer programming easy and fun. It is different from the other programming languages in that it is visual. Instead of typing in your commands, you create your program by connecting graphical blocks together. In this article based on chapter 2 of Programming with Scratch, author Majed Marji shows you how to move sprites on the stage using the relative motion command blocks.

Relative Motion

Figure 1 shows a Scratch program that displays “Hello!” on the screen. The result from running this program is also shown in the figure.

scratch-fig1

Figure 1 This figure shows: (a) a simple Scratch program that contains a single command block, and (b) the result of running this program.

The cat that you see in figure 1.1(b) is called a sprite. You can think of a sprite as a small robot that understands and obeys a predefined set of commands. You can give a sprite a different look by commanding it to use a different image, called costume. You can use an image of an airplane, snowman, your own photo, or anything else you like. The applications you create would typically contain more than one sprite, and your program will command these sprites to do certain things like move, turn, say something, play music, perform mathematical calculations, and so on. The area of the screen where your sprite move and interact with one another is called the stage.

Programming in Scratch is performed by snapping together “colored” command blocks, similar to putting together jigsaw puzzles or LEGO pieces. The stacked blocks that you create are called scripts.

Consider the grid depicted in figure 2, which shows a rocket sprite and a target (star) sprite. Here, the exact positions of these sprites on the stage are unknown as indicated by the absence of their (x,y) coordinates. If you were asked to give instructions to the rocket to hit the target, you might say, “First, move three steps, then turn right, then move two steps.” The effect of executing these instructions is also illustrated in the figure.

scratch-fig2

Figure 2 You can move a sprite on the stage using relative motion commands.

Commands like “move” and “turn” are examples of relative motion commands. The first “move” command, for example, caused the rocket to move up, whereas the second “move” command caused the sprite to move to the right. In essence, the motion depends on (or is relative to) the current direction (or heading) of the sprite.

In addition to its current (x,y) position on the stage, the state of a sprite is also determined by its current direction. The direction convention used in Scratch is illustrated in figure 3. You can explicitly set the direction of a sprite using the scratch2 command. You specify the direction by clicking the down arrow and selecting (up, right, down, or left) from the dropdown list or by typing in any value you want in the white edit box. Note that you can use negative values if you want. Typing 45 or -315, for example, causes the sprite to point northeast.

scratch-fig3

Figure 3 Direction convention used in Scratch: 0 (up), 90 (right), 180 (down), and -90 (left).

With this newfound knowledge, let me introduce Scratch’s relative motion commands. These commands are summarized in table 1. I’ll demonstrate how to use these commands with the aid of simple examples.

Table 1 Relative motion commands in Scratch

Command

Description

scratch-tab1

Moves the sprite in a straight line in the direction of its current heading. It takes an input number that indicates how far the sprite should move. A positive number causes the sprite to move forward, whereas a negative value causes the sprite to move backward.

scratch-tab2

Changes the sprite’s x-position by a specified amount. This causes a horizontal (left or right) movement of the sprite.

scratch-tab3

Changes the sprite’s y-position by a specified amount. This causes a vertical (up or down) movement of the sprite.

scratch-tab4

Rotates the sprite clockwise in reference to its current direction. It takes an input number that indicates the required turn angle. A negative value results in a counterclockwise motion.

scratch-tab5

Rotates the sprite counterclockwise in reference to its current direction. It takes an input number that indicates the required turn angle. A negative value results in a clockwise motion.

You can see the current direction of a sprite in the “sprite info area” of Scratch’s user interface (see figure 4).

scratch-fig4

Figure 4 Current sprite info area

Another way to see this information is provided by the scratch3 block. Clicking the checkbox next to this block allows you to see the sprite’s direction on the stage.

Using move and turn commands

Figure 5 illustrates how the move and turn commands work in relation to the current direction of the sprite. The first command causes the sprite to point up. The second command turns the sprite 45° clockwise. Then, the sprite moves 100 steps in its current direction (in other words, northeast). The last command turns the sprite 45° counterclockwise, which changes the sprite’s direction to the up position.

scratch-fig5

Figure 5 A simple script that illustrates using the move and turn commands

There are many other ways to implement this script and still have the same end result. For example, instead of commanding the sprite to point up then turn right 45°, we can directly command it to point in the direction of 45° using the scratch4 command. Another way is to have the sprite point right, move some distance, turn left 90°, then move the same distance up. The scripts for these two alternatives are shown in figure 6. As you can see, the second script used the Pythagorean Theorem to calculate the horizontal and vertical distances.

scratch-fig6

Figure 6 Different scripts that produce the same result as the script of figure 5

TRY IT OUT (1) – What do you think would happen if you used negative values in motion commands? Try the script shown in figure 7 to check your answer. (2) To know the direction of the sprite, check the box next to the scratch5 block, then turn the sprite by different angles (using the turn commands). What values are displayed in the direction monitor box on the stage?

scratch-fig7

Figure 7 Using negative parameters in motion blocks

Using “change x by” and “change y by” commands

Figure 8 shows a simple script that illustrates the effect of the scratch-change1 and scratch-change2 commands. The first command moves the rocket sprite to the center of the stage, setting its x-coordinate to 0 and its y-coordinate to 0. The scratch-change3 command changes the x-coordinate to 50 (in other words, 0+50), which causes the sprite to move 50 steps to the right. The next command (scratch-change4) changes the y-coordinate to 50, which causes the sprite to move up 50 steps. The (x,y) coordinates of the sprite after executing this command will be (50,50). When the second scratch-change5 command is executed, the sprite will move additional 50 steps to the right ending at point (100,50). You should now be able to trace the motion of the sprite caused by this script, which is also illustrated in the figure.

scratch-fig8

Figure 8 A simple script that illustrates using the “change x by” and “change y by” commands

Summary

Scratch programs (also called scripts) are created by snapping together command blocks that control graphical objects called sprites. You can give a sprite a different look by assigning it a different image, called costume. Sprites move and interact with one another on a background area called the stage. You can change the appearance of the stage by assigning it a different image, called background. Scratch has four kinds of blocks: command blocks, function blocks, trigger blocks, and control structure blocks.

In this article, you learned how to use relative motion commands to move sprites with reference to their own position and direction.

 

Here are some other Manning titles you might be interested in:

arduino

Arduino in Action

Martin Evans, Joshua Noble, Mark Sproul, and Jordan Hochenbaum

java

The Well-Grounded Java Developer

Benjamin J. Evans and Martijn Verburg

machinelearning

Machine Learning in Action

Peter Harrington

 

 

del.icio.us Tags: ,,,

Dew Drop – September 4, 2012 (#1,393)

Top Links

 

.NET / Visual Studio

 

Web Development

 

Design / Methodology / Testing

 

Silverlight / WPF / Windows Phone

 

Podcasts / Screencasts / Videos

 

Community / Events

 

Database

 

PowerShell

 

Miscellaneous

 

More Link Collections

 

The Geek Shelf