專案名稱 : 我要打星星
程式碼 :
arduino :
const int buttonPin1 = 2;
const int buttonPin2 = 4;
const int buttonPin3 = 6;
const int buttonPin4 = 8;
const int buttonPin5 = 10;
const int buttonPin = 6;
const int ledPin1 = 3;
const int ledPin2 = 5;
const int ledPin3 = 7;
const int ledPin4 = 9;
const int ledPin5 = 11;
int buttoni=0;
int buttoni1=0;
int buttoni2=0;
int buttoni3=0;
int buttoni4=0;
int buttoni5=0;
int switchi=0;
int ledi=0;
int uv=0;
int buttonState=0;
int bt=1;
int rdn=random(1, 6);
unsigned long time;
unsigned long time1;
unsigned long dtime1;
unsigned long dtime=1000;
void setup() {
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if(buttonState==HIGH)
{uv=1;
dtime=1000;
buttoni=0;
bt=1;
}
if(uv==1)
{
int i;
for(i=0;i<=2;i++){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
delay(1000);
if(i==2)
{
uv=2;
}
}
}
if(uv==2)
{
if(bt==1){
bt=0;
switch (rdn) {
case 1:
digitalWrite(ledPin1, HIGH);
break;
case 2:
digitalWrite(ledPin2, HIGH);
break;
case 3:
digitalWrite(ledPin3, HIGH);
break;
case 4:
digitalWrite(ledPin4, HIGH);
break;
case 5:
digitalWrite(ledPin5, HIGH);
break;
}
time = millis();
}
time1=millis();
dtime1=time1-time;
if(dtime1>=dtime&&bt==0){
uv=3;
}
buttoni1 = digitalRead(buttonPin1);
buttoni2 = digitalRead(buttonPin2);
buttoni3 = digitalRead(buttonPin3);
buttoni4 = digitalRead(buttonPin4);
buttoni5 = digitalRead(buttonPin5);
if(buttoni1==HIGH)
buttoni=1;
if(buttoni2==HIGH)
buttoni=2;
if(buttoni3==HIGH)
buttoni=3;
if(buttoni4==HIGH)
buttoni=4;
if(buttoni5==HIGH)
buttoni=5;
if(buttoni!=0&&buttoni!=rdn)
uv=3;
if(buttoni==rdn)
{
bt=1;
dtime-=20;
switch (buttoni) {
case 1:
digitalWrite(ledPin1, LOW);
break;
case 2:
digitalWrite(ledPin2, LOW);
break;
case 3:
digitalWrite(ledPin3, LOW);
break;
case 4:
digitalWrite(ledPin4, LOW);
break;
case 5:
digitalWrite(ledPin5, LOW);
break;
}
rdn=random(1, 6);
delay(dtime);
time=millis();
buttoni=0;
}
}
if(uv==3)
{
int i;
for(i=0;i<=2;i++){
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
digitalWrite(ledPin4, LOW);
digitalWrite(ledPin5, LOW);
delay(500);
if(i==2)
{
uv=0;
}
}
}
}
processing :
按中間的開始鍵會有加10分
import processing.serial.*;
Serial myPort;
int score = 0;
float count=1.5;
float count2=0;
void setup(){
size(600,400);
//background(255, 204, 0);
myPort = new Serial(this, "COM3", 9600);
float yrope = 100;
}
int value=0;
void draw(){
background(255, 204, 0);
fill(0);
textSize(150);
text(score, 300, 350);
while(myPort.available()>0)
{
value = myPort.read();
println(value);
if(value=='G'){
score+=10;//分數跳一次加10分
count2+=1;
}
}
}
圖片 :
心得:
在製作的過程中電線有時候一直短路很困擾,再連接processing 時一直出現狀況
燈有時候會一直閃不停QQ
原本processing是用來加分數,可是只做到傳送開始鈕的值~
我們利用遊戲時間即次數來控制遊戲結束與否。
2013年1月14日 星期一
2012年12月4日 星期二
Week12, HW11,
//#define c 3830 // 261 Hz
//#define d 3400 // 294 Hz
//#define e 3038 // 329 Hz
//#define f 2864 // 349 Hz
//#define g 2550 // 392 Hz
//#define a 2272 // 440 Hz
//#define b 2028 // 493 Hz
//#define C 1912 // 523 Hz
//#define R 0
// #include "pitches.h"
const int inPin1 = 7;
const int inPin2 = 6;
const int inPin3 = 5;
const int inPin4 = 4;
const int inPin5 = 3;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;
void setup() {
//pinMode(ledPin, OUTPUT);
pinMode(inPin1, INPUT);
pinMode(inPin2, INPUT);
pinMode(inPin3, INPUT);
pinMode(inPin4, INPUT);
pinMode(inPin5, INPUT);
}
void loop() {
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);
val3 = digitalRead(inPin3);
val4 = digitalRead(inPin4);
val5 = digitalRead(inPin5);
// Serial.println(val);
// delay(100);
//tone = 2028;
if(val1==HIGH){
tone(8,524,8);
}
if(val2==HIGH){
tone(8,588,8);
}
if(val3==HIGH){
tone(8,660,8);
}
if(val4==HIGH){
tone(8,698,8);
}
if(val5==HIGH){
tone(8,784,8);
}
}
2012年11月27日 星期二
WEEK12, HW10,
利用可變電阻 控制燈泡亮的速度
程式碼
/*
Analog Input
Demonstrates analog input by reading an analog sensor on analog pin 0 and
turning on and off a light emitting diode(LED) connected to digital pin 13.
The amount of time the LED will be on and off depends on
the value obtained by analogRead().
The circuit:
* Potentiometer attached to analog input 0
* center pin of the potentiometer to the analog pin
* one side pin (either one) to ground
* the other side pin to +5V
* LED anode (long leg) attached to digital output 13
* LED cathode (short leg) attached to ground
* Note: because most Arduinos have a built-in LED attached
to pin 13 on the board, the LED is optional.
Created by David Cuartielles
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
http://arduino.cc/en/Tutorial/AnalogInput
*/
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
// declare the ledPin as an OUTPUT:
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
//Serial.println(sensorValue);
// turn the ledPin on
digitalWrite(13, HIGH);
delay(sensorValue);
digitalWrite(12, HIGH);
delay(sensorValue);
digitalWrite(11, HIGH);
delay(sensorValue);
digitalWrite(10, HIGH);
delay(sensorValue);
digitalWrite(9, HIGH);
delay(sensorValue);
digitalWrite(8, HIGH);
delay(sensorValue);
digitalWrite(7, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
//turn the ledPin off:
digitalWrite(13, LOW);
delay(sensorValue);
digitalWrite(12, LOW);
delay(sensorValue);
digitalWrite(11, LOW);
delay(sensorValue);
digitalWrite(10, LOW);
delay(sensorValue);
digitalWrite(9, LOW);
delay(sensorValue);
digitalWrite(8, LOW);
delay(sensorValue);
digitalWrite(7, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
// read the value from the sensor:
sensorValue = analogRead(sensorPin);
//Serial.println(sensorValue);
// turn the ledPin on
digitalWrite(7, HIGH);
delay(sensorValue);
digitalWrite(8, HIGH);
delay(sensorValue);
digitalWrite(9, HIGH);
delay(sensorValue);
digitalWrite(10, HIGH);
delay(sensorValue);
digitalWrite(11, HIGH);
delay(sensorValue);
digitalWrite(12, HIGH);
delay(sensorValue);
digitalWrite(13, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(sensorValue);
//turn the ledPin off:
digitalWrite(7, LOW);
delay(sensorValue);
digitalWrite(8, LOW);
delay(sensorValue);
digitalWrite(9, LOW);
delay(sensorValue);
digitalWrite(10, LOW);
delay(sensorValue);
digitalWrite(11, LOW);
delay(sensorValue);
digitalWrite(12, LOW);
delay(sensorValue);
digitalWrite(13, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(sensorValue);
}
心得 :
今天才知道原來之前所學得的東西都在為未來鋪路,先學會怎麼會看程式碼,又用到大二學的接電線,果然是多學一點未雨綢繆,完成霹靂燈覺得成就感滿滿,哈哈,期末加油 :)
2012年11月20日 星期二
Week11, HW09,
1. 有了processing + Arduino可做出什麼?
我覺得原本只能在電腦上玩的按鍵遊戲都可以透過 Arduino 來實踐在實體物體上。
讓遊戲玩起來更加生動。 可以將音樂遊戲裝到Arduino 上可以變成跳舞機。
2. Arduino 應用的影片
我覺得原本只能在電腦上玩的按鍵遊戲都可以透過 Arduino 來實踐在實體物體上。
讓遊戲玩起來更加生動。 可以將音樂遊戲裝到Arduino 上可以變成跳舞機。
2. Arduino 應用的影片
2012年11月12日 星期一
Midtern
完整程式碼:
//*****變數宣告*****
PImage s2,cat1,s1,s3,catshack; //圖片空間
float y = 450; //跳繩y變數
int now=1; //改變場景要用到的變數
int jumpH=0; //喵跳的高度
int mx=400,my=400; //喵的位子
boolean stop = false; //遊戲暫停會用到
int score =0; //計算得分會弄到
float count=1.5; //讓跳繩變快
float count2=0; //算跳了幾次
//*****設定*****
import ddf.minim.*; //音樂
Minim minim; //音樂
AudioPlayer player; //音樂
void setup() {
size(900, 600); //視窗大小
s1=loadImage("bk2.png"); //場景1
s2=loadImage("bk.jpg"); //場景2
s3=loadImage("s3.jpg"); //場景3
cat1=loadImage("cat.png"); //跳跳貓
catshack=loadImage("catshack.png");
//****音樂*****
minim = new Minim(this);
player = minim.loadFile("888.mp3");
player.play();
}
//*****開始畫****
void draw() {
image(s2,0,0);
if (stop == false) {
l();
jump();
judge();
}
//*****按Enter鍵休息****
if (keyPressed) {
stop = true;
fill(0);
textSize(150);
text("STOP", 250, 300);
}
else stop = false;
if(mouseX>622 && mouseX<895 && mouseY>96 && mouseY<130 && mousePressed){
now=3;
}
}
//*****跳跳繩的繩******
void l(){
fill(255,0,128);
y= y + count;
if (y > 600) y = 350;
strokeWeight(10);
fill(255,0,128);
line(0,y,width,y);
}
//*****跳和場景變換*****
void jump(){
if(now==1){
show1();
if(mouseX>593 && mouseX<836 && mouseY>188 && mouseY<273 && mousePressed){
now=2;
}
}
if(now==2){
show2();
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<400){
my+=5;
}
image(cat1,mouseX,my,200,200); //讓跳跳人跟著滑鼠X移動
}
if(now==3){
show3();
}
}
void show1(){
image(s1,0,0);
}
void show2(){
//有手指指標
if (mousePressed == true) {
noCursor();
} else {
cursor(HAND);
}
fill(0);
textSize(50); //右上角分數大小
text(score+"score", 640,60); //右上角分數
}
void show3(){
image(s3,0,0);
fill(0);
textSize(50);
text("cheer up !", 250, 200);
textSize(150);
text(score, 360, 350);
minim = new Minim(this); //音樂
player = minim.loadFile("888.mp3"); //匯入音樂檔
player.play(); //音樂
}
//*****當按下滑鼠左鍵******
void mouseClicked()
{
jumpH=100 - (200-my);
score+=10; //分數跳一次加10分
count2+=1;
minim = new Minim(this); //音樂
player = minim.loadFile("jump.mp3"); //匯入音樂檔
player.play(); //音樂
}
//*****當按下滑鼠左鍵******
void judge(){
if(mouseY>300 && mouseY<540 && mousePressed) now=4;
if(now==4){
image(catshack,mouseX,my,138,200);
fill(0);
textSize(100);
text("Game over *_*' ",80,240);
text("Click Enter key !",65,350);
if(keyPressed)now=3;
}
if(now==3)show3();
if(count2==35)count+=0.5;
}
執行結果:
//*****變數宣告*****
PImage s2,cat1,s1,s3,catshack; //圖片空間
float y = 450; //跳繩y變數
int now=1; //改變場景要用到的變數
int jumpH=0; //喵跳的高度
int mx=400,my=400; //喵的位子
boolean stop = false; //遊戲暫停會用到
int score =0; //計算得分會弄到
float count=1.5; //讓跳繩變快
float count2=0; //算跳了幾次
//*****設定*****
import ddf.minim.*; //音樂
Minim minim; //音樂
AudioPlayer player; //音樂
void setup() {
size(900, 600); //視窗大小
s1=loadImage("bk2.png"); //場景1
s2=loadImage("bk.jpg"); //場景2
s3=loadImage("s3.jpg"); //場景3
cat1=loadImage("cat.png"); //跳跳貓
catshack=loadImage("catshack.png");
//****音樂*****
minim = new Minim(this);
player = minim.loadFile("888.mp3");
player.play();
}
//*****開始畫****
void draw() {
image(s2,0,0);
if (stop == false) {
l();
jump();
judge();
}
//*****按Enter鍵休息****
if (keyPressed) {
stop = true;
fill(0);
textSize(150);
text("STOP", 250, 300);
}
else stop = false;
if(mouseX>622 && mouseX<895 && mouseY>96 && mouseY<130 && mousePressed){
now=3;
}
}
//*****跳跳繩的繩******
void l(){
fill(255,0,128);
y= y + count;
if (y > 600) y = 350;
strokeWeight(10);
fill(255,0,128);
line(0,y,width,y);
}
//*****跳和場景變換*****
void jump(){
if(now==1){
show1();
if(mouseX>593 && mouseX<836 && mouseY>188 && mouseY<273 && mousePressed){
now=2;
}
}
if(now==2){
show2();
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<400){
my+=5;
}
image(cat1,mouseX,my,200,200); //讓跳跳人跟著滑鼠X移動
}
if(now==3){
show3();
}
}
void show1(){
image(s1,0,0);
}
void show2(){
//有手指指標
if (mousePressed == true) {
noCursor();
} else {
cursor(HAND);
}
fill(0);
textSize(50); //右上角分數大小
text(score+"score", 640,60); //右上角分數
}
void show3(){
image(s3,0,0);
fill(0);
textSize(50);
text("cheer up !", 250, 200);
textSize(150);
text(score, 360, 350);
minim = new Minim(this); //音樂
player = minim.loadFile("888.mp3"); //匯入音樂檔
player.play(); //音樂
}
//*****當按下滑鼠左鍵******
void mouseClicked()
{
jumpH=100 - (200-my);
score+=10; //分數跳一次加10分
count2+=1;
minim = new Minim(this); //音樂
player = minim.loadFile("jump.mp3"); //匯入音樂檔
player.play(); //音樂
}
//*****當按下滑鼠左鍵******
void judge(){
if(mouseY>300 && mouseY<540 && mousePressed) now=4;
if(now==4){
image(catshack,mouseX,my,138,200);
fill(0);
textSize(100);
text("Game over *_*' ",80,240);
text("Click Enter key !",65,350);
if(keyPressed)now=3;
}
if(now==3)show3();
if(count2==35)count+=0.5;
}
執行結果:
場景 1
場景 2
結束的狀況
場景 3
圖片素材 :

