Mreyes-Project-03-Dynamic-Drawing

project-03

//Mercedes Reys

//Section C 

//mreyes@andrew.cmu.edu

//Project-03

var x = 3;
var y = 3;

var dir = 1;

var speed = 7;
var speed2 = 7;

var radius = 4;
var circW = 10;

var x2 = x - 5
var y2 = y - 5
var x3 = x2 - 5
var y3 = y2 - 5

var dragging = false;

function setup() {
    createCanvas(400, 400);
    fill(255);
}

function draw() {
    var R = map(mouseY, 0, height, 0, 0);
    var G = map(mouseY, 0, height, 23, 0);
    var B = map(mouseY, 0, height, 54, 0);
    background(R,G,B);
   
    noStroke

    y += dir * speed;
    x += dir * speed;

    y2 += dir * speed2;
    x2 += dir * speed2;

    y3 += dir * speed2;
    x3 += dir * speed2;

  
    if (dragging) {
        x = mouseX;
        y = mouseY;
        
    }
  

    ellipse(x,y,circW,circW);
    ellipse(x2,y2,circW,circW);
    ellipse(x3,y3,circW,circW)

    if (x > width + radius){
    x = -radius
    y = -radius
    x2 = (-radius) - 5
    y2 = (-radius) -5
    x3 = (-radius) - 10 
    y3 = (-radius) - 10

  }
}

function mousePressed() {
    if (dist(x, y, mouseX, mouseY) < circW/2) {
        dragging = true;
        fill(14,216,227)
    }
}

function mouseReleased() {
    dragging = false;
    fill(255)
}



Try to catch a star!

The pong assignment was really challenging, but I used a lot of the concepts from that (such as if statements, boundary points, and animation) in this program. I attempted to simulate a shooting star while also making it a kind of game.

Leave a Reply