2020年3月31日 星期二

懶嵐\(。∀ ° )/ week04 陣列繪圖 (文長注意)

上個禮拜老師用Processing幫我們複習了二維陣列

基本型就長這個樣子
然後我搞出了一隻苦力怕

沒有錯啦
這種風格就稱為像素圖
於是...


進入正題\(。∀ ° )/


東方Project是知名日本同人社團上海アリス幻樂団
所開發出的系列作品

今天的作品就是
東方Project的主角之一:
博麗靈夢

先找到一張Q版的像素圖
稍微切片一下

找好配色

然後就是摧殘眼睛的地獄


歷經了那麼久把數字都key進去之後

靈夢就完成ㄌ  灑花~

結論: 不做死就不會死,好累_(:з」∠)_

2020年3月28日 星期六

Week04 某團主唱聽說是個小提琴

1.每點1下左鍵有隨機顏色的球掉落

2.新增隨機大小的球
3.新增按住左鍵球會停住並變大顆

4.變數改成Claas Bubble{}















































5.建立名為drawAndUpdate取代原先畫圓




















6.新增New Tab將4.5.做的放進去,簡化排版



7.在2階陣列中畫圖


8.改成可以直接點在格子上畫圖,在按一下紅色會消失

2020年3月26日 星期四

Programming-week04

彩色小球掉落
彩色 控制大小飛起
程式碼:
int []x = new int[1000];
int []y = new int[1000];
int []r = new int[1000];
color [] c = new color[1000];
int n =0;
void setup(){
    size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],r[i]);
    y[i]--;
  }
  if(mousePressed)r[n-1]++;
}
void mousePressed(){
  x[n] = mouseX;
  y[n] = mouseY;
  r[n]=10;
  c[n] = color(random(255), random(255), random(255));
  n++;
}

------------------------------------------------------
class Bubble{
  int x;
  int y;
  int r;
  color c;
  Bubble(int _x, int _y, int _r){
    x=_x; y=_y; r=_r;
    c = color(random(255),random(255),random(255) );
}
void drawAndUpdate(){
  fill(c);
  circle(x,y,r);
  y--;
}
}
Bubble [] b=new Bubble[1000];
int n =0;
void setup(){
    size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    b[i].drawAndUpdate();
  }
  if(mousePressed) b[n-1].r++;
}
void mousePressed(){
  b[n] = new Bubble(mouseX,mouseY,10);
  n++;
}
--------------------------------------------------
設計迷宮
程式碼:
size(300,300);

int [][]table={ {0,0,0,0,0},
                 {1,1,1,0,1},
                 {0,0,1,1,0},
                 {0,0,1,1,0} };
               
  for(int i=0;i<4;i++){
   for(int j=0;j<5;j++){
      if(table[i][j]==1)fill(255,0,0);
      else fill(128);
      rect( j*50, i*50, 50, 50);
  }
}


自走迷宮
程式碼:
int [][]table=new int[6][6];

void setup(){
    size(300,300);
}
void draw(){
  background(128);
  for(int i=0;i<6;i++){//vs.y
   for(int j=0;j<6;j++){//vs.y
      if(table[i][j]==1)fill(255,0,0);
      else fill(128);
      rect( j*50, i*50, 50, 50);
   }
  }
 }
void mousePressed(){
  int x = (mouseX)/50;
  int y = (mouseY)/50;
  table[y][x]=1;
}


彩色球



一開始先寫星期一考試的題目,小葉老師用心的解法詮釋一次給我們看




這次的程式碼跟上周的隕石大同小異,多了讓小球可以變彩色的程式碼

這裡是常闇的重修地獄録 第三之卷

今天的課程主要目的是做出七彩的大小泡泡~~

首先最重要的結構先出來......

注意~~這裡最上面兩行是Java與C#的陣列宣告方式

接著將之前的「能讓泡泡一直出現的程式碼」放上來......

接著就讓泡泡能隨機擁有不同的顏色吧~~

既然都說是泡泡,那當然要能吹嘛~~改變球體的大小就用按滑鼠的時間決定吧......

不過這次的程式碼要設定的陣列似乎有點多,有沒有辦法可以簡化?

答案是肯定的!不過這要用上一種名為「資料結構」的概念。

簡而言之,「資料結構」是一種整合的概念,將許多的的概念,將許多相近類型的程式碼整合為一個區塊,這樣也能簡化很多必須重複輸入的部分。

這就是最後的結果啦~~

接著是今天的程式碼

MAIN:

bubble[] b = new bubble[1000];
int n = 0;
void setup()
{
  size(400 ,400);
}
void draw()
{
  background(255);
  for(int i = 0 ;i < n ;i++)
  {
    b[i].drawAndUpdate();
  }
  if(mousePressed) b[n-1].r++;
}
void mousePressed()
{
  b[n] = new bubble(mouseX ,mouseY ,10);
  n++;
}

