簡體   English   中英

如何改進我的Processing節奏游戲的原型?

[英]How can I improve my prototype of my Processing rhythm game?

我正在嘗試在處理中創建類似於Osu的節奏游戲。 該游戲應該根據正在播放的音樂創建一個塊。 在我所處的階段,只要有音樂播放,游戲就會掛起。 音樂也會失真。 請幫忙!

int start;
float xpos;
float ypos;

int counter = 0;

Boolean menu = true;
Boolean game = false;

import ddf.minim.*;

click Clicker;

Minim minim;
AudioPlayer song;

void setup() {
  size (800,800);
  Clicker = new click();
  start = millis();

}

void draw() {
  if (menu) {
    text("Welcome to My Game!", 300, 350);
    text("Get ready to play", 400, 375);
    text("Click on the screen to start", 275, 400);
    textSize(35);


  }

  if(game) {
    Clicker.display();
    Clicker.click();
    Clicker.gui();

    int timer = millis()/1000;
    text("Time: "+ timer, 10, 760);

    minim = new Minim(this);
    song = minim.loadFile("Bohemian Rhapsody.mp3");
    song.play();

  }
}

class click {
  float xpos;
  float ypos = 50;
  float wide;
  float high;
  float colour;

  click() {
    wide = 30;
    high = 30;
   colour = 45;
  }

  void display() {
    background (255);
    fill(colour);
    rect(xpos, ypos, wide, high);
  }

  void click() {
    if (mousePressed) {
      if (mouseX >= xpos && mouseX <= xpos + 30) {
        if (mouseY >= ypos && mouseY <= ypos + 30) {
          counter = counter + 1;
          xpos = random(0, 750);
          ypos = random(50, 650);
        }
      }
    }
  }

  void gui() {
    text("Score: " + counter, 10, 790);
    textSize(35);
    line(0, 700, 800, 700);
  }
}

void mousePressed() {
  if (menu) {
    menu = false;
    game = true;
  }
}

有一些要修復和改進的地方:

  1. 語法/流程
  2. 游戲設計
  3. 節奏游戲

1.語法/流程

音樂可能會失真的原因是,您在draw()函數中多次初始化了minim庫。 同樣,您應該為歌曲調用一次play()。 這是您的代碼版本,其中移動了幾行:

import ddf.minim.*;

float xpos;
float ypos;

int counter = 0;

Boolean menu = true;
Boolean game = false;

click Clicker;

Minim minim;
AudioPlayer song;

void setup() {
  size (800,800);
  Clicker = new click();
  //initialize the library once, when you setup
  minim = new Minim(this);
  song = minim.loadFile("Bohemian Rhapsody.mp3");
}

void draw() {
  if (menu) {
    text("Welcome to My Game!", 300, 350);
    text("Get ready to play", 400, 375);
    text("Click on the screen to start", 275, 400);
    textSize(35);


  }

  if(game) {
    Clicker.display();
    Clicker.click();
    Clicker.gui();

    int timer = millis()/1000;
    text("Time: "+ timer, 10, 760);

  }
}

class click {
  float xpos;
  float ypos = 50;
  float wide;
  float high;
  float colour;

  click() {
    wide = 30;
    high = 30;
   colour = 45;
  }

  void display() {
    background (255);
    fill(colour);
    rect(xpos, ypos, wide, high);
  }

  void click() {
    if (mousePressed) {
      if (mouseX >= xpos && mouseX <= xpos + 30) {
        if (mouseY >= ypos && mouseY <= ypos + 30) {
          counter = counter + 1;
          xpos = random(0, 750);
          ypos = random(50, 650);
        }
      }
    }
  }

  void gui() {
    text("Score: " + counter, 10, 790);
    textSize(35);
    line(0, 700, 800, 700);
  }
}

void mousePressed() {
  if (menu) {
    menu = false;
    game = true;
    song.play();//play the song once, when entering game mode
  }
}

2.游戲設計

在線上有大量有關該主題的資源,僅玩游戲應該有助於指出幾個基本問​​題:

  • 游戲的目標/獎勵是什么(水管工可以救王子嗎,難題是否解決了)?
  • 游戲的運作方式(規則/機制/關卡何時開始/結束/您贏/輸/如何?)

您當前的版本會顯示一個永無止境的級別,只要玩家選擇單擊一個框,時間就會增加,分數也會增加。 嘗試為每個級別設置時間限制。 您總是可以引入復雜性來進行升級(以首選的點擊順序同時引入兩個框,等等)。 您已經提到了Osu節奏游戲,但您應該真正玩它,並嘗試將其規則/算法分解為若干步驟。

3.節奏游戲

節奏最有趣的部分是您所看到的,所聽到的聲音之間的緊密聯系(這是一個很不錯的目標,它本身就是正確的),而且還包括您如何/何時互動。

目前,如果您對音樂進行評論,這對游戲完全沒有影響。 與音樂沒有任何關系。 您應該嘗試根據音樂中的關鍵時刻添加用戶互動。 Minim已經提供了一些起跳和節拍檢測功能 你應該玩這個。 (或者,您可以嘗試使用諸如Echonest之類的軟件或服務來進行音樂分析並提取關鍵時刻,或者直接在軟件中手動添加標記並在允許的情況下導出csv文件)

玩得開心!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM