Hello! For a final project I am working on coding something similar to guitar hero. Currently, I have one colored dot that travels to the bottom of the screen (when it hits the bottom, the user is supposed to push a button on the keyboard to make sound). I am wondering if it is possible to have multiple of these dots travel down the screen at the same time, but have the times offset? This is what my figure looks like so far: so the yellow ball travels down the screen, and when it hits the open circle at the bottom you are suppsoed to hit the corresponding note, but I want circles to be running down the lines at the same time (but start at different times), and this is the code I have so far: function lines()
close allx1=[.5 .5];y1=[0 1];x2=[1.5 1.5];x3=[2.5 2.5];x4=[3.5 3.5];x5=[4.5 4.5]; %positions of all lines%
hline1=line(x1,y1,'LineWidth',1);hline2=line(x2,y1,'LineWidth',1);hline3=line(x3,y1,'LineWidth',1);hline4=line(x4,y1,'LineWidth',1);hline5=line(x5,y1,'LineWidth',1);%plot lines%
hold on axis([0 5 0 1]);%set axes%
ballPos1=[.5 1];%moving ball in this exampe%
ballPos2=[.5 0];ballPos3=[1.5 0];ballPos4=[2.5 0];ballPos5=[3.5 0];ballPos6=[4.5 0];%markerballs at the bottom%
hBall2=plot(ballPos2(1),ballPos2(2),'ko','MarkerSize',13);hold onhBall3=plot(ballPos3(1),ballPos3(2),'ko','MarkerSize',13);hold onhBall4=plot(ballPos4(1),ballPos4(2),'ko','MarkerSize',13);hold onhBall5=plot(ballPos5(1),ballPos5(2),'ko','MarkerSize',13);hold onhBall6=plot(ballPos6(1),ballPos6(2),'ko','MarkerSize',13);hold onhBall1=plot(ballPos1(1),ballPos1(2),'ko','MarkerSize',13,'MarkerFaceColor','y');%plots all the different circles%
while ballPos1(2)>=.5set(hBall1,'XData', ballPos1(1), 'YData', ballPos1(2));ballPos1(2)=ballPos1(2)-.01;pause(.03)end%moves the yellow ball down the line%
end
I'm looking on suggestions for functions/ commands that could help me do this, or maybe a timer? I'm not totally sure yet. Thank you!
Best Answer