連結網址:
心得:
終於都做到一個段落了,雖然跟預期的有些不一樣,不過從無到有的結果實在令人十分感動,希望期末可以修正錯誤,再多加延伸,完成一個完整的遊戲。
在遊戲過程中按下play鍵,開始遊戲用滑鼠來控制貓咪左右移動,按下左鍵可讓貓咪跳起來。按下空白鍵可以暫停遊戲,螢幕畫面的右上角有分數統計。
在寫程式的過程中,我們一度卡在偵測繩子與貓咪相互碰撞跌倒的地方,一直不知道該怎麼做,之後我們用偵測畫面的位置,來判斷貓咪是否被繩子辦到。但還是沒有完整的做好偵測繩子,還需要再做更改。
2012年10月30日 星期二
Week08, HW08,
1. 請寫下以下資料:
1.1. 你之前完成了什麼?
素材 :
覺得之前的背景圖貼來貼去很不好看,所以換了一張背景圖,我們遊戲名稱也出來了
a. 第一個場景圖
c.主角貓
1.2. 你今天計畫要做什麼?
看下play鍵可以跳到另一個遊戲畫面
做出繩子,偵測是否有碰到繩子
1.3. 可能會遇到的問題... (及可能的解決方法)
2. 請把你目前期中作品的進度貼出來
PImage bk,cat,cat1;
int now=1,x=0,y=0;
int jumpH=0; //跳的高度
int mx=500,my=500;
int now=1,x=0,y=0;
int jumpH=0; //跳的高度
int mx=500,my=500;
void setup(){
size(1200,800); //視窗大小
bk=loadImage("bk.jpg"); //背景圖
cat=loadImage("bk2.png"); //背景2
cat1=loadImage("cat.png"); //跳跳人
fill(237,28,36); //紅
rect(0,0,328,123);
}
void show1(){
image(cat,0,0);
}
void show2(){
image(bk,0,0);
}
void draw(){
if(now==1){
show1();
if(mouseX>780 && mouseX<1115 && mouseY>250 && mouseY<379 && mousePressed){
now=2;
}
}
if(now==2){
show2();
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<500){
my+=5;
}
image(cat1,mouseX,my,138,235); //讓跳跳人跟著滑鼠X移動
}
size(1200,800); //視窗大小
bk=loadImage("bk.jpg"); //背景圖
cat=loadImage("bk2.png"); //背景2
cat1=loadImage("cat.png"); //跳跳人
fill(237,28,36); //紅
rect(0,0,328,123);
}
void show1(){
image(cat,0,0);
}
void show2(){
image(bk,0,0);
}
void draw(){
if(now==1){
show1();
if(mouseX>780 && mouseX<1115 && mouseY>250 && mouseY<379 && mousePressed){
now=2;
}
}
if(now==2){
show2();
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<500){
my+=5;
}
image(cat1,mouseX,my,138,235); //讓跳跳人跟著滑鼠X移動
}
}
void mouseClicked() //按下滑鼠左鍵
{
jumpH=200 - (500-my); //就跳起
}
{
jumpH=200 - (500-my); //就跳起
}
week8 hw8
未完成 : 計分、背景音樂、跳繩加快、有其他貓會加入玩、選擇角色
有想過要不要把"有其他貓會加入玩" 改成 吃"天空掉下來的魚會加分吃到垃圾會扣分沒吃到魚也會扣分"
//*****變數宣告*****
PImage s2,cat1,s1,s3;//圖片空間
float y = 450;//跳繩y變數
int now=1;//改變場景要用到的變數
int jumpH=0; //喵跳的高度
int mx=400,my=400;//喵的位子
boolean stop = false; //遊戲暫停會用到
int score =0; //計算得分會弄到
//*****設定*****
void setup() {
size(900, 600);//視窗大小
s2=loadImage("bk.jpg");//場景2
s1=loadImage("bk2.png"); //場景1
s3=loadImage("s3.jpg"); //場景3
cat1=loadImage("cat.png"); //跳跳人
float yrope = 100;
fill(237,28,36); //紅
rect(0,0,328,123);
}
//*****開始畫****
void draw() {
image(s2,0,0);
if (stop == false) {
l();
jump();
}
//按Enter鍵休息
if (keyPressed) {
stop = true;
fill(0);
textSize(150);
text("STOP", 250, 300);
}else stop = false;
if(mouseX>622 && mouseX<895 && mouseY>96 && mouseY<130 && mousePressed){
now=3;
}
}
//*****跳跳繩的繩******
void l(){
fill(255,0,128);
y= y + 1.5; //若想讓跳繩越跳越快,可以從這裡改,把1.5改成變數
if (y > 600) y = 350;
strokeWeight(10);
fill(255,0,128);
line(0,y,width,y);
}
//*****跳和場景變換*****
void jump(){
if(now==1){
show1();
if(mouseX>593 && mouseX<836 && mouseY>188 && mouseY<273 && mousePressed){
now=2;
}
}
if(now==2){
show2();
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<400){
my+=5;
}
image(cat1,mouseX,my,138,235); //讓跳跳人跟著滑鼠X移動
}
if(now==3){
show3();
}
}
void show1(){
image(s1,0,0);
}
void show2(){
//有手指指標
if (mousePressed == true) {
noCursor();
} else {
cursor(HAND);
}
}
void show3(){
image(s3,0,0);
fill(0);
textSize(50);
text("cheer up !", 300, 200);
textSize(150);
text(score, 360, 350);
}
//*****當按下滑鼠左鍵******
void mouseClicked()
{
jumpH=100 - (200-my); //就跳起
}
場景1
場景2
場景3
角色1
角色2
2012年10月29日 星期一
week7 視訊
//小葉老師最短的視訊
import processing.video.*;
Capture video;
void setup(){
size(640,480,P2D);
video = new Capture(this, width, height);
video.start();
loadPixels();
}
void draw(){
if(video.available()){
video.read();
video.loadPixels();
for(int i=0;i<640*480;i++){
pixels[i]=video.pixels[i];
}
updatePixels();
}
import processing.video.*;
Capture video;
void setup(){
size(640,480,P2D);
video = new Capture(this, width, height);
video.start();
loadPixels();
}
void draw(){
if(video.available()){
video.read();
video.loadPixels();
for(int i=0;i<640*480;i++){
pixels[i]=video.pixels[i];
}
updatePixels();
}
我們可愛的組員及頭上長花反串同學 XD
臉臭臭的組員在認真上課中
2012年10月23日 星期二
WEEK07, HW07,
專題進度
我們更新的素材
1.素材
2.程式碼
int mx=500,my=500; //預設的預備起跳位子
void setup(){
size(1200,800); //視窗大小
aaa=loadImage("back1.jpg"); //背景圖
ddd=loadImage("ddd.jpg"); //跳跳人
}
void draw(){
image(aaa,0,0);
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<500){
my+=5;
}
image(ddd,mouseX,my,138,235); //讓跳跳人跟著滑鼠X移動
}
jumpH=200 - (500-my); //就跳起
}
我們更新的素材
1.素材
2.程式碼

