기본 명령어
move()
turn_left()
turn_off()
print()
popup()
say()
repeat()
get_random()
물건
비퍼
벽
문
장애물
좌표
방향
색
글자
입력 폼
고급 명령어
게임 개발용
수학 함수
문자열 함수
RGB 함수
연산자
문법
삭제된 명령어
repeat()
(기본 명령어)
repeat() - 지정된 횟수만큼 명령어 반복하기
repeat() - 지정된 횟수만큼 명령어 반복하기
사용설명
void repeat ( string command, int count )
반복되는 명령어(command)를 지정된 횟수(count)만큼 실행한다.예>
repeat("move()", 3) | move()를 3번 실행 |
repeat("turn_left()", 3) | turn_left() 을 3번 실행 |
repeat("r1.move()", 7) | 로봇r1을 앞으로 7칸 이동 |
repeat("r2.pick_object()", 10) | 로봇r2가 물건을 10개 주울 때 |
repeat("put_object('토마토')", 10) | 토마토를 10개 내려놓을 때 |
repeat("r2.put_object('호박')", 5) | 로봇r2가 호박을 5개 내려놓을 때 |
매개변수
string command
반복 실행할 명령어
int count
명령어를 반복하는 횟수
반복 실행할 명령어
int count
명령어를 반복하는 횟수
반환값
없음(void)
repeat()는 반환값이 없음
repeat()는 반환값이 없음
사용예
코드실행
repeat("move()",4)turn_left()
repeat("move()",3)
코드실행
a=get_random(0,4)b=get_random(0,4)
repeat("move()",a)
turn_left()
repeat("move()",b)
코드실행
function upstair() {move()
turn_left()
move()
turn_left()
turn_left()
turn_left()
move()
}
repeat("upstair()",3)
관련함수