getting started with robot basic
TRANSCRIPT
IN PROGRAMMING FOLDER
CLICK ON ‘ACCEPT’
THIS IS THE EDITOR SCREEN, WHERE YOU KEY IN YOUR PROGRAM.
THIS IS THE TERMINAL SCREEN, WHERE YOUR PROGRAM RUNS.
X-AXIS
Y-AXIS
0800
0
600
How to Create a Line
• Define the begin point (1) and the end point(2)
• Begin Point: x1, y1• End Point: x2, y2• The Command to Draw the Line :– Line x1, y1, x2, y2– Example: Line 40, 50, 100, 200
How to Create Shapes:
• A Rectangle: define the point in the upper-left corner(1) and the point in the lower-right corner(2).– Rectangle x1, y1, x2, y2– Example: Rectangle 40, 50, 100, 200
• A Circle: define it like a rectangle. The circle is drawn inside that rectangle.– Circle x1, y1, x2, y2– Example: Circle 40, 50, 100, 200
//To draw a line, define the begin point and end point.//Line x-coordinate of begin point, y-coordinate of begin point,// x-coordinate of end point, y-coordinate of end point
Line 0,400,800,400
//Rectangle, x-coordinate of upper-left corner, y-coordinate of upper-left corner,// x-coordinate of lower-right corner, y-coordinate of lower-right corner Rectangle 100,100,200,300
//Circle is created the same way as a rectangle with coordinates for a rectangle,//BUT drawn INSIDE the rectangle.
Circle 300,100,500,300
End
Robot Basic Commands & their Meaning
• rLocate x,y
• rTurn angle
• rForward pixels
• End
• Places the robot simulator on the screen at the x, y coordinates.
• Turns the robot at the angle specified (it defaults to pointing up).
• Moves the robot forward the number of pixels.
• Ends the program.
ALL ROBOT COMMANDS BEGIN WITH AN ‘R’
•Places robot at coordinates 100 for x, and 200 for y.•Robot turns 90 degrees (right).•Robot moves forward 500 pixels.•Robot turns 180 degrees (halfway arount).•Robot moves forward 500 pixels.•Program ends.
A Sample Program Meaning of Each Command
THE ROBOT SIMULATOR DURING THE PROGRAM RUN.
THE LINE INDICATES WHICH DIRECTION THE ROBOT IS POINTING (in this case, Left)
The Editor’s Menu and the Toolbar
Identifying Buttons on the Toolbar
New File
Copy
Save File
Open File
Cut Paste
Other Buttons on the Toolbar You Should Know:
Undo Last Change
Print your program
Show Terminal Screen
Find Text
Find and Replace Text
Run Program
Here’s a Sample Program with Comments:
// defines a comment, which the program ignores
This is the Result
Circle
Rectangle
Line
COPY IN A NEW FILE. SAVE AS ROBOT
GET ROBOT HERE
USING THE LINE COMMAND, TRY TO WRITE THE PROGRAM THAT WILL DRAW THESE TWO INTERSECTING LINES
Did you write something like this?
line 0,0,800,600line 800,0,0,600