Getting Started With Robot Basic

19
IN PROGRAMMING FOLDER

Transcript of Getting Started With Robot Basic

Page 1: Getting Started With Robot Basic

IN PROGRAMMING FOLDER

Page 2: Getting Started With Robot Basic

CLICK ON ‘ACCEPT’

Page 3: Getting Started With Robot Basic

THIS IS THE EDITOR SCREEN, WHERE YOU KEY IN YOUR PROGRAM.

Page 4: Getting Started With Robot Basic

THIS IS THE TERMINAL SCREEN, WHERE YOUR PROGRAM RUNS.

X-AXIS

Y-AXIS

0800

0

600

Page 5: Getting Started With Robot Basic

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

Page 6: Getting Started With Robot Basic

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

Page 7: Getting Started With Robot Basic

//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

Page 8: Getting Started With Robot Basic

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’

Page 9: Getting Started With Robot Basic

•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

Page 10: Getting Started With Robot Basic

THE ROBOT SIMULATOR DURING THE PROGRAM RUN.

THE LINE INDICATES WHICH DIRECTION THE ROBOT IS POINTING (in this case, Left)

Page 11: Getting Started With Robot Basic

The Editor’s Menu and the Toolbar

Page 12: Getting Started With Robot Basic

Identifying Buttons on the Toolbar

New File

Copy

Save File

Open File

Cut Paste

Page 13: Getting Started With Robot Basic

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

Page 14: Getting Started With Robot Basic

Here’s a Sample Program with Comments:

// defines a comment, which the program ignores

Page 15: Getting Started With Robot Basic

This is the Result

Circle

Rectangle

Line

Page 16: Getting Started With Robot Basic

COPY IN A NEW FILE. SAVE AS ROBOT

Page 17: Getting Started With Robot Basic

GET ROBOT HERE

Page 18: Getting Started With Robot Basic

USING THE LINE COMMAND, TRY TO WRITE THE PROGRAM THAT WILL DRAW THESE TWO INTERSECTING LINES

Page 19: Getting Started With Robot Basic

Did you write something like this?

line 0,0,800,600line 800,0,0,600