├── Assignment1 ├── Assignment1.pde └── sketch.properties ├── Assignment2 ├── Assignment2.pde └── sketch.properties ├── Assignment3 ├── Assignment3.pde └── sketch.properties ├── Assignment4 ├── Assignment4.pde └── sketch.properties ├── Assignment5 ├── Assignment5.pde └── sketch.properties ├── Assignment6 ├── Assignment6.pde └── sketch.properties ├── Intro ├── Intro.pde └── sketch.properties ├── README.md ├── ball_overlaps_paddle ├── ball_overlaps_paddle.pde └── sketch.properties ├── bounce_ball ├── bounce_ball.pde └── sketch.properties ├── change_background ├── change_background.pde └── sketch.properties ├── change_background_continuous ├── change_background_continuous.pde └── sketch.properties ├── change_ball_color ├── change_ball_color.pde └── sketch.properties ├── change_ball_color2 ├── change_ball_color2.pde └── sketch.properties ├── circle ├── circle.pde └── sketch.properties ├── concentric_circles_for_loop ├── concentric_circles_for_loop.pde └── sketch.properties ├── concentric_circles_no_loop ├── concentric_circles_no_loop.pde └── sketch.properties ├── concentric_circles_while_loop ├── concentric_circles_while_loop.pde └── sketch.properties ├── ellipse_array ├── ellipse_array.pde └── sketch.properties ├── ellipse_array_loops ├── ellipse_array_loops.pde └── sketch.properties ├── left_right_color_control ├── left_right_color_control.pde └── sketch.properties ├── move_paddle ├── move_paddle.pde └── sketch.properties ├── paddle ├── paddle.pde └── sketch.properties ├── screen_grapher ├── screen_grapher.pde └── sketch.properties ├── shapes ├── shapes.pde └── sketch.properties ├── square ├── sketch.properties └── square.pde ├── start_moving_ball ├── sketch.properties └── start_moving_ball.pde ├── wanderer_list ├── sketch.properties └── wanderer_list.pde └── wanderers ├── sketch.properties └── wanderers.pde /Assignment1/Assignment1.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | float screenWidth = ***; //set to your maxX 4 | float screenHeight = ***; //set to your maxY 5 | 6 | void setup() //runs once 7 | { 8 | fullScreen(); //Sets the program to run in full screen mode 9 | 10 | } 11 | 12 | void draw() //runs forever 13 | { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Assignment1/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Assignment2/Assignment2.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assignment2/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Assignment3/Assignment3.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assignment3/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Assignment4/Assignment4.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assignment4/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Assignment5/Assignment5.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assignment5/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Assignment6/Assignment6.pde: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Assignment6/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /Intro/Intro.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | void setup() //runs once 4 | { 5 | fullScreen(); //Sets the program to run in full screen mode 6 | 7 | } 8 | 9 | void draw() //runs continuously until the program is stopped 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Intro/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SuaCode - Smartphone-Based Coding Course 2 | 3 | [Course outline](https://drive.google.com/open?id=1odhEW4VrEUFmu_naQjywrJdXlLw5DucnLl1ctPliUXY) 4 | [0.0 Introduction](https://drive.google.com/open?id=1aCXiozFF8if6GMYiCiKmB6drrp1KF2XRn1DGOBtdqiY) 5 | 6 | ## Lesson 1 7 | [1.0 Basic Concepts in Processing](https://drive.google.com/open?id=1Ah2RlKPqW2Y6EIAthzgYRWgRNHaRgn8lYD1s6Cf1JEY) 8 | [Assignment 1 - Make Pong Interface](https://drive.google.com/open?id=1uNwWfBI9-JTlcmh4OZ8W9s7xPc9EuoupEIx6inne9iQ) 9 | 10 | ## Lesson 2 11 | [2.0 Variables](https://drive.google.com/open?id=1unJWDGheh0vIjFXSvWHdjAl1T-C13PWvyDHL8CHKkAM) 12 | [Assignment 2 - Move Ball](https://drive.google.com/open?id=1Hxsg67pB8A7o4uTtmWK4219-tmAcAYscQbzL1cTohTw) 13 | 14 | ## Lesson 3 15 | [3.0 Conditionals](https://drive.google.com/open?id=1ZP7aoDq8TE9FNxepJw4ZSuDXOI4exUnPJH1qok_iv1s) 16 | [Assignment 3 - Bounce Ball](https://drive.google.com/open?id=1IFbPvciPSuUar1pM8bMxRZBpXrPCQYxEhAZX4AK-Ra8) 17 | 18 | ## Lesson 4 19 | [4.0 Functions](https://drive.google.com/open?id=1Oz3eQzm4tKTj0FtIMTWFoRTckcUBn4h7shqCvf3CX2A) 20 | [Assignment 4 - Move Paddles](https://drive.google.com/open?id=1gAJCekLfsulZZ5Jicy5wj1-Z2SVk3zt6y1ZgkFNVnRo) 21 | 22 | ## Lesson 5 23 | [5.0 Classes and Objects](https://drive.google.com/open?id=1zUskf8ALY37QBPFdKxW13r7P1a4tDA-wbuPWhf5qX8w) 24 | [Assignment 5 - Add Extra Ball](https://drive.google.com/open?id=1HyvfK9PBYfdYXvVJPuuCc55RSEcamnvFYmf2HlmOzB0) 25 | 26 | ## Lesson 6 27 | [6.0 Loops & Arrays](https://drive.google.com/open?id=1bap7mffotjOWuVCfNIFqKK4Voxc283A88ppjH-y9HeQ) 28 | [Assignment 6 - Add More Balls](https://drive.google.com/open?id=1_NzBVM-dCDEcm7F9Zo-iT-cFzg9Oj7U6EQt8W42zLWE) 29 | -------------------------------------------------------------------------------- /ball_overlaps_paddle/ball_overlaps_paddle.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | float screenWidth = ***; //set to your maxX 4 | float screenHeight = ***; //set to your maxY 5 | 6 | 7 | //paddleRightX (the x position of the right paddle) is 90 units from the 8 | //right edge of the screen. We do this because the paddle's width is 90 units. 9 | //So by subtracting 90 from maxX, the right paddle fits nicely at the 10 | //right edge of the screen. 11 | float paddleRightX = ***; // maxX - paddleWidth = *** - 90 = *** 12 | 13 | //y position of the left paddle is exactly half of the y axis 14 | float paddleLeftY= ***; // maxY/2 = *** 15 | 16 | //y position of the right paddle is exactly half of the y axis 17 | float paddleRightY= ***; // maxY/2 = *** 18 | 19 | //x position of the left paddle is at 0 20 | float paddleLeftX = 0; 21 | 22 | float paddleWidth = 90; 23 | 24 | float paddleHeight= 300; 25 | 26 | float diameter = 80; //diameter of the ball 27 | float radius = 40; //since half the diameter is the radius 28 | 29 | boolean hasOverlappedLeftPaddle = false; 30 | boolean hasOverlappedRightPaddle = false; 31 | 32 | int ballX = 0; 33 | 34 | int ballY = 0; 35 | 36 | void setup() 37 | { 38 | fullScreen(); //Sets the program to run in full screen mode 39 | } 40 | 41 | void draw () 42 | { 43 | background (0); //set background to black each frame 44 | 45 | stroke (0, 0, 255); //use a blue outline for all shapes until stroke is run again with another color 46 | 47 | fill (0, 255, 0); //fill all shapes to green until fill is run with another color 48 | 49 | //Draw paddles 50 | rect (paddleLeftX, paddleLeftY, paddleWidth, paddleHeight); //draw left paddle 51 | 52 | rect (paddleRightX, paddleRightY, paddleWidth, paddleHeight); //draw right paddle 53 | 54 | fill(255); //fill all shapes to white until fill is run with another color 55 | 56 | //set balls position to be position of a touch on the screen 57 | ballX = mouseX; 58 | ballY = mouseY; 59 | 60 | //Check if there is an overlap between ball and left paddle 61 | hasOverlappedLeftPaddle = doesOverlap(paddleLeftX, paddleLeftY, paddleWidth, paddleHeight, ballX, ballY, radius); 62 | 63 | if (hasOverlappedLeftPaddle) { 64 | 65 | fill (255, 0, 0); //fill all shapes to red until fill is run with another color 66 | } 67 | 68 | //Check if there is an overlap between ball and right paddle 69 | hasOverlappedRightPaddle = doesOverlap(paddleRightX, paddleRightY, paddleWidth, paddleHeight, ballX, ballY, radius); 70 | 71 | if (hasOverlappedRightPaddle) { 72 | 73 | fill (0, 0, 255); //fill all shapes to blue until fill is run with another color 74 | } 75 | 76 | //Draw ball 77 | ellipse (ballX, ballY, diameter, diameter); //draw ball unto the screen 78 | } 79 | 80 | //Checks if ball overlaps paddle 81 | 82 | boolean doesOverlap(float xPaddle, float yPaddle, float widthPaddle, float heightPaddle, float xBall, float yBall, float radius) { 83 | 84 | float ballLeftEdge = xBall-radius; //left edge of ball 85 | float ballBottomEdge = yBall+radius; //bottom edge of ball 86 | float ballRightEdge = xBall+radius; //right edge of ball 87 | float ballTopEdge = yBall-radius; //top edge of ball 88 | 89 | float paddleLeftEdge = xPaddle; //left edge of paddle 90 | float paddleBottomEdge = yPaddle+heightPaddle; //bottom edge of paddle 91 | float paddleRightEdge = xPaddle+widthPaddle; //right edge of paddle 92 | float paddleTopEdge = yPaddle; //top edge of paddle 93 | 94 | if (ballBottomEdge >= paddleTopEdge //Check if bottom edge of ball and top edge of paddle overlap 95 | && ballTopEdge <= paddleBottomEdge //Check if top edge of ball and bottom edge of paddle overlap 96 | && ballLeftEdge <= paddleRightEdge //Check if left edge of ball and right edge of paddle overlap 97 | && ballRightEdge >= paddleLeftEdge ) //Check if right edge of ball and left edge of paddle overlap 98 | { 99 | return true; 100 | } else { 101 | return false; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /ball_overlaps_paddle/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /bounce_ball/bounce_ball.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | 5 | //x position of the ball is exactly half of the x axis 6 | int ballX = ***; // maxX/2 = *** 7 | 8 | //y position of the ball is exactly half of the y axis 9 | int ballY = ***; // maxY/2 = *** 10 | 11 | int ballWidth = 80; //width of ball 12 | int ballHeight = 80; //height of ball 13 | int xSpeed = 5; //ball's horizontal speed 14 | int ySpeed = 0; //ball's vertical speed 15 | int radius = 40; //since half the width or the height of the ball is the radius 16 | 17 | void setup() //runs once 18 | { 19 | fullScreen(); //Sets the program to run in full screen mode 20 | 21 | } 22 | 23 | void draw() //runs forever 24 | { 25 | background(0); //set color to black 26 | 27 | fill(255); //set color of ellipse to white 28 | 29 | ellipse(ballX, ballY, ballWidth, ballHeight); //draw ellipse 30 | 31 | //Move ball 32 | ballX = ballX+xSpeed; 33 | ballY = ballY+ySpeed; 34 | 35 | //Check if ball hits left or right walls 36 | if ((ballX-radius < 0) || (ballX+radius) > screenWidth) { 37 | xSpeed = xSpeed * -1; //Reverse direction 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /bounce_ball/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /change_background/change_background.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | 4 | void setup() { 5 | fullScreen(); //Sets the program to run in full screen mode 6 | 7 | } 8 | 9 | void draw() { 10 | 11 | if (mousePressed) { //check if mouse has been pressed 12 | 13 | background(255); //set background color to white 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /change_background/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /change_background_continuous/change_background_continuous.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | 4 | void setup() { 5 | fullScreen(); //Sets the program to run in full screen mode 6 | 7 | } 8 | 9 | void draw() { 10 | 11 | if (mousePressed) { //check if mouse has been pressed 12 | 13 | background(255); //set background color to white 14 | } else { 15 | 16 | background(0); //set background color to black 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /change_background_continuous/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /change_ball_color/change_ball_color.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int halfScreenWidth = ***; // maxX/2 = *** 4 | 5 | int ballWidth = 80; 6 | int ballHeight = 80; 7 | 8 | void setup() { 9 | fullScreen(); //Sets the program to run in full screen mode 10 | 11 | } 12 | 13 | void draw() { 14 | if (mouseX < halfScreenWidth ) { 15 | 16 | fill(255, 0, 0); //set color to red 17 | } else { 18 | 19 | fill(0, 0, 255); //set color to blue 20 | } 21 | 22 | ellipse(mouseX, mouseY, ballWidth, ballHeight); //draw ellipse at touch position 23 | } 24 | -------------------------------------------------------------------------------- /change_ball_color/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /change_ball_color2/change_ball_color2.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | 4 | int oneThirdScreenWidth = ***; // maxX/3 = *** 5 | 6 | int twoThirdScreenWidth = ***; // (⅔)*maxX = *** 7 | 8 | int ballWidth = 80; 9 | int ballHeight = 80; 10 | 11 | void setup() { 12 | fullScreen(); //Sets the program to run in full screen mode 13 | 14 | } 15 | 16 | void draw() { 17 | if (mouseX < oneThirdScreenWidth ) { 18 | 19 | fill(255, 0, 0); //set color to red 20 | } else if (mouseX < twoThirdScreenWidth ) { 21 | 22 | fill(0, 255, 0); //set color to green 23 | } else { 24 | 25 | fill(0, 0, 255); //set color to blue 26 | } 27 | 28 | ellipse(mouseX, mouseY, ballWidth, ballHeight); //use variable 29 | } 30 | -------------------------------------------------------------------------------- /change_ball_color2/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /circle/circle.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | //x position of the ball is exactly half of the x axis 4 | int ballX = ***; // maxX/2 = *** 5 | 6 | //y position of the ball is exactly half of the y axis 7 | int ballY = ***; // maxY/2 = *** 8 | 9 | int diameter = 80; //diameter of circle 10 | 11 | void setup() { 12 | fullScreen(); //Sets the program to run in full screen mode 13 | 14 | } 15 | 16 | void draw() { 17 | background(0); 18 | 19 | circle(ballX, ballY, diameter); //call circle function 20 | } 21 | 22 | //Draws circle 23 | void circle(int x, int y, int diameter) { 24 | fill(0, 255, 0); 25 | 26 | ellipse(x, y, diameter, diameter); 27 | } 28 | -------------------------------------------------------------------------------- /circle/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /concentric_circles_for_loop/concentric_circles_for_loop.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | void setup() 7 | { 8 | fullScreen(); //Sets the program to run in full screen mode 9 | 10 | noFill(); //makes shapes drawn below have no color 11 | 12 | float circleX = screenWidth/2; 13 | float circleY = screenHeight/2; 14 | 15 | for (float diameter = 100; diameter < screenHeight; diameter = diameter + 100) { 16 | ellipse (circleX, circleY, diameter, diameter); 17 | } 18 | } 19 | 20 | void draw() { 21 | } 22 | -------------------------------------------------------------------------------- /concentric_circles_for_loop/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /concentric_circles_no_loop/concentric_circles_no_loop.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | void setup() 7 | { 8 | fullScreen(); //Sets the program to run in full screen mode 9 | 10 | noFill(); //makes shapes drawn below have no color 11 | 12 | float diameter = 100; 13 | 14 | float circleX = screenWidth/2; 15 | float circleY = screenHeight/2; 16 | 17 | ellipse (circleX, circleY, diameter, diameter); 18 | 19 | diameter = diameter + 100; //increment diameter by 100 20 | ellipse (circleX, circleY, diameter, diameter); 21 | 22 | diameter = diameter + 100; //increment diameter by 100 23 | ellipse (circleX, circleY, diameter, diameter); 24 | 25 | diameter = diameter + 100; //increment diameter by 100 26 | ellipse (circleX, circleY, diameter, diameter); 27 | 28 | diameter = diameter + 100; //increment diameter by 100 29 | ellipse (circleX, circleY, diameter, diameter); 30 | 31 | diameter = diameter + 100; //increment diameter by 100 32 | ellipse (circleX, circleY, diameter, diameter); 33 | 34 | diameter = diameter + 100; //increment diameter by 100 35 | ellipse (circleX, circleY, diameter, diameter); 36 | 37 | diameter = diameter + 100; //increment diameter by 100 38 | ellipse (circleX, circleY, diameter, diameter); 39 | } 40 | 41 | void draw() { 42 | } 43 | -------------------------------------------------------------------------------- /concentric_circles_no_loop/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /concentric_circles_while_loop/concentric_circles_while_loop.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | void setup() 7 | { 8 | fullScreen(); //Sets the program to run in full screen mode 9 | 10 | noFill(); //makes shapes drawn below have no color 11 | 12 | float diameter = 100; 13 | 14 | float circleX = screenWidth/2; 15 | float circleY = screenHeight/2; 16 | 17 | while (diameter < screenHeight) { 18 | ellipse (circleX, circleY, diameter, diameter); 19 | diameter = diameter + 100; //increment diameter by 100 20 | } 21 | } 22 | 23 | void draw() { 24 | } 25 | -------------------------------------------------------------------------------- /concentric_circles_while_loop/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /ellipse_array/ellipse_array.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenHeight = ***; //set to your maxY 4 | 5 | int noOfPositions = 5; 6 | float [] xPositions = new float[noOfPositions]; 7 | 8 | void setup() 9 | { 10 | fullScreen(); //Sets the program to run in full screen mode 11 | 12 | background(255); 13 | 14 | float circleY = screenHeight/2; 15 | float diameter = 100; 16 | 17 | xPositions[0] = 100; 18 | xPositions[1] = 200; 19 | xPositions[2] = 300; 20 | xPositions[3] = 400; 21 | xPositions[4] = 500; 22 | noFill(); 23 | 24 | ellipse (xPositions[0], circleY, diameter, diameter); 25 | ellipse (xPositions[1], circleY, diameter, diameter); 26 | ellipse (xPositions[2], circleY, diameter, diameter); 27 | ellipse (xPositions[3], circleY, diameter, diameter); 28 | ellipse (xPositions[4], circleY, diameter, diameter); 29 | } 30 | 31 | void draw() { 32 | } 33 | -------------------------------------------------------------------------------- /ellipse_array/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /ellipse_array_loops/ellipse_array_loops.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenHeight = ***; //set to your maxY 4 | 5 | int noOfPositions = 5; 6 | float [] xPositions = new float[noOfPositions]; 7 | 8 | void setup() 9 | { 10 | fullScreen(); //Sets the program to run in full screen mode 11 | 12 | background(255); 13 | 14 | noFill(); //makes shapes drawn below have no color 15 | 16 | float circleY = screenHeight/2; 17 | float diameter = 100; 18 | 19 | for (int i = 0; i < noOfPositions; i = i + 1) { 20 | xPositions[i] = 100 * (i+1); 21 | } 22 | 23 | noFill(); 24 | 25 | for (int i = 0; i < noOfPositions; i = i + 1) { 26 | ellipse (xPositions[i], circleY, diameter, diameter); 27 | } 28 | 29 | } 30 | 31 | void draw() { 32 | } 33 | -------------------------------------------------------------------------------- /ellipse_array_loops/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /left_right_color_control/left_right_color_control.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int halfScreenWidth = ***; // maxX/2 = *** 4 | 5 | void setup() { 6 | fullScreen(); //Sets the program to run in full screen mode 7 | 8 | } 9 | 10 | void draw() { 11 | if (mouseX < halfScreenWidth ) { 12 | 13 | background(255, 0, 0); //set color to red 14 | } else { 15 | 16 | background(0, 0, 255); //set color to blue 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /left_right_color_control/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /move_paddle/move_paddle.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | 5 | //x position of the paddle is exactly half of the x axis 6 | int paddleX = ***; // maxX/2 = *** 7 | 8 | //y position of the paddle is one-fourth of the y axis 9 | int paddleY= ***; // maxY/4 = *** 10 | 11 | int paddleWidth = 90; 12 | int paddleHeight= 300; 13 | 14 | void setup() { 15 | fullScreen(); //Sets the program to run in full screen mode 16 | 17 | } 18 | 19 | void draw() { 20 | background(0); 21 | 22 | movePaddle(); //move padde horizontally 23 | 24 | fill(0, 255, 0); //set to green 25 | 26 | rect (paddleX, paddleY, paddleHeight, paddleWidth); //draw left paddle 27 | } 28 | 29 | //Move paddle horizontally 30 | void movePaddle() { 31 | 32 | paddleX = constrain(mouseX, 0, screenWidth - paddleHeight); //constrain paddle to drawing window 33 | } 34 | -------------------------------------------------------------------------------- /move_paddle/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /paddle/paddle.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenHeight = ***; 4 | 5 | Paddle paddle = new Paddle(***, ***, 90, 300); //new Paddle object 6 | 7 | void setup() 8 | { 9 | fullScreen(); //Sets the program to run in full screen mode 10 | 11 | } 12 | 13 | void draw() 14 | { 15 | background (0); //set background to black 16 | paddle.display(); 17 | paddle.move(); 18 | } 19 | 20 | //Paddle class 21 | class Paddle//Paddle class 22 | { 23 | //fields: variables within class 24 | float x, y, w, h; //positions, width and height 25 | 26 | //Paddle constructor 27 | Paddle (float paddleX, float paddleY, float paddleWidth, float paddleHeight) 28 | { 29 | //initializations 30 | x = paddleX; 31 | y = paddleY; 32 | w = paddleWidth; 33 | h = paddleHeight; 34 | } 35 | 36 | //Displays the paddle 37 | void display() 38 | { 39 | fill (0, 255, 0); //set color to green 40 | stroke (0, 0, 255); //set outline to blue 41 | rect (x, y, w, h); //draw paddle 42 | } 43 | 44 | //Move paddle 45 | void move() 46 | { 47 | y = constrain(mouseY, 0, screenHeight - h); //constrain paddle to drawing window 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /paddle/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /screen_grapher/screen_grapher.pde: -------------------------------------------------------------------------------- 1 | float x, y; 2 | 3 | void setup() 4 | { 5 | fullScreen(); 6 | background(255, 255, 0); 7 | } 8 | 9 | void draw() 10 | { 11 | strokeWeight(1); 12 | stroke(200); 13 | x = 0; 14 | while (x < width) 15 | { 16 | line(x, 0, x, height); 17 | x += 5; 18 | } 19 | 20 | y = 0; 21 | while (y < height) 22 | { 23 | line(0, y, width, y); 24 | y += 5; 25 | } 26 | 27 | stroke(0); 28 | strokeWeight(2); 29 | arrow(width-10, 0, width, 0); 30 | arrow(0, height-10, 0, height); 31 | 32 | fill(0); 33 | textSize(25); 34 | text("O", 7, 25); 35 | textSize(25); 36 | for (int i = 50; i < width-10; i+=50) 37 | { 38 | line(i, 0, i, 10); 39 | if (i > width - 50) 40 | break; 41 | if (i % 100 == 0) 42 | { 43 | text(i, i-15, 30); 44 | } 45 | } 46 | 47 | for (int i = 50; i < height-10; i+=50) 48 | { 49 | line(0, i, 10, i); 50 | if (i > height - 50) 51 | break; 52 | if (i % 100 == 0) 53 | { 54 | text(i, 20, i+7); 55 | } 56 | } 57 | 58 | strokeWeight(3); 59 | line(0, 0, width, 0); 60 | line(0, 0, 0, height); 61 | 62 | strokeWeight(6); 63 | arrow(width/2, 100, width - 100, 100); 64 | text("maxX = ", width-width/6, 150); 65 | text(width, width-width/9, 150); 66 | arrow(100, height/2, 100, height - 100); 67 | text("maxY = ", 100, height-height/18); 68 | text(height, 200, height-height/18); 69 | 70 | text("(maxX,maxY) = (", width/2 - width/10, height/2+height/40); 71 | text(width, width/2 + width/100, height/2+height/40); 72 | text(",", width/2 + width/22, height/2+height/40); 73 | text(height, width/2 + width/20, height/2+height/40); 74 | text(")", width/2 + width/12, height/2+height/40); 75 | 76 | textSize(60); 77 | text("Take note of maxX and maxY", width/2 - width/5, height/2-height/18); 78 | } 79 | 80 | void arrow(int x1, int y1, int x2, int y2) { 81 | line(x1, y1, x2, y2); 82 | pushMatrix(); 83 | translate(x2, y2); 84 | float a = atan2(x1-x2, y2-y1); 85 | rotate(a); 86 | line(0, 0, -15, -15); 87 | line(0, 0, 15, -15); 88 | popMatrix(); 89 | } 90 | -------------------------------------------------------------------------------- /screen_grapher/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /shapes/shapes.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | void setup() //runs once 4 | { 5 | fullScreen(); //Sets the program to run in full screen mode 6 | 7 | } 8 | 9 | void draw() //runs continuously until the program is stopped 10 | { 11 | background(200); //sets the background grey 12 | 13 | rect(***, ***, ***, ***); //draws a rectangle 14 | 15 | 16 | ellipse(***, ***, ***, ***); //draws an ellipse 17 | 18 | 19 | textSize(20); //set text size to 20 20 | 21 | 22 | text("This is my first program", ***, ***); //writes text on screen 23 | } 24 | -------------------------------------------------------------------------------- /shapes/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /square/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /square/square.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | //x position of the rectangle is exactly half of the x axis 4 | int rectX = ***; // maxX/2 = *** 5 | 6 | //y position of the rectangle is one-fourth of the y axis 7 | int rectY = ***; // maxY/4 = *** 8 | 9 | //x position of the text is exactly half of the x axis 10 | int textX = ***; // maxX/2 = *** 11 | 12 | //y position of the text is exactly half of the y axis 13 | int textY = ***; // maxY/2 = *** 14 | 15 | int len = 100; //length of square 16 | int calculatedArea; //variable to hold calculated area 17 | 18 | void setup(){ 19 | fullScreen(); //Sets the program to run in full screen mode 20 | 21 | } 22 | 23 | void draw(){ 24 | background(0); 25 | 26 | calculatedArea = square(rectX, rectY, len); //call square function 27 | 28 | textSize(30); 29 | text (calculatedArea, textX, textY); //print calculated area on the screen 30 | } 31 | 32 | //Draws square 33 | int square(int x, int y, int w){ 34 | int area = 0; 35 | fill(0,0,255); 36 | rect(x,y,w,w); 37 | area = w*w; //calculate area 38 | return area; //return area 39 | } 40 | -------------------------------------------------------------------------------- /start_moving_ball/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /start_moving_ball/start_moving_ball.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | //x position of the ball is exactly half of the x axis 7 | int ballX = ***; // maxX/2 = *** 8 | 9 | //y position of the ball is exactly half of the y axis 10 | int ballY = ***; // maxY/2 = *** 11 | 12 | int ballWidth = 80; //width of ball 13 | int ballHeight = 80; //height of ball 14 | int xSpeed = 5; //ball's horizontal speed 15 | int ySpeed = 5; //ball's vertical speed 16 | int radius = 40; //since half the width or the height of the ball is the radius 17 | 18 | boolean gameOn = false; //new variable to start ball's movement 19 | 20 | void setup() //runs once 21 | { 22 | fullScreen(); //Sets the program to run in full screen mode 23 | 24 | } 25 | 26 | void draw() //runs forever 27 | { 28 | background(0); 29 | fill(255); 30 | ellipse(ballX, ballY, ballWidth, ballHeight); 31 | 32 | //Check if mouse is pressed, set gameOn to true 33 | if (mousePressed) { 34 | gameOn = true; 35 | } 36 | 37 | //Move ball 38 | if (gameOn) { 39 | ballX = ballX+xSpeed; 40 | ballY = ballY+ySpeed; 41 | } 42 | 43 | //Check if ball hits left or right walls 44 | if ((ballX-radius < 0) || (ballX+radius) > screenWidth) { 45 | 46 | xSpeed = xSpeed * -1; //Reverse direction 47 | } 48 | //Check if ball hits top or bottom walls 49 | if ((ballY-radius < 0) || (ballY+radius) > screenHeight) { 50 | 51 | ySpeed = ySpeed * -1; //Reverse direction 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /wanderer_list/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /wanderer_list/wanderer_list.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | int numOfWanderers = 10; 7 | Wanderer[] wanderers = new Wanderer[numOfWanderers]; 8 | 9 | void setup() 10 | { 11 | fullScreen(); //Sets the program to run in full screen mode 12 | background(0); 13 | int diameter = 20; 14 | float wandererX = screenWidth/2; 15 | float wandererY = screenHeight/2; 16 | 17 | // Create wanderers at the center 18 | for (int i = 0; i < numOfWanderers; i++) { 19 | wanderers[i] = new Wanderer(wandererX, wandererY, diameter); 20 | } 21 | } 22 | 23 | void draw() 24 | { 25 | //Draw and display the i-th wanderer 26 | for (int i = 0; i < numOfWanderers; i++) { 27 | wanderers[i].display(); 28 | wanderers[i].move(); 29 | } 30 | } 31 | 32 | //Wanderer Class 33 | class Wanderer { 34 | //positions and diameter of the wanderer 35 | float x; 36 | float y; 37 | float d; 38 | 39 | float redColor; 40 | float greenColor; 41 | float blueColor; 42 | //Initialize a Wanderer to be at the given coordinates 43 | Wanderer(float x0, float y0, float d0) 44 | { 45 | x = x0; 46 | y = y0; 47 | d = d0; 48 | redColor = random(0, 255); 49 | greenColor = random(0, 255); 50 | blueColor = random(0, 255); 51 | } 52 | 53 | // Move by random steps in x and y 54 | void move() { 55 | x = constrain(x+random(-10, 10), 0, screenWidth); 56 | y = constrain(y+random(-10, 10), 0, screenHeight); 57 | } 58 | 59 | //Draw wander 60 | void display() { 61 | fill(redColor, greenColor, blueColor); 62 | ellipse(x, y, d, d); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /wanderers/sketch.properties: -------------------------------------------------------------------------------- 1 | #Sun Feb 17 19:49:17 EST 2019 2 | manifest.sdk.target=26 3 | manifest.orientation=landscape 4 | manifest.version.name=1.0 5 | manifest.sdk.min=17 6 | manifest.permissions= 7 | manifest.version.code=1 8 | manifest.package= 9 | manifest.label= 10 | -------------------------------------------------------------------------------- /wanderers/wanderers.pde: -------------------------------------------------------------------------------- 1 | //maxX = ***, maxY = *** 2 | 3 | int screenWidth = ***; //set to your maxX 4 | int screenHeight = ***; //set to your maxY 5 | 6 | Wanderer wanderer1, wanderer2; 7 | 8 | void setup() 9 | { 10 | fullScreen(); //Sets the program to run in full screen mode 11 | background(0); 12 | float diameter = 20; 13 | float wandererX = screenWidth/2; 14 | float wandererY = screenHeight/2; 15 | 16 | // Create wanderers at the center 17 | wanderer1 = new Wanderer(wandererX, wandererY, diameter); 18 | wanderer2 = new Wanderer(wandererX, wandererY, diameter); 19 | } 20 | 21 | void draw() 22 | { 23 | wanderer1.display(); 24 | wanderer2.display(); 25 | wanderer1.move(); 26 | wanderer2.move(); 27 | } 28 | 29 | //Wanderer Class 30 | class Wanderer { 31 | //positions and diameter of the wanderer 32 | float x; 33 | float y; 34 | float d; 35 | 36 | float redColor; 37 | float greenColor; 38 | float blueColor; 39 | //Initialize a Wanderer to be at the given coordinates 40 | Wanderer(float x0, float y0, float d0) 41 | { 42 | x = x0; 43 | y = y0; 44 | d = d0; 45 | redColor = random(0, 255); 46 | greenColor = random(0, 255); 47 | blueColor = random(0, 255); 48 | } 49 | 50 | // Move by random steps in x and y 51 | void move() { 52 | x = constrain(x+random(-10, 10), 0, screenWidth); 53 | y = constrain(y+random(-10, 10), 0, screenHeight); 54 | } 55 | 56 | //Draw wander 57 | void display() { 58 | fill(redColor, greenColor, blueColor); 59 | ellipse(x, y, d, d); 60 | } 61 | } 62 | --------------------------------------------------------------------------------