Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
TheMeq
13
Years of Service
User Offline
Joined: 5th Sep 2012
Location: Nottingham
Posted: 18th Oct 2012 15:01
Hello, my name is Richard, Ncie to meet you all.

Im trying to create a music rhythm game and im having a few troubles getting the maths right. What I am trying to do at the moment is get my notes moving down at the beat of the music.

I have some variables set up.



how do I figure out what var_inc should equal to, taking into account, the fps (which often changes).

Thanks!

TheMeq
13
Years of Service
User Offline
Joined: 5th Sep 2012
Location: Nottingham
Posted: 20th Oct 2012 12:33
Any help with this would be muchly appreciated.

Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 20th Oct 2012 16:18
Just as a heads up, both to you and anyone else who might've been about to answer, I'm putting together an example for you right now, so I'll post it here as soon as it is done.


Previously TEH_CODERER.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 20th Oct 2012 19:00
Ok, I was going to try and get as far as actually a small game example but I'm afraid I've run out of time. Hopefully this will still be a useful starting point.

No interaction really at the moment. You set up a song by telling it how long the song is and what its BPM is. It then generates some random values in the array for keys to press on each beat in the song.

Well, take a look. Just run it and then press enter. It does a few empty bars so the user can get used to the pace before they would have to start pressing anything. Let me know if you have any questions.



Hope this helps!


Previously TEH_CODERER.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Oct 2012 19:24
I get an array out of bounds or does not exist error at line 420 as soon as I start it. I'm using W7.


That's some example all the same.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 20th Oct 2012 19:29
How very bizarre...that should be entirely impossible!

[Line 420] timerSystem_frame(array count(timerSystem_frame)) = tTimer - timerSystem.current

That line is only called after the array has been dimensioned with a size of 30 so that should be accessing element 29; the last element.

I'm assuming we're both using the latest version of DBPro here, not that I could think what would've changed between version to cause that to error.


Previously TEH_CODERER.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Oct 2012 19:44 Edited at: 20th Oct 2012 20:07
I've just tried this



and the value printed is -1 and it gives the error at the next line as soon as I hit the spacekey().

I'll do a bit more checking.

I'm using U77RC7.

Edit I get that error immediately after the dim statement as well. I'll test this on my main PC and report back. I agree this shouldn't happen.

Edit2 I get exactly the same error on my Vista PC using a new copy and paste (just in case ). But a simple test program works fine. I'll see if I can narrow down the problem. Something is interfering with the array somehow.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 20th Oct 2012 20:33
Found the bug! You had forgotten the brackets. In several places you had



instead of



With those errors corrected your code works fine on both my machines. I guess DBPro recognizes timerSystem_frame and timerSystem_frame() as two different things, a scalar and an array.

I wonder why it worked on your machine?
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 20th Oct 2012 21:53
Well I feel suitably stupid!

Thanks for taking the time to debug that. You're quite right; it is bizarre it worked for me at all. Rookie mistake on my part.

The fixed code then hopefully.




Previously TEH_CODERER.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 21st Oct 2012 02:25
Which update are you using? If you're using the latest official upgrade, i.e. U76 (I think) then this extract from the U77 thread seems to be relevant:

Quote: "ARRAY COUNT of undefined array now returns -1 instead of 0 (which would be identical to an array with a single item)"


But your comments suggest you're using U77 as I am. As you say, bizarre. Perhaps you used an earlier version by mistake as I have done in the past.
Unlocker
13
Years of Service
User Offline
Joined: 26th Jul 2012
Location:
Posted: 21st Oct 2012 03:37
I use U762 and try last example. Compiller find syntax error in BOX commands. i debug all BOX commands like this:

box x1, y1, x1 + 1, y2, borderColor, borderColor, borderColor, borderColor

instead:

box x1, y1, x1 + 1, y2, borderColor

after that program work but with no sound )))

the truth is out there
Unlocker
13
Years of Service
User Offline
Joined: 26th Jul 2012
Location:
Posted: 21st Oct 2012 03:49
For interest i try first variant by Andrew_Neale. And it work too, after edit BOX commands (but without sound too).

the truth is out there
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 21st Oct 2012 11:10
There is no sound, no. Your question asked how to 'get my notes moving down at the beat of the music' (which you were setting a BPM for in a variable already, so actually playing music for this example was pretty much irrelevant) so that is the bit I covered. The pulses in that example happen at the BPM specified when creating the song and the notes scrolling down always center themseleves within the boxes at the bottom on those beats.

If I've misunderstood what you were asking for then please let me know.


Previously TEH_CODERER.
Andrew_Neale
16
Years of Service
User Offline
Joined: 3rd Nov 2009
Location: The Normandy SR-2
Posted: 21st Oct 2012 13:17 Edited at: 21st Oct 2012 13:18
A new version for you. Slightly improved note movement to give a better feel of a beat as well as some simple sound this time.



[Edit]Missed an 'n' in versio[n] and couldn't let it go. [/Edit]


Previously TEH_CODERER.
TheMeq
13
Years of Service
User Offline
Joined: 5th Sep 2012
Location: Nottingham
Posted: 24th Oct 2012 12:15
I'll try this out tonight! How exciting!! Thanks Andrew

TheMeq
13
Years of Service
User Offline
Joined: 5th Sep 2012
Location: Nottingham
Posted: 14th Nov 2012 00:24 Edited at: 14th Nov 2012 00:52
Hi, the code is brilliant, sorry for the late reply.

A few questions.

If i wanted to make beat files, how would i incorporate that, and also, the bars seem to judder a little bit... and im not sure how to smoothen that out.

The kind of movement I am after looks like this:

http://www.youtube.com/watch?v=ZKb9xmvV00E

and I have a feeling it has something to do with this line:



Login to post a reply

Server time is: 2026-07-07 10:12:10
Your offset time is: 2026-07-07 10:12:10