このゲームの始まりに”press button to start”みたいなテキストを入れてゲームの進行をしたいのですが
int title(){ text("Game Title", width * 0.5, height * 0.3); text("Press button to start", width * 0.5, height * 0.7); if(keyPressed)
このような感じのコードを挿入したいです。しかしコードも不十分です。また入れる場所も分かりません。
いれるとしたらほかに必要な要素は何なのでしょうか。
教えてください。
Bullet bullet; private Boss boss = new Boss(75, 35); private ArrayList<Bullet> danmaku = new ArrayList<Bullet>(); float[] z = new float[500]; float[] y = new float[500]; void setup() { size(450, 600); frameRate(40); noCursor(); bullet = new Bullet(width/2, height/2, 10, 0, 0 ); for (int r = 0; r < z.length; r++) { z[r] = random(-1000,300); y[r] = random(height); } } void ship(int x, int y) {こ noStroke(); fill(255, 0, 0); ellipse(mouseX, mouseY, 7.5, 7.5); } class Boss { private int tx, ty; private int dx, dy; private long routine = 0; Boss(int x, int y) { tx = x; ty = y; dx = 1; dy = -5; } void move() { tx += dx; ty += dy; if (tx < 0 || tx > width) { dx*= -1; } if (ty < 0 || ty > height) { dy*= -1; } } void doShinking() { routine++; if (routine % 10 == 0) { move(); } if (routine % 30 == 0) { danmaku.addAll(this.shot()); println("#shot" +routine + ":" + tx + "," + ty); } } ArrayList<Bullet> shot() { ArrayList<Bullet> danmaku = new ArrayList(); for (int i = 0; i < 360; i+= 11.5) { double rad = radians(i); danmaku.add(new Bullet(this.tx, this.ty, 10, Math.cos(rad), Math.sin(rad))); } return danmaku; } } class Bullet { private double tx, ty; private final double tr; private double dx, dy; private boolean is_alive = true; Bullet(double x, double y, double r, double temp_dx, double temp_dy ) { tx = x; ty = y; tr = r; dx = temp_dx; dy = temp_dy; } boolean isAlive() { return is_alive; } void update() { tx += dx; ty += dy; if (Math.min(tx, ty) < 0) { is_alive = false; return ; } if (tx > width || ty > height) { is_alive = false; return ; } stroke(255, 0, 255); fill(0, 0, 255); ellipse((float)tx, (float)ty, (float)tr, (float)tr); } } void draw() { background(0); ship(mouseX, mouseY); boss.doShinking(); for (int i = danmaku.size() -1; i >= 0; i--) { Bullet b = (Bullet)danmaku.get(i); if (!b.isAlive()) { danmaku.remove(i); continue; } b.update(); } for (int r = 0; r < z.length; r++) { z[r] += 2; if(z[r] > width + 7.5){ z[r] = random(-1000,-10); y[r] = random(height); } stroke(255, 0, 255); fill(0,0,255); ellipse(z[r], y[r], 10, 10); } } ```ここに言語名を入力 ソースコード
試したこと
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/10 06:06