Você está na página 1de 19

IN PROGRAMMING

FOLDER
CLICK ON ‘ACCEPT’
THIS IS THE EDITOR
SCREEN , WHERE YOU KEY
IN YOUR PROGRAM .
0 0
X-AXIS 800

THIS IS THE TERMINAL


SCREEN , WHERE YOUR
PROGRAM RUNS .

Y-AXIS

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 • Places the robot simulator
• on the screen at the x, y
coordinates.
• rTurn angle
• Turns the robot at the angle
• specified (it defaults to
• rForward pointing up).
pixels • Moves the robot forward
• the number of pixels.
• End • Ends the program.
• ALL ROBOT COMMANDS BEGIN WITH AN ‘ R ’
A Sample Program
Meaning of Each
Command
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.


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

Save
N e w File File

Open File

Cut Paste

C opy
Other Buttons on the Toolbar You Should
Know:
Undo Last Find and
Change Replace
Text

Find Text

Print your
program

Run Program

Show Terminal
Screen
Here’s a Sample Program with
Comments:
// defines
a comment,
which the
program
ignores
Rectang
le
Circle

Line

This is the Result


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,600
line 800,0,0,600

Você também pode gostar