Skip to content

Commit 7a10ded

Browse files
audreychanaudreychan
authored andcommitted
Day 1
1 parent 2a34fbe commit 7a10ded

15 files changed

Lines changed: 118 additions & 50 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void setup(){
2+
size(800, 800);
3+
}
4+
5+
void draw(){
6+
fill(#2D92FA);
7+
if(mousePressed){
8+
fill(#890B0B);
9+
}
10+
ellipse(400, 400, 800, 800);
11+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
PImage mustache;
2+
PImage friend;
3+
4+
void setup(){
5+
friend = loadImage("delara.jpg");
6+
size(800, 600);
7+
friend.resize(width, height);
8+
mustache = loadImage("Mustache.png");
9+
mustache.resize(50, 25);
10+
}
11+
12+
void draw(){
13+
background(friend);
14+
if(mousePressed){
15+
image(mustache, mouseX - 250, mouseY - 75);
16+
}
17+
}
7.49 KB
Loading
17.1 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
PImage wakanda;
2+
PImage quinjet;
3+
4+
void setup(){
5+
wakanda = loadImage("Wakanda.jpeg");
6+
size(640, 357);
7+
quinjet = loadImage("Quinjet.png");
8+
}
9+
10+
void draw(){
11+
background(wakanda);
12+
image(quinjet, mouseX, mouseY);
13+
}
6.55 KB
Loading
72.1 KB
Loading

src/section2/FourSquare.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,41 @@
66
public class FourSquare {
77

88
// 2. Create a new Robot
9+
Robot r2d3 = new Robot();
910

1011
void go() {
1112
// 4. Make the robot move as fast as possible
13+
r2d3.setSpeed(5000);
1214

1315
// 5. Set the pen width to 5
16+
r2d3.setPenWidth(5);
1417

1518
// 6. Use a for loop to repeat steps #7 to #8, four times...
19+
for(int i = 0; i < 4; i ++) {
1620

1721
// 7. Set the pen color to random
22+
r2d3.setRandomPenColor();
1823

1924
// 1. Call the drawSquare() method
25+
drawSquare();
2026

2127
// 8. Turn the robot 90 degrees to the right
22-
28+
r2d3.turn(90);
29+
}
2330
}
2431

2532

2633
void drawSquare() {
2734
JOptionPane.showMessageDialog(null, "yay! you called the drawSquare() method!");
2835
/* 3. Fill in the code to draw a square inside the method below. */
36+
r2d3.penDown();
37+
r2d3.hide();
38+
for(int i = 0; i < 4; i ++) {
39+
r2d3.move(100);
40+
r2d3.turn(90);
41+
2942

43+
}
3044

3145
}
3246

src/section2/MyFirstJavaProgram.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ public class MyFirstJavaProgram {
88
public static void main(String[] args) {
99

1010
// START HERE
11-
12-
13-
11+
System.out.println("Hello world!");
12+
Robot r2d2 = new Robot();
13+
r2d2.penDown();
14+
r2d2.setSpeed(50);
15+
r2d2.hide();
16+
r2d2.setPenColor(Color.BLUE);
17+
for(int i = 0; i < 4; i ++) {
18+
r2d2.move(100);
19+
r2d2.turn(90);
20+
}
1421
}
1522
}

src/section2/StarShow.java

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,24 @@ public class StarShow {
1212
Robot robot = new Robot("batman");
1313

1414
void makeStars() {
15+
robot.hide();
16+
robot.moveTo(30, 550);
17+
for(int i = 15; i < 150; i += 10) {
18+
drawStar(i);
19+
robot.moveTo(robot.getX() + 15 + i / 2, robot.getY() - 15 - i / 2);
20+
robot.setRandomPenColor();
21+
}
1522

16-
drawStar(150); //5. delete this line. You will draw the star again in step 8.
17-
// 13. Set the speed to 8
18-
19-
// 6. Make a variable to hold the X position of the Robot and set it to 10
20-
21-
// 7. Make a variable to hold the Y position of the Robot and set it to 600
22-
23-
// 8. Make a variable to hold the star size and set it to 25
24-
25-
// 12. Use a for loop to repeat steps #19 to #18, 30 times
26-
27-
// 19. Set the pen width to i
28-
29-
// 10. Set the X position of the robot to your X variable
30-
31-
// 11. Set the Y position of the robot to your Y variable
32-
33-
// 9. Call the drawStar() method with your star size variable
34-
35-
// 14. Increase the value of the X position variable by star size. See Figure 2
36-
37-
// 15. decrease the value of the Y position variable by star size. See Figure 3
38-
39-
// 16. Increase the star size by 20
40-
41-
// 17. Turn the robot 12 degrees
42-
43-
// 18. Make each star a different random color like in Figure 4
4423

4524
}
4625

4726
private void drawStar(int starSize) {
48-
// 2. Put the robot's pen down
49-
50-
// 4. Repeat both commands 5 times. See Figure 1 at http://bit.ly/star-show
51-
52-
// 1. Move the robot the distance of the starSize variable
53-
54-
// 3. Turn the robot 144 degrees
27+
robot.penDown();
28+
robot.setSpeed(500000);
29+
for(int i = 0; i < 5; i ++) {
30+
robot.move(starSize);
31+
robot.turn(144);
32+
}
5533

5634
}
5735

0 commit comments

Comments
 (0)