HW3_Student_work.docx: uploaded 29 June 2012 at 8:15 am

advertisement
Example of Student Work
HW 3: Etch-A-Sketch
**I tried simplifying the code as much as possible, however the application still lags tremendously on
the actual phone, and tends to crash.
The Etch-A-Sketch application is intended to simulate the drawing features of the classic Etch-A-Sketch.
Instead of turning the dials, however, the application takes full advantage of the Android's
accelerometer and of App Inventor's accelerometer sensors. The application is set to be used only in
landscape mode, similar to the shape of the Etch-A-Sketch, and allowing for the user to draw more
tilting left-to-right versus tilting up-and-down. The drawing canvas takes up most of the screen so the
most important feature of the application is most clearly visible to the user, allowing for more drawing
space and keeping the app simple and easy to understand. The most difficult features of the application
were to balance out the accelerometer functions as well as the shaking sensor functions; the screen of
the application had to be adjusted so that the window was fixed and the orientation would not change
on accident when the phone was tilted.
In the Designer window, the screen is set to the background of the Etch-A-Sketch graphic. Buttons for
changing the pen to either draw-mode or erase-mode are visible over the dials in the corners. The
instructions for clearing the screen are printed along the bottom frame of the canvas.
Designer Window and the landscape screen.
In the blocks editor, the main functionality behind the accelerometer and drawing functions are a part
of the OrientationChanged component of Orientation Sensor (labeled SensorDraw). The program at
launch sets the ball sprite to the dark gray color. Afterwards, the MoveTo function for the ball is called,
adding on the absolute value of the roll and pitch (tilting) motions to the original X and Y values of the
ball. This makes sure that the values for ball are positive, and that no negative values from roll and pitch
are added, else the ball could appear off screen in the negative range. The DrawCircle component is
then called and applied to the canvas.
While I originally attempted to use the DrawLine component to make the lines straight, the sensitivity of
the program made the application suffer from even more lag than it already currently does. DrawLine
did not make the path for the ball straight but rather would branch off multiple lines from the X1 and Y1
values.
When the phone shakes, the drawn lines are cleared out, and the starting point for the ball is randomly
placed on the canvas. Another way to erase the lines is to click the "erase" button on the bottom-left
dial on the screen, changing the color of the ball to the canvas, in order to make smaller erases.
The Block Editor; see zip file for comments.
The emulator, while it cannot test the accelerometer features, shows the final design of the application,
and can test the color-changing of the erase and draw buttons on the dials.
The application visible on the computer emulator.
This application has helped me understand the concepts behind the accelerometer functionalities on
phones, and how apps can use these functions. However at the same time, I've learned that these
features can cause strain on the phone and require many resources in order to crunch the numbers that
are continuously going through the program.
Download