• Advertisement
Sign in to follow this  

Optimization of simple rhythm game

This topic is 2300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font="verdana, geneva, lucida,"]
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! [/font]

Share this post


Link to post
Share on other sites
Advertisement
I'd lean towards the second option - not because "thousands" of notes is going to be a noticeable load on any modern PC, but because it'll help you think out solutions to complex problems.


Some hints to get you started:


Define the edge of the screen as "now" and the opposite edge as "now plus some time." The amount of time will depend on the tempo of the song and how close together you space your "notes." For instance, it might be 10 seconds.

Define a song as a series of notes, with each note being marked with a time value. When the current song time reaches 10 seconds (or whatever) prior to the note's play time, draw it at the far edge of the screen. As the actual song time moves closer to the note's play time, use linear interpolation to move the note towards the "now" edge.


See if you can piece it together from there :-)

Share this post


Link to post
Share on other sites
Thanks for the advice! One more thing though, here's what I have in my mind right now:

(1) [color=#1C2837][size=2]Define a song as a series of notes, with each note being marked with a time value (just as you said)
[color="#1c2837"](2) When a level (song) starts, record the time and after each iteration of the "game loop" check the time elapsed since the level started and draw the notes accordingly.
[color="#1c2837"]

[color="#1c2837"]So here's my question should I "force" my "game loop" to run at specific (maybe programmer defined) time intervals?
[color="#1c2837"]

[color="#1c2837"]Thanks a lot!

Share this post


Link to post
Share on other sites
Also keep in mind what would happen if you have a song hours long. If you place them all when the song starts, you may run out of precision in your time datatype. Trying to modify the imprecise values repeatedly would cause them to be jumbled by the time they reach the goal point. Drawing them when they appear is advantageous. Also, consider the game In The Groove; some effects, such as notes moving from side to side and pulsating, would not be possible if you predetermined their positions at the start. If you decide to implement more features later, the design with the least limitations would prevail.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement