Processingでインベーダーゲームを作っています。
java
1int w = 10; 2int h = 20; 3int x = 270; 4int y = 445; 5int vy = 7; 6int shot = 0; 7int reset = 445; 8void setup() { 9 size(500, 500); 10 background(0); 11} 12void draw() { 13 background(0); 14 PImage houdai = loadImage("houdai.png"); 15 PImage teki = loadImage("teki.png"); 16 image(houdai, 250, 450, 50, 50); 17 image(teki, 250, 50, 50, 50); 18 if (keyPressed) { 19 y = reset; 20 shot = 1; 21 } 22 if (shot!= 0) { 23 y -= vy; 24 rect(x, y, w, h); 25 } 26 if(y < 0){ 27 shot = 0; 28 } 29}
houdaiからrectを発射しています。キーを押したぶん弾を発射したいです。配列は必要でしょうか?ヒントをください。よろしくお願いします。