How is Guitar Hero Programmed?
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.
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.
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.
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.
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.
>>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
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
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:
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.
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.
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.
An example:
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 secondin binary: 000010as integer: 2Track 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,.....}
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.
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).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement