Optimisation regarding rhythm game
Hi guys,
I'm creating a rhythm style game in C++ where the notes come down the screen and you have to hit a key that corresponds to that note within the correct time, I'm sure we all know those type of games by now :3
My question is regarding the best way to create hundreds, and in some cases possibly thousands of note objects. I currently thought of two ways to do it:
1) Create and place every note manually before the song starts. This would mean placing notes at positions like 200, -4000, so the notes move down the Y axis at the same pace, and obviously the lower the Y axis, the later the note arrives.
2) Create the notes as the song is playing based on the amount of time that has elapsed, and place them all in the same position on the Y axis when doing so.
The first way appeals to me more as I can create everything before the game begins, and keep destroying the notes as they're no longer needed, but it seems like a strange idea to have notes starting at such low numbers on the Y axis; is this a feasible way to do it?
The second way seems like a better option, as there's a lot less notes, thus a lot less lag throughout, but I'm not entirely sure how I'd go about this option; so if this is the better option, a little advice on how to go about this would be appreciated.
Thanks for reading
~Rob
Re: Optimisation regarding rhythm game
Re: Optimisation regarding rhythm game
Guitarhero clone ?
Making a bitmap for the entire song and then just blitting the part you need will likely fail for bigger songs as there are limits to the size of a bitmap, and amount of memory available in the machine.
The proper way to do this would be to indeed just draw the notebar when it's needed.
Re: Optimisation regarding rhythm game
Thanks, but how exactly would I go about doing that? I'm not sure how I would structure a song to make notes appear only after a certain length of time; using GetTickCount() doesn't seem like a way I'd want to do it :P Anything you can direct me into looking at?
Re: Optimisation regarding rhythm game
GetTickCount is not going to be accurate enough, you need a multimediatimer.
As for drawing itself... There's lots of ways about it. The simplest would seem to store all the notes chronologically and then each frame you draw locate the range of notes that fall within the displayed timeframe.
As with all projects... Start playing with it, start with the simplest solution you can find and see if it works, chances are it's going to be adequate. If not, rethink and improve. Don't try to create something new by starting with the optimising, it just doesn't work :)