We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, this is my first time using the forum. I'm working on a project where I make Dance Dance Revolution, but I can't understand how to create arrows that move up the screen at designated times. I'm not sure if I'm explaining this well, and I don't have any example code either because I have no idea where to start. Any help would be much appreciated.
Answers
It's hard to answer general "how do I do this" type questions. It's much easier to answer "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense.
The best thing I can tell you to do is to break your problem down into smaller pieces and then take those pieces on one at a time. Can you create a program that just shows a single hard-coded arrow? Separately from that, can you create a program that just shows a single rectangle moving up on the screen? Work your way forward in small steps like that. Then if you get stuck on a specific step, you can post a MCVE along with a specific technical question. Good luck.
So I tried what you said, and ended up with something that (somewhat works). The problem is, the arrows are always slightly different each time I play the program. My code is as follows:
`import processing.sound.*; SoundFile song; class Arrow { float y; Arrow() { y = height; } void draw() { fill(0); stroke(255, 0, 0); strokeWeight(12); y = y - 20; if (beatTime >= 14000 && beatTime <= 15300) { ellipse(384, y, 100, 100); }
} }
ArrayList arrow;
int beatTime;
boolean arrowAppear() { return(millis() >= beatTime); }
void setup() { fullScreen(); smooth(); song = new SoundFile(this, "Zookeepers Heuse - Mercury [NCS Release].mp3"); arrow = new ArrayList(); song.play(); }
void draw() { background(0);
fill(0); stroke(0, 255, 0); ellipse(384, 200, 100, 100); ellipse(768, 200, 100, 100); ellipse(1152, 200, 100, 100); ellipse(1536, 200, 100, 100);
for (Arrow arrows : arrow ) arrows.draw(); if ( arrowAppear() ) { arrow.add( new Arrow() ); beatTime = millis() + 1000; } }`
Not sure why the code option is doing that. It only seems to sense that one line as actual code even though I put the entire thing in the code option.
You need to highlight your code and then press the code button in the editor.
Like I said, please try to work in smaller steps. Your question has nothing to do with playing music, right? So please don't include that code. Instead, post a MCVE that just does a single thing.