Georgia Institute of TechnologyChristina M. Gardner, PhD
Printable Version of this PageHome PageRecent ChangesSearchSign In

CS Principles - Etch-a-Sketch Starter Code

HW#3 Etch-a-sketch - Code Starters

Basic Starter Code given to all students:

DescriptionEtch-A-Sketch Application Issues Code ReuseFile
This code uses a ball that uses pitch and roll to move across the canvas. It was working fairly smooth at first, at least moving the ball across the screen in a functional manner. The code also draws a line behind the ball, using the previous x and y values and updating them to the current values. Again, the line was working fairly smooth at first. The main issues are control over the ball and making the line act accordingly. Also I need to figure out how to make it work in straight lines. I reused the draw line function from paint pot to use the ball to draw the line instead of your finger. orientation_sensor_test.Will (1).zip
By setting the y-value to a particular number, I am able to use the roll orientation and move the ball left-right while drawing a line. The code for drawing a line left-right will be helpful for the etch-a-sketch because I am able to draw straight lines. However, as soon as a y-value is intertwined, issues arise. This needs to be fixed because the final app will have the functionality of moving vertically as well as horizonatally across the canvas. The issue I have is that the sensor seems to run too slow, and the ball movement is not fluid. I will need to debug and figure out why the sensor is slowing down when the code is run. With the addition of the absolute value function in the blocks, the left-right values would finally function. However, I attempted doing something similar with the pitch (up-down y values) and the ball moved crazily around the canvas. I need to figure out how the roll and pitch can relate without interferring with the movements of the other. I used paint pot and the drawing tools to help a lot with this app. However, the most effective app I've seen has been one using a timer.
This code will be helpful for thinking about how to control a line being drawn and to erase a line that has already been drawn orientation_sensor_test (1).zip
Functionality working: ball is at least moving, lines drawing from ball, abs value keeps ball within canvas range. Issues: ball movement is sporadic, lines draw from (X, 0) to (ballX, ballY) diagonally. Code reused: Code from paintpot to move to X, Y coordinates; using orientation sensor code (already downloaded w/ source code) as a base for editing OrientationSensor1 orientation_sensor_test
1. My code can draw straight lines and the ball can move to different places. 2. using the orientatioin sensor to go to place I want to draw lines and draw lines at that location. 3. The starting point of each line is always located at the left corner of the canvas.4. I was able to get different values from the orientation sensor. I used the product of roll value and the angle value to calculate how much I want to move from left to right, right to left. I also used the pitch value to determine how much I want to move from top to buttom. the values helped me to draw lines on canvas as well. orientation_sensor_test (2).zip
I still have a lot to do with this code. So, far what I have done is I have a dot that if the user tilts the screen slow enough the dot will form a solid line anywhere on the canvas. I used Canvas.DrawCircle, which is not a good way to do this, it would be better to utilize Canvas.DrawLine. The only problem I found with utilizing Canvas.DrawLine was that I did not know what values to put in for the 2nd X & Y values, I tried utilizing Pitch and Roll for the 2nd X & Y values but that just made my lines go crazy. I need to figure out what to put for the 2nd X & Y and then I think I would be a lot better off. I pretty much utilized the Sensors chapter in the App Inventor book.HW3[1].zip

Last modified 29 June 2012 at 8:08 am by cmgardne