2024年11月25日 星期一

week12

 

week12


import processing.sound.*;

SoundFile sound1, sound2;


int playing = 2;

void setup() {

  size(640, 360);

  background(255);

  sound1 = new SoundFile(this, "Intro Song_Final.mp3");

  sound2 = new SoundFile(this, "In Game Music.mp3");

}


void draw() {

  if (sound1.isPlaying()) {

    playing = 1;

  } else if (sound2.isPlaying()) {

    playing = 2;

  } else {

    if (playing == 1) sound2.play();

    else sound1.play();

  }

}


week12-2
size(500,500);
noFill();
stroke(255,102,0);
line(340,80,40,40);
line(360,360,60,320);
stroke(0,0,0);
bezier(340,80,40,40,360,360,60,320);

week12-3
void setup() {
  size(500, 500);
}

PVector p0 = new PVector(340, 80);
PVector p1 = new PVector(40, 40);
PVector p2 = new PVector(360, 360);
PVector p3 = new PVector(60, 320);
float t = 0.0;
void draw() {
  background(255);
  noFill(); 
  stroke(255, 102, 0);
  line(340, 80, 40, 40);
  line(360, 360, 60, 320);
  stroke(0, 0, 0);
  bezier(340, 80, 40, 40, 360, 360, 60, 320);

  float x = p0.x * (1-t)*(1-t)*(1-t) + 3*p1.x * t * (1-t)*(1-t) + 3*p2.x * t * t * (1-t) + p3.x * t * t * t;
  float y = p0.y * (1-t)*(1-t)*(1-t) + 3*p1.y * t * (1-t)*(1-t) + 3*p2.y * t * t * (1-t) + p3.y * t * t * t;
  ellipse(x, y, 10, 10);
}

void mouseDragged() {
  t += 0.01 * (mouseX - pmouseX);
}


week12-4
void setup() {
  size(400, 400);
}

PVector p0 = new PVector(120, 80);
PVector p1 = new PVector(320, 20);
PVector p2 = new PVector(320, 300);
PVector p3 = new PVector(120, 300);
float t = 0.0;
void draw() {
  background(255);
  noFill(); // 以下是從文檔copy來的
  stroke(255, 102, 0);
  line(340, 80, 40, 40);
  line(360, 360, 60, 320);
  stroke(0, 0, 0);
  bezier(120, 80, 320, 20, 320, 300, 120, 300);

  float x = p0.x * (1-t)*(1-t)*(1-t) + 3*p1.x * t * (1-t)*(1-t) + 3*p2.x * t * t * (1-t) + p3.x * t * t * t;
  float y = p0.y * (1-t)*(1-t)*(1-t) + 3*p1.y * t * (1-t)*(1-t) + 3*p2.y * t * t * (1-t) + p3.y * t * t * t;
  ellipse(x, y, 10, 10);
}

void mouseDragged() {
  t += 0.01 * (mouseX - pmouseX);
}

week12-5
void setup() {
  size(400, 400);
}

PVector p0 = new PVector(120, 80);
PVector p1 = new PVector(320, 20);
PVector p2 = new PVector(320, 300);
PVector p3 = new PVector(120, 300);
float t0= 0.0;
void draw() {
  background(255);
  noFill(); // 以下是從文檔copy來的
  stroke(255, 102, 0);
  line(340, 80, 40, 40);
  line(360, 360, 60, 320);
  stroke(0, 0, 0);
  bezier(120, 80, 320, 20, 320, 300, 120, 300);
  
  for(float t=t0; t>=0; t-=0.025){
  
  float x = p0.x * (1-t)*(1-t)*(1-t) + 3*p1.x * t * (1-t)*(1-t) + 3*p2.x * t * t * (1-t) + p3.x * t * t * t;
  float y = p0.y * (1-t)*(1-t)*(1-t) + 3*p1.y * t * (1-t)*(1-t) + 3*p2.y * t * t * (1-t) + p3.y * t * t * t;
  ellipse(x, y, 10, 10);
  }
}

void mouseDragged() {
  t0+= 0.01 * (mouseX - pmouseX);
}


week12-6



沒有留言:

張貼留言