0% found this document useful (0 votes)
69 views8 pages

Tugas 1 Prak Algo

The document contains code snippets for 10 Blocky Games, 10 Burung Games, and 9 Turtle programs. The Blocky Games code includes loops and conditional statements to move and turn a character. The Burung Games code uses conditionals to set the character's heading based on its position and whether it detects a worm. The Turtle programs use loops and conditionals to draw shapes by controlling a turtle's pen color, movement, and turns.

Uploaded by

Tomy Subagia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views8 pages

Tugas 1 Prak Algo

The document contains code snippets for 10 Blocky Games, 10 Burung Games, and 9 Turtle programs. The Blocky Games code includes loops and conditional statements to move and turn a character. The Burung Games code uses conditionals to set the character's heading based on its position and whether it detects a worm. The Turtle programs use loops and conditionals to draw shapes by controlling a turtle's pen color, movement, and turns.

Uploaded by

Tomy Subagia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Tugas 1 Prak Algro

Nama : Aulia Nurhaliza

NIM : 220211060147

Kelas : C

Blocky Games #1

moveForward();
moveForward();
Blocky Games #2

moveForward();
turnLeft();
moveForward();
turnRight();
moveForward();
Blocky Games #3

while (notDone()) {
moveForward();
}
Blocky Games #4

while (notDone()) {
moveForward();
turnLeft();
moveForward();
turnRight();
}
Blocky Games #5

moveForward();
moveForward();
turnLeft();
while (notDone()) {
moveForward();
}
Blocky Games #6

while (notDone()) {
moveForward();
if (isPathLeft()) {
turnLeft();
}
}
Blocky Games #7

while (notDone()) {
if (isPathForward()) {
moveForward();
}
if (isPathRight()) {
turnRight();
}
}
Blocky Games #8

while (notDone()) {
if (isPathLeft()) {
turnLeft();
}
if (isPathRight()) {
turnRight();
}
moveForward();
}
Blocky Games #9

while (notDone()) {
if (isPathForward()) {
moveForward();
} else {
if (isPathLeft()) {
turnLeft();
} else {
if (isPathRight()) {
moveForward();
}
}
}
}
Blocky Games #10

while (notDone()) {
if (isPathLeft()) {
turnLeft();
}
if (isPathForward()) {
moveForward();
} else {
turnRight();
}
}
Burung Games #1

heading(45);
Burung Games #2

if (noWorm()) {
heading(0);
} else {
heading(90);
}
Burung Games #3

if (noWorm()) {
heading(315);
} else {
heading(60);
}
Burung Games #4

if (getX() < 80) {


heading(0);
} else {
heading(270);
}
Burung Games #5

if (getY() > 20) {


heading(270);
} else {
heading(180);
}
Burung Games #6

if (noWorm()) {
heading(345);
} else if (getY() < 80) {
heading(90);
} else {
heading(180);
}
Burung Games #7

if (getY() > 50) {


heading(225);
} else if (noWorm()) {
heading(300);
} else {
heading(180);
}
Burung 8

if (getX() < 50 && getY() < 50) {


heading(45);
} else if (noWorm()) {
heading(315);
} else if (getX() > 50 && getY() < 50) {
heading(135);
} else if (getY() < 75 && getX() < 80) {
heading(45);
}

Burung 9

if (noWorm() && getX() > 20) {


heading(180);
} else if (noWorm() && getY() > 20) {
heading(270);
} else if (getY() < 70 && getX() < 40) {
heading(90);
} else {
heading(315);
}
Burung 10

if (noWorm() && getY() < 80 && getX() < 30) {


heading(90);
} else if (noWorm() && getX() < 80) {
heading(0);
} else if (noWorm() && getY() > 50) {
heading(270);
} else if (getY() < 80 && getX() > 20) {
heading(90);
} else if (getX() > 20) {
heading(180);
} else if (getY() > 20) {
heading(270);
}

Turtle 1

for (var count = 0; count < 4; count++) {


moveForward(100);
turnRight(90);
}
Turtle 2

for (var count = 0; count < 5; count++) {


moveForward(100);
turnRight(72);
}
Turtle 3

penColour('#ffff00');
for (var count = 0; count < 5; count++) {
moveForward(100);
turnRight(144);
}
Turtle 4

penColour('#ffff00');
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
penDown();
moveForward(20);

Turtle 5

penColour('#ffff00');
for (var count2 = 0; count2 < 4; count2++) {
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
penDown();
turnRight(90);
}
Turtle 6

penColour('#ffff00');
for (var count2 = 0; count2 < 3; count2++) {
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
penDown();
turnRight(120);
}
turnLeft(90);
penUp();
penColour('#ffffff');
moveForward(100);
penDown();
moveForward(50);

Turtle 7

penColour('#ffff00');
for (var count2 = 0; count2 < 3; count2++) {
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
penDown();
turnRight(120);
}
turnLeft(90);
penUp();
penColour('#ffffff');
moveForward(100);
penDown();
for (var count3 = 0; count3 < 4; count3++) {
moveForward(50);
moveBackward(50);
turnRight(45);
}
Turtle 8

penColour('#ffff00');
for (var count2 = 0; count2 < 3; count2++) {
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
penDown();
turnRight(120);
}
turnLeft(90);
penUp();
penColour('#ffffff');
moveForward(100);
penDown();
for (var count3 = 0; count3 < 360; count3++) {
moveForward(50);
moveBackward(50);
turnRight(1);
}

Turtle 9

penColour('#ffff00');
for (var count2 = 0; count2 < 3; count2++) {
for (var count = 0; count < 5; count++) {
moveForward(50);
turnRight(144);
}
penUp();
moveForward(150);
turnRight(120);
penDown();
}
penUp();
turnLeft(90);
moveForward(100);
penDown();
penColour('#ffffff');
for (var count3 = 0; count3 < 360; count3++) {
moveForward(50);
turnRight(90);
turnRight(90);
moveForward(50);
turnLeft(90);
turnLeft(90);
turnRight(1);
}
turnRight(120);
moveForward(20);
penColour('#000000');
for (var count4 = 0; count4 < 360; count4++) {
moveForward(50);
turnRight(90);
turnRight(90);
moveForward(50);
turnLeft(90);
turnLeft(90);
turnRight(1);
}

You might also like