Class bubble:

class bubble
{
  int x;
  int y;
  int r;
  color c;
  bubble(int _x ,int _y ,int _r)
  {
    x = _x; y = _y; r = _r;
    c = color(random(255) ,random(255) ,random(255));
  }
  void drawAndUpdate()
  {
    fill(c);
    circle(x ,y ,r);
    y--;
  }
}

ㄎㄟ哩文

我爸的英文名字:Kelevin

彩色球球

程式碼:
int []x=new int[1000];
int []y=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],40);
    y[i]+=2;
  }
}
void mousePressed(){
  x[n]=mouseX;
  y[n]=mouseY;
  c[n]=color(random(255),random(255),random(255));
  n++;
}
氣球
程式碼:
int []x=new int[1000];
int []y=new int[1000];
int []r=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],r[i]);
    y[i]--;
  }
  if(mousePressed) r[n-1]++;
}
void mousePressed(){
  x[n]=mouseX;
  y[n]=mouseY;
  r[n]=10;
  c[n]=color(random(255),random(255),random(255));
  n++;
}
氣球VER2:
class Bubble{
  int x;
  int y;
  int r;
  color c;
}
Bubble[] b=new Bubble[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(b[i].c);
    circle(b[i].x,b[i].y,b[i].r);
    b[i].y--;
  }
  if(mousePressed) b[n-1].r++;
}
void mousePressed(){
  b[n]= new Bubble();
  b[n].x=mouseX;
  b[n].y=mouseY;
  b[n].r=10;
  b[n].c=color(random(255),random(255),random(255));
  n++;
}

emmmm...._week04

( • ̀ω•́ )
交了新的用語"random&color"
變成向上能放大的氣球了
emmmm.......微妙的東西

Week04



程式碼:
int []x=new int[1000];
int []y=new int[1000];
color []c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],30);
    y[i]+=2;
  }
}
void mousePressed(){
  x[n]=mouseX;
  y[n]=mouseY;
  c[n]=color(random(255),random(255),random(255));
  n++;
}



程式碼:
int []x=new int[1000];
int []y=new int[1000];
int []r=new int[1000];
color []c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],r[i]);
    y[i]--;
  }
  if(mousePressed) r[n-1]++;
}
void mousePressed(){
  x[n]=mouseX;
  y[n]=mouseY;
  r[n]=10;
  c[n]=color(random(255),random(255),random(255));
  n++;
}



程式碼:

class Bubble{
  int x;
  int y;
  int r;
  int c;
}
Bubble [] b=new Bubble[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(b[i].c);
    circle(b[i].x,b[i].y,b[i].r);
    b[i].y--;
  }
  if(mousePressed) b[n-1].r++;
}
void mousePressed(){
  b[n]=new Bubble();
  b[n].x=mouseX;
  b[n].y=mouseY;
  b[n].r=10;
  b[n].c=color(random(255),random(255),random(255));
  n++;
}

分成兩頁程式碼



程式碼:
(1)
Bubble [] b=new Bubble[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    b[i].drawAndUpdate();
  }
  if(mousePressed) b[n-1].r++;
}
void mousePressed(){
  b[n]=new Bubble(mouseX,mouseY,10);
  n++;
}

(2)
class Bubble{
  int x,y;
  int r;
  color c;
  Bubble(int _x,int _y,int _r){
    x=_x; y=_y;r=_r;
    c=color(random(255),random(255),random(255));
  }
  void drawAndUpdate(){
    fill(c);
    circle(x,y,r);
    y--;
  }
}



想睡的心與肥胖跟球球一起無限膨脹

Bubble [] b=new Bubble[1000];//set-->int []x=new int[1000]
int n=0;
void setup(){

  size(400,400);
}

void draw(){
  int i;
    background(255);
    for(i=0;i<n;i++)
    {
      b[i].drawAndUpdate();
    }
    if(mousePressed)
    {
      b[n-1].r++;
    }

 }

 void mousePressed(){
   b[n]= new Bubble(mouseX,mouseY,10);
   n++;


 }

上面是主程式啦
下面結構放到New Tab

class Bubble{//Struct(C)-->in JAVA turn into class
  int x,y,r;
  color c;

  Bubble(int _x, int _y, int _r){
 
    x=_x; y=_y; r=_r;
    c=color(random(255),random(255),random(255));
}


void drawAndUpdate(){

     fill(c);
     circle(x,y,r);
     y--;
  }
}


然後你就可以得到球球
跟我沒救的體重和絕望的心一直膨脹嗷嗷嗷嗷

阿凱-week04

Week 04
------------------------------


