size(500,500);
background(0);
textSize(50);
text("Hello",50,50);
PFont font = createFont("elffont-rock.otf",50);
textFont(font);
textFont(font2);//記得先把安裝字形,才能順利createFont()
text("ㄇㄉㄈㄎ",50,250);
PFont font0, font, font2;//3種字形:中文,英文,注音文
void setup() {
size(500, 500);
font0=createFont("qqq", 50);//
font = createFont("標楷體", 50);
PFont font2 = createFont("elffont-rock.otf", 50);
}
void draw() {
background(0);
textSize(50);
textFont(font0);
text("Hello", 50, 50);
//PFont font = createFont("elffont-rock.otf", 50);不能寫在裡面
textFont(font);
text("中文看到", 50, 100);
textFont(font2);//記得先把安裝字形,才能順利createFont()
text("ㄇㄉㄈㄎ", 50, 250);
}
import processing.sound.*;
SoundFile sound;
void setup(){
size(500,500);
sound = new SoundFile(this,"In Game Music.mp3");
//sound.play();//播放一次
sound.loop();//一直迴圈撥放
}
void draw(){
}
import processing.sound.*;
SoundFile sound1,sound2,hit;
void setup(){
size(500,500);
sound1 = new SoundFile(this,"In Game Music.mp3");
sound2 = new SoundFile(this,"Intro Song Final.mp3");
hit = new SoundFile(this, "sword slash.mp3");
//sound.play();//播放一次
sound2.play();//開場時先播放開場音樂
}
void draw(){
background(255);
}
void mousePressed(){
hit.play();//mouse按下時,揮劍的聲音
}
void keyPressed(){
if(key=='1'){
sound2.stop();
sound1.play();
}else{
sound1.stop();
sound2.play();
}
PImage board;//外面宣告變數
void setup(){
size(600,400);
board = loadImage("board.png");//裡面修改變數
}
float appleX=100,appleY=500,appleVX=3,appleVY=-30;
void draw(){
background(board);//裡面的變數
fill(255,0,0);
ellipse(appleX,appleY,80,80);//紅色的蘋果
appleX+=appleVX;
appleY+=appleVY;
appleVY+=0.98;//重力加速度
if(appleX>600){
appleX=100;appleY=500;appleVX=5;appleVY=-30;
}
}
PImage board;//外面宣告變數
void setup(){
size(600,400);
board = loadImage("board.png");//裡面修改變數
}
float appleX=100,appleY=500,appleVX=3,appleVY=-30;
void randomApple(){
appleX=random(100,500);
appleY=500;
appleVX=random(-8,-8);
appleVY=random(-30,-20);
}
void draw(){
background(board);//裡面的變數
fill(255,0,0);
ellipse(appleX,appleY,80,80);//紅色的蘋果
appleX+=appleVX;
appleY+=appleVY;
appleVY+=0.98;//重力加速度
if(appleX>600){
appleX=100;appleY=500;appleVX=5;appleVY=-30;
}
}
PImage board;//外面宣告變數
void setup(){
size(600,400);
board = loadImage("board.png");//裡面修改變數
}
float appleX=100,appleY=500,appleVX=3,appleVY=-30;
char appleKey;
void randomApple(){
appleX=random(100,500);
appleY=500;
if(appleX<300)appleVX=random(0,8);
else appleVX=random(-8,0);
appleVY=random(-30,-20);
appleKey=(char)('a'+int(random(26)));
}
int score=0;
void KeyPressed(){
if(key==appleKey){
score+=100;
}else{
score-=200;
}
void draw(){
background(board);//裡面的變數
text("Score:"+score,400,500);
fill(255,0,0);
ellipse(appleX,appleY,80,80);//紅色的蘋果
appleX+=appleVX;//照著運動速度,x往右移
appleY+=appleVY;照著運動速度,Y也會移動
appleVY+=0.98;//重力加速度
if(appleX>600 || appleX<0 || appleY>550){
appleX=100;appleY=500;appleVX=5;appleVY=-30;
}
}
PImage board;//外面宣告變數
void setup() {
size(600, 400);
board = loadImage("board.png");//裡面修改變數
}
float appleX=100, appleY=500, appleVX=3, appleVY=-30;
char appleKey;
void randomApple() {
appleX=random(100, 500);
appleY=500;
if (appleX<300)appleVX=random(0, 8);
else appleVX=random(-8, 0);
appleVY=random(-30, -25);
appleKey=(char)('a'+int(random(26)));
}
int score=0;
void keyPressed() {
if (state==0)state=1;
if (state==2) {
if (key==appleKey) {
score+=100;
} else {
score-=200;
}
}
}
int state =0;
int countdown=60*4;
void draw() {
background(board);//裡面的變數
textSize(50);
textAlign(CENTER, CENTER);
if (state==0)text("Press Any Key to Start", 300, 200);
else if (state==1) {
textSize(100);
countdown--;//讓這個--數字才會走
if (countdown>60*3) text("3", 300, 200, 200);
else if (countdown>60*2)text("2", 300, 200, 200);
else if (countdown>60*1)text("1", 300, 200, 200);
else if (countdown>0)text("Go", 300, 200, 200);
else state=2;
} else {
text("Score:"+score, 400, 500);
fill(255, 0, 0);
ellipse(appleX, appleY, 80, 80);//紅色的蘋果
fill(255, 255, 0);
textSize(50);
textAlign(CENTER, CENTER);
text(appleKey, appleX, appleY);
//appleX+=appleVX;
appleY+=appleVY;
appleVY+=0.98;//重力加速度
if (appleX>600 || appleX<0 || appleY>550) {
appleX=100;
appleY=500;
appleVX=5;
appleVY=-30;
}
}
}
PImage board;//外面宣告變數
import processing.sound.*;
SoundFile sound1,sound2,sound3;
void setup() {
size(600, 400);
board = loadImage("board.png");//裡面修改變數
randomApple();
sound3 = new SoundFile(this,"In Game Music.mp3");
sound2 = new SoundFile(this,"Gong.mp3");
sound1 = new SoundFile(this,"Intro Song Final.mp3");
sound1.play();
}
float appleX=100, appleY=500, appleVX=3, appleVY=-30;
char appleKey;
void randomApple() {
appleX=random(100, 500);
appleY=500;
if (appleX<300)appleVX=random(0, 8);
else appleVX=random(-8, 0);
appleVY=random(-30, -25);
appleKey=(char)('a'+int(random(26)));
}
int score=0;
void keyPressed() {
if (state==0)state=1;
if (state==2) {
if (key==appleKey) {
score+=100;
} else {
score-=20;
}
}
}
int state =0;
int countdown=60*4;
void draw() {
background(board);//裡面的變數
textSize(50);
textAlign(CENTER, CENTER);
if (state==0)text("Press Any Key to Start", 300, 200);
else if (state==1) {
textSize(100);
countdown--;
if(countdown%60==0){
sound1.stop();
sound1.play();
}
if (countdown>60*3) text("3", 300, 200, 200);
else if (countdown>60*2)text("2", 300, 200, 200);
else if (countdown>60*1)text("1", 300, 200, 200);
else if (countdown>0)text("Go", 300, 200, 200);
else state=2;
} else {
state=2;//時間用完,就跳入新的畫面
sound2.stop();
sound3.loop();
text("Score:"+score, 400, 500);
fill(255, 0, 0);
ellipse(appleX, appleY, 80, 80);//紅色的蘋果
fill(255, 255, 0);
textSize(50);
textAlign(CENTER, CENTER);
text(appleKey, appleX, appleY);
//appleX+=appleVX;
appleY+=appleVY;
appleVY+=0.98;//重力加速度
if (appleX>600 || appleX<0 || appleY>550) {
appleX=100;
appleY=500;
appleVX=5;
appleVY=-30;
}
}
}









沒有留言:
張貼留言