Jump to content
  • Advertisement
Sign in to follow this  
boehmz

How is Guitar Hero Programmed?

This topic is 3378 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

Do they just have a timer start with the song and tell it what notes need to be hit at certain time intervals(in a sense, brute force)? Is there any other way to do it than just have: when timer is between 3 and 3.5 seconds, give points if green button is strummed when timer is between 4 and 4.5 seconds, give points if yellow button is strummed when timer is between 5 and 5.5 seconds, give points if green button is strummed etc.

Share this post


Link to post
Share on other sites
Advertisement
Sounds like a good approach to me, except that 0.5 seconds per note is way too long.

Of course, it gets slightly more complicated when considering chords, held notes, hammer ons/pull offs and so forth...

Also, I guess tightly packed notes are handled, so that their "trigger time" can overlap.

Share this post


Link to post
Share on other sites
I believe that the engine works by comparing the current active input notes (fret or strummed, depending on GH version) to the notes nearby the current track time, where "nearby" is defined as being within a certain treshold distance from the note. This logic is executed when either the strum bar is moved (classic GH operation), or in case of the special fret buttons (lower on the neck on guitars > GH3), when the button is pressed. In essence, the core algorithm is just an one-dimensional position search with a distance treshold.

If nearby track notes that match the input notes are found, the game registers a success. Conversely, a failure is registered if track notes matching to the input notes are not found.

In case of the sliding notes, there is an additional logic to see whether the input buttons corresponding to the slides are held down during the duration of the track notes.

Hammer-ons and pull-offs work by observing the success status of the previously played consecutive notes.

Share this post


Link to post
Share on other sites
>>when timer is between 3 and 3.5 seconds, give points if green button is strummed
Ive never played the game so bare with me

if ( abs(time - eventtime)*(1.0/0.25) > 1 )
scoer = 0.0
else
score = 1.0

though there will be overlap between ( handled by a lerp)


sorry drunk as a fart ATM (sat night rah rah) but in case youre interested in created a 'fun' game, choose the middle of 'between 3 and 3.5 seconds' and deviate off that, i.e. never have a fixed value between X+Y is perfect + rest aint

Share this post


Link to post
Share on other sites
I can't tell you exactly how Guitar Hero is programmed as I have never seen the source, but I believe that they use a midi file for the notes, an mp3 (or equivalent) file for the actual songs, and the note positions are calculated based on the note delta times in the midi file.

Something like:


int NoteTime = (int)(((iNoteSpr.mRSNote.mStartTime + 0.0) / mSong.mTimeDiv) * (60000.0 / (mSong.mBPM)));
int NoteEndTime = (int)(((iNoteSpr.mRSNote.mEndTime + 0.0) / mSong.mTimeDiv) * (60000.0 / (mSong.mBPM)));


float len = (float)(240 / mNoteImages[0].mTex.Width);


float z = (float)(240.0 + (((songPos * 1000.0 - mNoteDelayTime - NoteTime) / (60000.0 / (mSong.mBPM))) / (60.0 / len)) * (240.0 * iNoteSpr.mRSNote.mDirVal));

if (iNoteSpr.mRSNote.mDirVal == -1)
z -= iNoteSpr.mTex.Width/2+mTarget.Width;


float w = Math.Abs((float)(240.0 + (((songPos * 1000.0 - mNoteDelayTime - NoteEndTime) / (60000.0 / (mSong.mBPM))) / (60.0 / len)) * (240.0 * iNoteSpr.mRSNote.mDirVal)) - z);



Which is from an abandoned game of mine... The code is a mess but it works..

The Frets on Fire source might be a good place to look (It is written in Python if I remember correctly).

Good luck.

Share this post


Link to post
Share on other sites
There are 5 buttons. These can be represented via an int, by setting bits.

Let track be made of adequate number of samples. At any given point in time, a certain set of buttons must be pressed.

int samples[];
notes = 0;
time = 0;
while (running) {
int buttons = readInput();
if (samples[time] != buttons) {
// wrong
} else {
// correct
}
time++;
Sleep(100);
}
This is probably the simplest possible solution, that just might work in practice.

An example:
// Yellow button is second
in binary: 000010
as integer: 2

Track requiring user to press yellow button from 0.5s to 1 second would be:
{0,0,0,0,0,2,2,2,2,2,2,0,0,0,.....}

Share this post


Link to post
Share on other sites
Quote:
Original post by Kwizatz
You can take a look at Frets On Fire's Source Code to get an idea.


This is assuming that FoF is programmed the same as GH, which it probably is not. I've played FoF and it doesn't seem as responsive or as fluid as GH.

Share this post


Link to post
Share on other sites
Yes, that may be true but Frets on Fire can import Guitar Hero songs, so at the very least the concepts are probably similar... At the end of the day it doesn't really matter how GH was programmed. If the OP wants to create a similar game than the Frets on Fire source is probably a good place to start (or at least better than trying to hard code every note).

Share this post


Link to post
Share on other sites
Having trouble viewing Frets on Fire source. Got python and pygame installed. When I try to open the .ogg files, a blank command prompt comes up.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!