1.畫出五子棋
void setup() {
size(800, 800);
}
void draw() {
background(#F0D079);使用 Tool- Color Selector, 挑出你要的顏色, 可用 R,G,B 來描述,也可用 #0B33FF 之類的像亂碼的數字來設定顏色
noFill();
strokeWeight(6); 在 Help-Reference 裡面可以找 stroke 相關的功能
rect(50, 50, 700, 700);
strokeWeight(1);
for (int i=0;i<9;i++) {
line(50, 50+i*80, 750, 50+i*80); line() 是用來配上不同的 strokeWeight() 粗細
line(50+i*80, 50, 50+i*80, 750);
}
}
int nowX, nowY;
void setup() {
size(800, 800);
}
void draw() {
background(#F0D079);
noFill();
strokeWeight(6);
rect(50, 50, 700, 700);
strokeWeight(1);
for (int i=0;i<9;i++) {
line(50, 50+i*80, 750, 50+i*80);
line(50+i*80, 50, 50+i*80, 750);
}
fill(255,0,0);
rect(nowX*80+50, nowY*80+50, 80,80);
}
void mouseMoved(){
nowX = (mouseX-50)/80;
nowY = (mouseY-50)/80;
println("mouseX:" + mouseX+"mouseY:"+mouseY+"nowX:"+nowX+"nowY:"+nowY);
}
int nowX, nowY;
int [][] array = new int [8][8];宣告陣列
void setup() {
size(800, 800);
}
void draw() {
background(#F0D079);
noFill();不會蓋過原本顏色
strokeWeight(6);
rect(50, 50, 700, 700);
strokeWeight(1);
for (int i=0;i<9;i++) {
line(50, 50+i*80, 750, 50+i*80);
line(50+i*80, 50, 50+i*80, 750);
}
fill(24, 120, 219);配上淡藍色
rect(nowX*80+50, nowY*80+50, 80, 80);
fill(237,138,245);配上淡紫色
for (int i=0;i<8;i++) {使用for迴圈,來進行陣列的比較、畫圖
for (int j=0;j<8;j++) {
if (array[i][j]==1) rect(i*80+50, j*80+50, 80, 80);
}
}
}
void mousePressed() { 使用函式來將mouse改變array[i][j]裡面的值
array[nowX][nowY]=1;
}
void mouseMoved() {
nowX = (mouseX-50)/80;
nowY = (mouseY-50)/80;
println("mouseX:" + mouseX+"mouseY:"+mouseY+"nowX:"+nowX+"nowY:"+nowY);
}
int nowColor=1;
int nowX, nowY;
int [][] array = new int [8][8];
void setup() {
size(800, 800);
}
void draw() {
background(#F0D079);
noFill();
strokeWeight(6);
rect(50, 50, 700, 700);
strokeWeight(1);
for (int i=0;i<9;i++) {
line(50, 50+i*80, 750, 50+i*80);
line(50+i*80, 50, 50+i*80, 750);
}
fill(24, 120, 219);
ellipse(nowX*80+50, nowY*80+50, 80, 80);
//rect(nowX*80+50, nowY*80+50, 80, 80);
//fill(237,138,245);
for (int i=0;i<8;i++) {
for (int j=0;j<8;j++) {
if (array[i][j]==1) {
fill(0);
ellipse(i*80+50, j*80+50, 80, 80);
}
if (array[i][j]==2) {
fill(255);
ellipse(i*80+50, j*80+50, 80, 80);
}
}
}
}
void mousePressed() {
array[nowX][nowY]=nowColor;
if (nowColor==1 ) nowColor=2;
else if (nowColor==2) nowColor=1;
}
void mouseMoved() {
nowX = (mouseX-50)/80;
nowY = (mouseY-50)/80;
println("mouseX:" + mouseX+"mouseY:"+mouseY+"nowX:"+nowX+"nowY:"+nowY);
}
int nowX, nowY;
int [][] array = new int [8][8];
void setup() {
size(800, 800);
}
void draw() {
background(#F0D079);
noFill();
strokeWeight(6);
rect(50, 50, 700, 700);
strokeWeight(1);
for (int i=0;i<9;i++) {
line(50, 50+i*80, 750, 50+i*80);
line(50+i*80, 50, 50+i*80, 750);
}
fill(24, 120, 219);
ellipse(nowX*80+50, nowY*80+50, 80, 80);
//rect(nowX*80+50, nowY*80+50, 80, 80);
//fill(237,138,245);
for (int i=0;i<8;i++) {
for (int j=0;j<8;j++) {
if (array[i][j]==1) {
fill(0);
ellipse(i*80+50, j*80+50, 80, 80);
}
if (array[i][j]==2) {
fill(255);
ellipse(i*80+50, j*80+50, 80, 80);
}
}
}
}
void mousePressed() {
array[nowX][nowY]=nowColor;
if (nowColor==1 ) nowColor=2;
else if (nowColor==2) nowColor=1;
}
void mouseMoved() {
nowX = (mouseX-50)/80;
nowY = (mouseY-50)/80;
println("mouseX:" + mouseX+"mouseY:"+mouseY+"nowX:"+nowX+"nowY:"+nowY);
}
這部影片是當放出音樂時,然後在影片上跑出圖案,如果當圖案通過終點線時,敲擊到,即可得分。
沒有留言:
張貼留言