◇畫線遊戲:
將按鈕圖片放置好、加入音樂、設計好關卡,將佳蓉寫好的程式加入。
(前周主頁面還有"開始遊戲"的按鈕,但切換的時候會造成出錯,最後找不出原因,就決定先拔掉那顆按鈕。)
● 主頁: ● 關卡:
● 計分畫面: ● 選擇關卡頁面:
● 程式碼:
1. 遊戲一些設定:
2. 頁面設置:
◇畫線遊戲:
將按鈕圖片放置好、加入音樂、設計好關卡,將佳蓉寫好的程式加入。
(前周主頁面還有"開始遊戲"的按鈕,但切換的時候會造成出錯,最後找不出原因,就決定先拔掉那顆按鈕。)
● 主頁: ● 關卡:
● 計分畫面: ● 選擇關卡頁面:
● 程式碼:
1. 遊戲一些設定:
2. 頁面設置:
PVector[]coord;
void setup() {![]() |
int N=10;
Domino [] d;
String [] number1={" ","1","2","3","4","5","6"};
String [] number2={" ","1","2","3","4","5","6"};
String [] word={"右鍵可將牌翻轉","a鍵可以讓牌轉90度","s鍵可以將牌重製"};
void setup(){
size(1000,1000);
PFont font = createFont("標楷體", 40);
textFont(font);
d= new Domino[N];
for(int i=0;i<N;i++){
d[i]=new Domino();
}
textSize(30);
textAlign(CENTER,CENTER);
}
void draw(){
background(#FFFFF2);
rect(0,0,210,30);
rect(210,0,260,30);
rect(470,0,260,30);
fill(0);
text(word[0],100,10);
fill(0);
text(word[1],340,10);
fill(0);
text(word[2],600,10);
for(int i=0;i<N;i++){
if(d[i].a==0)d[i].draw();
else d[i].draw2();
}
}
void mousePressed(){
if(mouseButton==RIGHT){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60)
{
int t=d[i].n1;
d[i].n1=d[i].n2;
d[i].n2=t;
}
}
}
}
void keyPressed(){
if(key=='a' || key=='A'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
if(d[i].a==0)d[i].a=1;
else d[i].a=0;
}
}
}
if(key=='s' || key=='S'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].n1=(int)random(7);
d[i].n2=(int)random(7);
}
}
}
if(key=='s' || key=='S'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].n1=(int)random(7);
d[i].n2=(int)random(7);
}
}
}
}
void mouseDragged(){
for(int i=0;i<N;i++)
{
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].x+=(mouseX-pmouseX);
d[i].y+=(mouseY-pmouseY);
}
}
}
class Domino{
int x,y;
int n1,n2;
int a,b;
Domino(){
x=(int)random(100,800);
y=(int)random(100,800);
n1=(int)random(7);
n2=(int)random(7);
a=0;
b=0;
}
void draw(){
fill(50);
rect(x+60,y,60,60);
rect(x,y,60,60);
fill(255);
text(number1[n1],x+30,y+30);
text(number2[n2],x+60+30,y+30);
}
void draw2(){
fill(50);
rect(x,y,60,60);
rect(x,y+60,60,60);
fill(255);
text(number1[n1],x+30,y+30);
text(number2[n2],x+30,y+60+30);
}
}
int N=10;
Domino [] d;
String [] number1={" ","1","2","3","4","5","6"};
String [] number2={" ","1","2","3","4","5","6"};
String [] word={"右鍵可將牌翻轉","a鍵可以讓牌轉90度","s鍵可以將牌重製"};
void setup(){
size(1000,1000);
PFont font = createFont("標楷體", 40);
textFont(font);
d= new Domino[N];
for(int i=0;i<N;i++){
d[i]=new Domino();
}
textSize(30);
textAlign(CENTER,CENTER);
}
void draw(){
background(#FFFFF2);
rect(0,0,210,30);
rect(210,0,260,30);
rect(470,0,260,30);
fill(0);
text(word[0],100,10);
fill(0);
text(word[1],340,10);
fill(0);
text(word[2],600,10);
for(int i=0;i<N;i++){
if(d[i].a==0)d[i].draw();
else d[i].draw2();
}
}
void mousePressed(){
if(mouseButton==RIGHT){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60)
{
int t=d[i].n1;
d[i].n1=d[i].n2;
d[i].n2=t;
}
}
}
}
void keyPressed(){
if(key=='a' || key=='A'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
if(d[i].a==0)d[i].a=1;
else d[i].a=0;
}
}
}
if(key=='s' || key=='S'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].n1=(int)random(7);
d[i].n2=(int)random(7);
}
}
}
if(key=='s' || key=='S'){
for(int i=0;i<N;i++){
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].n1=(int)random(7);
d[i].n2=(int)random(7);
}
}
}
}
void mouseDragged(){
for(int i=0;i<N;i++)
{
if(d[i].x<mouseX && mouseX<d[i].x+120 && d[i].y<mouseY && mouseY<d[i].y+60){
d[i].x+=(mouseX-pmouseX);
d[i].y+=(mouseY-pmouseY);
}
}
}
class Domino{
int x,y;
int n1,n2;
int a,b;
Domino(){
x=(int)random(100,800);
y=(int)random(100,800);
n1=(int)random(7);
n2=(int)random(7);
a=0;
b=0;
}
void draw(){
fill(50);
rect(x+60,y,60,60);
rect(x,y,60,60);
fill(255);
text(number1[n1],x+30,y+30);
text(number2[n2],x+60+30,y+30);
}
void draw2(){
fill(50);
rect(x,y,60,60);
rect(x,y+60,60,60);
fill(255);
text(number1[n1],x+30,y+30);
text(number2[n2],x+30,y+60+30);
}
}
目前的成果展示
1.封面
=>有透過resize的方式讓圖片跟隨頁面變化
2.加入音樂-在按封面頁的start後跳轉進遊戲頁面
3.遊戲方法
-鍵盤的上下左右鍵是操控飛機
-空白鍵射出子彈(紅色)
4.視窗跳轉
-打贏時跳出YOU WIN的字樣
color[] colArray = {
color(227, 41, 54),
color(41, 188, 227),
color(41, 227, 48),
color(250, 239, 13),
};
void setup() {
size(600, 500);
for (int k=0; k<20; k++) hole[0][k]=1;
}
int x=300, y=500;
float angle1=0, angle2=0;
boolean bulletFlying=false;
float bulletX, bulletY;
float bulletVX, bulletVY;
int [][] hole = new int[5][20];
void draw() {
background(#FFFFF2);
fill(0, 0, 0);
ellipse(x, y, 80, 80);
strokeWeight(40);
strokeCap(SQUARE);
line(x, y, x+80*cos(angle1), y+80*sin(angle1));
strokeWeight(1);
for (int i=0; i<5; i++) {
for (int j=0; j<20; j++) {
if (hole[i][j]==0) continue;//noFill();
else fill(255, 255, 0);
ellipse(15+j*30, 15+i*30,30, 30);
}
}
if (bulletFlying) {
bulletX+= bulletVX;
bulletY+= bulletVY;
fill(255, 255, 0);
ellipse(bulletX, bulletY, 30, 30);
if (bulletX > 585) bulletVX=-bulletVX;
if (bulletX < 15) bulletVX=-bulletVX;
if (bulletY < 15 || touch_yellow_ball() ) {
//bulletVY=0;bulletVX=0;
put_ball_in_hole();
bulletFlying=false;
}
}
}
boolean touch_yellow_ball() {
for (int i=0; i<5; i++) {
for (int j=0; j<20; j++) {
if ( hole[i][j]==1 && dist(bulletX, bulletY, 15+j*30, 15+i*30)<23) return true;
}
}
return false;
}
void put_ball_in_hole() {
float nearest = 99999;
int nowI=0, nowJ=0;
for (int i=0; i<5; i++) {
for (int j=0; j<20; j++) {
float now = dist( 15+j*30, 15+i*30, bulletX, bulletY);
if (now<nearest && hole[i][j]==0) {
nearest = now;
nowI=i;
nowJ=j;
}
}
}
hole[nowI][nowJ]=1;
}
void keyPressed() {
if (keyCode==UP) angle1-=0.05;
if (keyCode==DOWN) angle1+=0.05;
if (key==' ') {
bulletFlying=true;
bulletX=x;
bulletY=y;
bulletVX=cos(angle1)*5;
bulletVY=sin(angle1)*5;
}
}
今日進度,完善圖片之間自動黏合及設定好顯示圖片的參數
為了使size更容易設定,更換了1、2兩張圖
# Week13
上課內容:
-填寫Processing使用問卷。
-排版的技巧。
-爆爆王version4:
-上週時鐘問題解決:
1.時間的顯示調整。例:00:00(分:秒)。
倒數計時2:00
int m = (120-(millis()/1000)-(startTime/1000))/60%60;
int s = (120-(millis()/1000)-(startTime/1000))%60;
String mm = nf(m, 2);
String ss = nf(s, 2);
String line1 = "剩下"+":"+mm+":"+ss;
if(millis()-startTime>=120000){
stage=3;
counting();
}else if(millis()-startTime<=120000){
text(line1,210,30);
}
2.時鐘的顯示會被地盤顏色蓋住。
把時鐘text()往void draw()後面擺。
#先寫的先畫!
-另外一個組員計畫:貼圖
發現的問題:
-排版問題
2022/11/28 Week13
# 畫音樂遊戲需要的圖
💚歌曲: 達拉崩八
歌手: cover by ilem
💚歌曲: Beat Eater
歌手: Vivid bad Square
💚歌曲: Party Animal
歌手: Mayday
💚歌曲: Orange Kiss
歌手: Snow Man
💚歌曲: 春を告げる
歌手: yama
💚歌曲: Good Luck
歌手: SixTONES
💚歌曲: Cheap Thrills
歌手: sia
💜歌曲: 達拉崩八
歌長: 3: ...(因為後面戰鬥音樂遊戲需要這首,一定要做)
💜歌曲: Good Luck
歌長: 2:28
💜歌曲: D(evil)
歌手: 春野 feat. yama
歌長: 2:37
💜歌曲: Orange Kiss
歌長: 2:37
💜歌曲: Give It Up?
歌手: 96猫
歌長: 2:37
💜歌曲: Heartbeat (Nightcore ver.)
歌手: Marcus & Martinus
歌長: 2:46
💜歌曲: ブラッディ・グルービー
歌手: ChroNoiR
歌長: 2:30
💜歌曲: 三原色
歌手: YOASOBI
歌長: 2:30
💜歌曲: 99 ILLUSION!
歌手: starlight ninety-nine group
歌長: 1:50
💜歌曲: Fashion
歌手: SixTONES
歌長: 2:14
💜歌曲: Negative Fighter
https://youtu.be/y8RxbC6473k歌手: Hey! Say! JUMP
歌長: 2:17
- 設計不完...最終的歌 (BPM):
💛歌曲: 達拉崩八
BPM: 132
💛歌曲: Fashion
BPM: 120
💛歌曲: Orange Kiss
BPM: 132
💛歌曲: Give It Up?
BPM: 90
💛歌曲: 99 ILLUSION!
BPM: 83