這邊的程式碼跟上個禮拜大同小異,主要是要 執行以下
按一下生一顆顏色隨機大小固定的球往下墜落
  
c[n]=color(random(255),random(255),random(255));

random 是說隨機顏色 0~255 
--------------------------------------------------------------------------------------------------------------------------



跟上面不一樣的地方在於

int []r=new int[1000];
[  設定圓的半徑 ]
r[n]=10;
[ 起始的半徑 ]
circle(x[i],y[i],r[i]);
[ 圓的起始位置 ]
if( mousePressed )r[n-1]++;
[ 半徑++ ]

--------------------------------------------------------------------------------------------------------------------------

[ ]  [ ] 是2*2的陣列寫法
程式內容主要是要讓陣列裡面有1的值就變紅色
要注意 
 rect( j*50 , i*50 , 50 , 50);
陣列左邊是 i 右邊是 j
但是rect  j 跟 i 調換

week4

今天第一節老師教了之前練習的程式
讓我們多加複習了以前打過的







今天第二堂上課教了一個球球掉下來的程式碼
我覺得超酷。因為很少可以做到可以動的
每次打完都會讓我很認真思考這些程式的魔力
倒底如何打出這些程式,能讓東西動起來

混分仔日常

`

int []x=new int[1000];
int []y=new int[1000];
color[] c = new color[1000];
int n=0;
void setup()
{
  size(400,400);
}
void draw()
{
  background(255);
  for (int i=0;i<n;i++)
  {
    fill(c[i]);
    circle (x[i],y[i],30);
    y[i]+=2;
  }
}
void mousePressed()
{
  x[n]=mouseX;
  y[n]=mouseY;
  c[n]=color(random(255),random(255),
  random(255));
  n++;
}
彩色墜落



int []x=new int[1000];
int []y=new int[1000];
color[]c=new color[1000];
int []r=new int [1000];
int n=0;
void setup()
{
  size(400,400);
}
void draw()
{
  background(255);
  for (int i=0;i<n;i++)
  {
    fill(c[i]);
    circle (x[i],y[i],r[i]);
    y[i]--;
  }
  if (mousePressed)r[n-1]++;
}
void mousePressed()
{
  x[n]=mouseX;
  y[n]=mouseY;
  r[n]=10;
  c[n]=color(random(255),random(255),
  random(255));
  n++;
}
漂浮變大的球球

邪惡微笑教主征服地球計畫W4:)把隕石變成彩色!!!

Weeeeeek4-彩色隕石
進攻地球3個禮拜了,慢慢發現地球人有戒心了,普通的隕石已經不管用了,深思熟慮之後我命令手下把隕石漆上七彩的顏色,降低地球人的戒心,不知道效果如何。
程式碼:
int []x=new int[1000];
int []y=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){///我的手下圖顏色的部分
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],30);
    y[i]+=2;
  }
}
void mousePressed(){///這裡跟一開始的隕石一樣!
  x[n]=mouseX;
  y[n]=mouseY;
  c[n]=color(random(255),random(255),random(255));
  n++;
}
圖片:
但但但但但但但是....BBBBBBBut!
地球人開始反擊了
他們建造了能集器發射出強大能量的武器,這樣我的隕石會被一一擊毀,
我得請我的工程團隊幫我好好分析地球人們武器的成分了...
逼逼逼啵啵啵~~~~(((一段時間後....
電腦:分析完成
程式碼:
int []x=new int[1000];
int []y=new int[1000];
int []r=new int[1000];
color[]c=new color[1000];
int n=0;
void setup(){
  size(400,400);
}
void draw(){
  background(255);
  for(int i=0;i<n;i++){
    fill(c[i]);
    circle(x[i],y[i],r[i]);
    y[i]--;
  }
  if(mousePressed) r[n-1]++;
}
void mousePressed(){
  x[n]=mouseX;
  y[n]=mouseY;
  r[n]=10;
  c[n]=color(random(255),random(255),random(255));
  n++;
}
圖片:
居然!!!!跟我的彩色隕石差不多,多了常壓放大跟更改了移動方向,一定是哪裡出了問題!!!!
下次我一定要好好肅清我的團隊!!!!
番外篇....代更..

size(300,300);
int [][] table={{0,0,0,0,0},
                {1,1,1,0,1},
                {0,0,1,1,0},
                {0,0,1,1,0}};
for(int i=0;i<4;i++){
  for(int j=0;j<5;j++){
  if(table[i][j]==1 )fill(255,0,0);
  else fill(128);
  rect(j*50,i*50,50,50);
  }
}

彩色球球week04

我們先練習了禮拜一的題目,把數字分開印、函式呼叫的質數判斷、擲骰統計次數等等



然後複習一下上週教的,球球的移動,這次是變色,往上飛放大