View Full Version : Guitar Hero Help
kdkiernan
11-30-2007, 03:53 AM
I need to make a guitar hero type game for my high school class and I need some help
the game will use the 1,2,and 3 buttons as frets and the space bar to strum... you must hit both at the same time to hit the note...
it is very similar to this model game http://www.newgrounds.com/portal/view/386989
i am very lost and could use all the help i can get quickly thank you.
garlandpool
12-01-2007, 07:48 AM
Well, dude, if I'm gonna help you, I'll need to know a little about what you already know. For example, do you know this stuff:
if(Key.isDown(Key.LEFT)){_x-=10;}
Have you started working yet? Do you have any code worked out?
kdkiernan
12-03-2007, 01:48 AM
I am not sure, but I do have basic knowledge of collision/containment codes which would seem to be helpful. I need to make it so that the fret buttons are 1-4 and the backspace is the strum or pick button. the note will only count if the corresponding button number and backspace are pressed. But Holding down the number key does not count as a miss, and the attempt to hit the note will only be made at the push of backspace. I think this may have something to do with the 1-4 buttons enabling the note and the backspace actually hitting it.
I need as much help as i can get...
If you can, take a look at this game http://www.newgrounds.com/portal/view/386989
and let me know the codes he/she would have used because this is exactly what the assignment is based on.
Thank you very much for any help at all
garlandpool
12-03-2007, 08:20 PM
I can see how your project could be done without too much difficulty if you setup a symbol the way I show in this video:
3 Frame Architecture (http://www.rosettastoneofguitar.com/fms/captivate/flash/21threeFrames/1threeFrames_nName.htm)
Once you setup a MovieClip the way this video shows, I'll tell you what to write in the 2nd frame to make your game respond to the keys you push. It'll be pretty easy. In fact, here is the code for checking to see if a person pressed the "1" key:
if (Key.getCode(49)) {
trace("You ROCK!");
}
Put that in the second frame, so the code will be checked constantly.
If you want the person to have to press the 1 key before the BackSpace button will work correctly, you do something like this:
if (Key.getCode(49)) {
if (Key.isDown(Key.BACKSPACE)) {
trace("You ROCK!");
}
}
By "nesting" these if statements you make the 1 key have to be pressed before it will allow the BackSpace button to count.
Now, if you want the code to count hitting the backspace button as a mistake if you don't press one of the notes first, then you would add this to what you now have. Here's what the whole thing would look like:
if (Key.getCode(49)) {
if (Key.isDown(Key.BACKSPACE)) {
trace("You ROCK!");
}
}
if (Key.isDown(Key.BACKSPACE)) {
trace("Dude, you sound like crap!");
}
So, that should get you started down the right path. I can forsee the challenge of making the program demand different notes at different times, but it shouldn't be hard at all.
Let me know how it goes!
Fred
kdkiernan
12-03-2007, 08:28 PM
thank you very much for the help!
I will let you know how things are going soon
kdkiernan
12-04-2007, 09:58 PM
I'm stuck on making the note being played count only when it goes over the designated line. If someone can help out that'd be great.
garlandpool
12-04-2007, 11:05 PM
Should you do a hitTest between the line and the displayed note? You could make an invisible rectangle around the line to allow the hitTest more room than just a line (which would only allow a tiny instant for the hitTest). Then say something like:
if(this.hitTest(_parent.note)){
if (Key.getCode(49)) {
if (Key.isDown(Key.BACKSPACE)) {
trace("You ROCK!");
}
}
}
So, there's a lot of nesting...the first one has to be true before the second one counts and so on.
Hope this helps...that's the best I can do given the information you have given me. I'd have to open your file and see how you're building this to help you better. I'm gonna play some guitar hero when I get home, so I'm doing what I can here! :eek:
The approach I would take is when you hit the strum, find the closest note on the line. If the currently held frets don't match the frets needed for that note, then it's a miss. Then measure the location of the note on screen (just ._x or ._y), anything within one range is ok, anything within a smaller range is good, and a smaller range than that is perfect.
You would want to store the notes themselves in an array or something, and only add them to the screen a second or two before you need to hit them. I would probably use XML to import the list of notes, and actionscript cuepoints to make sure they precisely sync up with the song, but you might rather skip those if you don't know how to use them.
kdkiernan
12-05-2007, 02:20 PM
What code would you use for finding the closest note on the line?
Is there anyway you could show me an example of what you are saying?
Well, assuming you are storing your notes in an array called notes, it could be
var closest=0;
var distance=Math.abs(notes[0]._x-goalx);
for (var count=1;count<notes.length;count++){
if (Math.abs(notes[closest]._x-goalx)<distance) {
closest=count;
distance=Math.abs(notes[closest]._x-goalx);
}
}
//now notes[closest] is the note with _x closest to goalx
Where goalx is the location of the point you need to strum.
This assumes you always have to hit one "note" at a time. So you'd need to lump multiple frets together into one note, rather than treat them as separate objects.
You could also improve the efficiency by stopping the loop once the note's _x is beyond a certain point, assuming the notes were loaded into the array in the order they needed to be hit, using unshift()
kdkiernan
12-06-2007, 03:35 PM
ok that makes a lot more sense, thanks. Is there any way you can show me an example for code that you need in order for the fret button to be 1 and the strum to be BACKSPACE?
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.