PImage aaa,ddd; //匯入圖片
int jumpH=0; //跳的高度int mx=500,my=500; //預設的預備起跳位子
size(1200,800); //視窗大小
aaa=loadImage("back1.jpg"); //背景圖
ddd=loadImage("ddd.jpg"); //跳跳人
}
image(aaa,0,0);
if(jumpH>0){
jumpH=jumpH-10;
my-=10;
}
if(my<500){
my+=5;
}
image(ddd,mouseX,my,138,235); //讓跳跳人跟著滑鼠X移動
}
void mouseClicked() //按下滑鼠左鍵
{jumpH=200 - (500-my); //就跳起
}
3. 討論出最後的遊戲
有分難易度
1.普通 速度慢慢地加快
2. 困難 除了速度會慢慢地加快,還會有人垃圾有閃躲
2012年10月16日 星期二
Week06,HW06
1.作品建議
紀詠心和陳孟琳的章魚燒遊戲感覺不錯~~
2.期中作品
A.素材
B.流程
C.code
PImage girl1;
void setup(){
size(500,500);
girl1=loadImage("girl1.jpg");
}
void draw(){
background(223,236,244);
image(girl1,mouseX,mouseY,238,121);
}
紀詠心和陳孟琳的章魚燒遊戲感覺不錯~~
2.期中作品
A.素材
B.流程
C.code
PImage girl1;
void setup(){
size(500,500);
girl1=loadImage("girl1.jpg");
}
void draw(){
background(223,236,244);
image(girl1,mouseX,mouseY,238,121);
}
2012年10月9日 星期二
Week05 ,HW05,
1.
void setup(){
size(600,600);
}
float rrr=0.01;
void draw(){
background(34,177,76);
fill(0,128,64); //綠色
ellipse(300,400,20,300); //樹枝
//rotate(12);
fill(0,0,0);
ellipse(305,539,200,50); //葉子
pushMatrix();
translate(300,300);
fill(233,180,2);
for(int i=0;i<16;i++){
rotate(rrr);rrr+=0.01;
rotate(PI/8);
ellipse(10,10,300,30);
}
fill(18,12,0);
for(int i=0;i<16;i++){
rotate(PI/8);
ellipse(10,10,200,30);
}
fill(223,49,62);
for(int i=0;i<4;i++){
rotate(PI/2);
ellipse(50,50,30,50); //果實
}
popMatrix();
}
size(600,600);
}
float rrr=0.01;
void draw(){
background(34,177,76);
fill(0,128,64); //綠色
ellipse(300,400,20,300); //樹枝
//rotate(12);
fill(0,0,0);
ellipse(305,539,200,50); //葉子
pushMatrix();
translate(300,300);
fill(233,180,2);
for(int i=0;i<16;i++){
rotate(rrr);rrr+=0.01;
rotate(PI/8);
ellipse(10,10,300,30);
}
fill(18,12,0);
for(int i=0;i<16;i++){
rotate(PI/8);
ellipse(10,10,200,30);
}
fill(223,49,62);
for(int i=0;i<4;i++){
rotate(PI/2);
ellipse(50,50,30,50); //果實
}
popMatrix();
}
2012年10月2日 星期二
Week04,HW04
void setup(){
size(600,400);
background(255,255,255);
fill(237,28,36); //紅
rect(0,0,50,50);
fill(255,127,39); //澄
rect(0,50,50,50);
fill(255,242,0); //黃
rect(0,100,50,50);
fill(34,177,76); //綠
rect(0,150,50,50);
fill(0,162,232); //藍
rect(0,200,50,50);
fill(63,72,204); //靛
rect(0,250,50,50);
fill(0,0,0); //紫
rect(0,300,50,50);
fill(255,255,255); //存檔
rect(0,350,50,50);
fill(5,255,255); //讀檔
rect(550,350,50,50);
fill(255,255,255); // 放大
rect(550,0,50,50);
fill(0,0,0);
ellipse(575, 25, 30, 30);
fill(255,255,255); //縮小
rect(550,50,50,50);
fill(0,0,0);
ellipse(575, 75, 10, 10);
}
int www=5;
void draw(){ //控制滑鼠
if(mouseX<50 && mouseY<50) stroke(255,0,0);
else if(mousePressed && mouseX<50 && mouseY<100) stroke(255,127,39);
else if(mousePressed && mouseX<50 && mouseY<150) stroke(255,242,0);
else if(mousePressed && mouseX<50 && mouseY<200) stroke(34,177,76);
else if(mousePressed && mouseX<50 && mouseY<250) stroke(0,162,232);
else if(mousePressed && mouseX<50 && mouseY<300) stroke(63,72,204);
else if(mousePressed && mouseX<50 && mouseY<350) stroke(0,0,0);
else if(mousePressed && mouseX<50 && mouseY<400) save("234.JPEG");
else if(mousePressed && mouseX>550 && mouseY>350){
PImage file = loadImage("234.JPEG"); //讀取圖檔
image(file,0,0,600,400);
}
else if(mousePressed && mouseX>550 && mouseY<50){
strokeWeight(++www);
}
else if(mousePressed && mouseX>550 && mouseY<100){
strokeWeight(--www);
if(www<2)www=2;
}
if(mousePressed) line(mouseX,mouseY,pmouseX,pmouseY);
2012年9月25日 星期二
Week03,HW03
3-1
void setup(){
size(600,600);
background(45,130,223); //背景色
}
void draw(){
fill(100,100,100);
rect(100,100,100,100);
fill(255,255,0);
ellipse(mouseX,mouseY,100,100); //跟著滑鼠動
}
//for(int i=0;i<10;i++){
//}
3-2
void setup(){
size(600,600);
//frameRate(1);
}
float x=100,y=100;
void draw(){
background(100,100,200); //背景色 (在此處是刷新的意思)
//fill(255,150,0);
//ellipse(mouseX,mouseY,70,70); //跟著滑鼠動
fill(226,48,20); //填上框框顏色(紅色)
arc(mouseX,mouseY, 50, 50, PI, 180);
fill(246,248,235); //填上框框顏色(白色)
arc(mouseX,mouseY, 50, 50, 0, PI);
fill(3,3,3); //填上框框顏色(黑色)
ellipse(mouseX,mouseY, 25, 25);
fill(246,248,235); //填上框框顏色(白色)
ellipse(mouseX,mouseY, 10, 10);
//fill(0,255,255);
//rect(y, 20, x, y);
x=x*0.9+mouseX*0.1; //x=(x+mouseX)/2;
y=y*0.9+mouseY*0.1; //y=(y+mouseY)/2;
translate(x,y);
myChu();
}
void myChu(){
scale(0.5,0.5);
//translate(-150,-150);
fill(239,231,0); //填上框框顏色(黃色)
ellipse(300, 180 ,310, 310);//橢圓(臉)
fill(224,83,53); //填上框框顏色(紅)
ellipse(200, 271, 70, 70);//橢圓(左)
ellipse(430, 197, 70, 70);//橢圓(右)
fill(1,1,1); //填上框框顏色(黑)
ellipse(223, 187, 60, 60);//橢圓(左眼)
ellipse(365, 150, 60, 60);//橢圓(右眼)
ellipse(300, 197, 15, 10);//橢圓(鼻子)
fill(254,254,254); //填上框框顏色(白)
ellipse(228, 180, 27, 27);//橢圓(左眼)
ellipse(358, 145, 27, 27);//橢圓(右眼)
noFill();
arc(310, 240, 110, 110, HALF_PI, PI);
fill(20,178,21); //填上框框顏色(紅)
triangle(145, 160, 30, 41, 185, 70);
fill(0,64,128); //填上框框顏色(紅)
ellipse(25, 45, 27, 27);//橢圓(右眼)
}
void setup(){
size(600,600);
background(45,130,223); //背景色
}
void draw(){
fill(100,100,100);
rect(100,100,100,100);
fill(255,255,0);
ellipse(mouseX,mouseY,100,100); //跟著滑鼠動
}
//for(int i=0;i<10;i++){
//}
3-2
void setup(){
size(600,600);
//frameRate(1);
}
float x=100,y=100;
void draw(){
background(100,100,200); //背景色 (在此處是刷新的意思)
//fill(255,150,0);
//ellipse(mouseX,mouseY,70,70); //跟著滑鼠動
fill(226,48,20); //填上框框顏色(紅色)
arc(mouseX,mouseY, 50, 50, PI, 180);
fill(246,248,235); //填上框框顏色(白色)
arc(mouseX,mouseY, 50, 50, 0, PI);
fill(3,3,3); //填上框框顏色(黑色)
ellipse(mouseX,mouseY, 25, 25);
fill(246,248,235); //填上框框顏色(白色)
ellipse(mouseX,mouseY, 10, 10);
//fill(0,255,255);
//rect(y, 20, x, y);
x=x*0.9+mouseX*0.1; //x=(x+mouseX)/2;
y=y*0.9+mouseY*0.1; //y=(y+mouseY)/2;
translate(x,y);
myChu();
}
void myChu(){
scale(0.5,0.5);
//translate(-150,-150);
fill(239,231,0); //填上框框顏色(黃色)
ellipse(300, 180 ,310, 310);//橢圓(臉)
fill(224,83,53); //填上框框顏色(紅)
ellipse(200, 271, 70, 70);//橢圓(左)
ellipse(430, 197, 70, 70);//橢圓(右)
fill(1,1,1); //填上框框顏色(黑)
ellipse(223, 187, 60, 60);//橢圓(左眼)
ellipse(365, 150, 60, 60);//橢圓(右眼)
ellipse(300, 197, 15, 10);//橢圓(鼻子)
fill(254,254,254); //填上框框顏色(白)
ellipse(228, 180, 27, 27);//橢圓(左眼)
ellipse(358, 145, 27, 27);//橢圓(右眼)
noFill();
arc(310, 240, 110, 110, HALF_PI, PI);
fill(20,178,21); //填上框框顏色(紅)
triangle(145, 160, 30, 41, 185, 70);
fill(0,64,128); //填上框框顏色(紅)
ellipse(25, 45, 27, 27);//橢圓(右眼)
}
2012年9月17日 星期一
week01,HW01
2-1
size(600,600);
for(int i=0; i<50; i++){
fill(random(255),random(255),random(255));
rect(random(400),random(400),random(500),random(500));//random是亂數,rect是四邊形
}
2-2
2-3
2-2
size(400,300);
for(int i=0; i<80; i++){//i
for(int k=0;k<60;k++){
fill(k*255/10,k*255/60,i*255/50);
//fill(random(255),random(255),random(255));
rect(i*5,k*5,10,10);
}}
2-3
size(800,600);
background(50);
noStroke();
for(int i=0;i<4;i++){
for(int j=0;j<3;j++){
fill(i*255/5,j*255/4,10);
ellipse(i*200+50, j*200+125, 200, 200);
fill(i*255/4,j*255/3,10);
ellipse(i*200+50, j*200+100, 150, 100);
fill(i*255/3,j*255/2,10);
ellipse(i*200+50, j*200+100,100,50);
}
}
2012年9月11日 星期二
week01,HW01
1-1
1-2
size(500,500); //大小
background(45,130,223); //背景色
fill(224,83,53); //填上框框顏色
PImage pikachu;
pikachu = loadImage("http://farm3.static.flickr.com/2198/3531070118_354caf8ac1_o.jpg");
image(pikachu, 20,20);
1-3
size(500,500); //大小
background(45,130,223); //背景色
/*
PImage pikachu;
pikachu = loadImage("http://farm3.static.flickr.com/2198/3531070118_354caf8ac1_o.jpg");
image(pikachu, 20,20);
//rect(30,20,55,55); //方形
*/
fill(239,231,0); //填上框框顏色(黃色)
ellipse(300, 180 ,310, 310);//橢圓(臉)
fill(224,83,53); //填上框框顏色(紅)
ellipse(200, 271, 70, 70);//橢圓(左)
ellipse(430, 197, 70, 70);//橢圓(右)
fill(1,1,1); //填上框框顏色(黑)
ellipse(223, 187, 60, 60);//橢圓(左眼)
ellipse(365, 150, 60, 60);//橢圓(右眼)
ellipse(300, 197, 15, 10);//橢圓(鼻子)
fill(254,254,254); //填上框框顏色(白)
ellipse(228, 180, 27, 27);//橢圓(左眼)
ellipse(358, 145, 27, 27);//橢圓(右眼)
noFill();
arc(310, 240, 110, 110, HALF_PI, PI);
fill(20,178,21); //填上框框顏色(紅)
triangle(145, 160, 30, 41, 185, 70);
fill(0,64,128); //填上框框顏色(紅)
ellipse(25, 45, 27, 27);//橢圓(右眼)
心得:
從網路搜尋到關於processing相關的作品和其互動應用,剛開始接觸到這個感覺不是很了解,進processing裡的reference了解到許多的用法~ 感覺很好玩。
1-2
size(500,500); //大小
background(45,130,223); //背景色
fill(224,83,53); //填上框框顏色
PImage pikachu;
pikachu = loadImage("http://farm3.static.flickr.com/2198/3531070118_354caf8ac1_o.jpg");
image(pikachu, 20,20);
1-3
size(500,500); //大小
background(45,130,223); //背景色
/*
PImage pikachu;
pikachu = loadImage("http://farm3.static.flickr.com/2198/3531070118_354caf8ac1_o.jpg");
image(pikachu, 20,20);
//rect(30,20,55,55); //方形
*/
fill(239,231,0); //填上框框顏色(黃色)
ellipse(300, 180 ,310, 310);//橢圓(臉)
fill(224,83,53); //填上框框顏色(紅)
ellipse(200, 271, 70, 70);//橢圓(左)
ellipse(430, 197, 70, 70);//橢圓(右)
fill(1,1,1); //填上框框顏色(黑)
ellipse(223, 187, 60, 60);//橢圓(左眼)
ellipse(365, 150, 60, 60);//橢圓(右眼)
ellipse(300, 197, 15, 10);//橢圓(鼻子)
fill(254,254,254); //填上框框顏色(白)
ellipse(228, 180, 27, 27);//橢圓(左眼)
ellipse(358, 145, 27, 27);//橢圓(右眼)
noFill();
arc(310, 240, 110, 110, HALF_PI, PI);
fill(20,178,21); //填上框框顏色(紅)
triangle(145, 160, 30, 41, 185, 70);
fill(0,64,128); //填上框框顏色(紅)
ellipse(25, 45, 27, 27);//橢圓(右眼)
心得:
從網路搜尋到關於processing相關的作品和其互動應用,剛開始接觸到這個感覺不是很了解,進processing裡的reference了解到許多的用法~ 感覺很好玩。
訂閱:
文章 (Atom)