The Daily Click ::. Forums ::. Klik Coding Help ::. How do I do this?
 

Post Reply  Post Oekaki 
 

Posted By Message

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
8th January, 2014 at 08/01/2014 21:51:06 -

Okay, I want it to work like this:

I have objects equally spaced out and after a certain point...
all the new objects are closer together than the earlier ones but still equally close together to each-other.

How do I do this using only events and calculations?

And no, I do not want to use an active to trace that distance between them because these positions have to be ultra-precise and scalable.

 
Maltar Draco, I do PC gaming.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th January, 2014 at 09/01/2014 13:19:14 -

I think I'm going to need a diagram - I can't really picture what you mean.

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
9th January, 2014 at 09/01/2014 16:22:54 -

Easy.

I'm assuming you have two points and you want all the objects to be positioned between those points equally spaced apart.

The algorithm would work like so:

1. Calculate the distance between the points: dist = sqrt((x1-x2)^2 + (y1-y2)^2)
2. Divide by the number of objects to find the spacing: spacing = ( dist / # of objects )
3. Calculate the angle between the two points: angle = atan2(y2-y1, x2-x1) Note: you might have to flip the points around, I can't remember.
4. Use a loop (or whatever you want) to position the objects like so:
X position = cos(angle) * spacing * n
Y position = sin(angle) * spacing * n

Good luck.

 
n/a

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
9th January, 2014 at 09/01/2014 22:09:54 -

Would it help if I told you they were in one dimension meaning no need for angles?

Edited by Maltar Draco

 
Maltar Draco, I do PC gaming.

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
11th January, 2014 at 11/01/2014 01:07:27 -

I agree with sketchy, its hard to tell what your going for without some kind of diagram.
"all the new objects are closer together than the earlier ones but still equally close together to each-other"
this confused me as to what you actually want to do lol.

 
[Game design makes my brain feel like its gonna explode.]

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
15th January, 2014 at 15/01/2014 21:18:05 -

Would it help if I told you that the dimension was time and that this was for my guitar hero game and also that changes in distance are actually changes in tempo and that the positions of the objects are measured in milliseconds?

Yes, milliseconds!

Always
Set counter to timer


So if it was at 120 bpm and you had four chrotchets.
They would be at...
0 ms
500 ms
1000 ms
1500 ms
But then after the fourth note for whatever reason you decided to change to 140 bpm, the new notes would have to be at...
2000 ms
2429 ms
2857 ms
3286 ms

How do I calculate that?

 
Maltar Draco, I do PC gaming.

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
16th January, 2014 at 16/01/2014 01:06:57 -

That sounds like a real challenge to get all that math to work. Because i feel once you got it up and going it would run slow. Ever thought about using the surface object, and build graphics for the buttons from one long guitar graphic stored outside the program.

Then maybe check for rgb values at spots using an array of some sort. So time is hard coded into the array, ever cell stands for a millisecond.

I don't know if it would even work. but that's how i would try and do it. Just to keep the object count down. It can get out of hand really fast.

 
https://www.facebook.com/nathon.brown.7

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
16th January, 2014 at 16/01/2014 20:03:09 -

Yea i agree with pan tosser, this is gonna be a very complicated project.

 
[Game design makes my brain feel like its gonna explode.]

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49566

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
16th January, 2014 at 16/01/2014 23:36:36 -


Originally Posted by Maltar Draco
Would it help if I told you that the dimension was time and that this was for my guitar hero game and also that changes in distance are actually changes in tempo and that the positions of the objects are measured in milliseconds?

Yes, milliseconds!

Always
Set counter to timer


So if it was at 120 bpm and you had four chrotchets.
They would be at...
0 ms
500 ms
1000 ms
1500 ms
But then after the fourth note for whatever reason you decided to change to 140 bpm, the new notes would have to be at...
2000 ms
2429 ms
2857 ms
3286 ms

How do I calculate that?



How'd you calculate the numbers you have in your example? Use the same math.

 
n/a

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
18th January, 2014 at 18/01/2014 16:16:57 -

I forgot to mention that data is stored in ini.

In the example I showed you it would be:

[SyncTrack]
0 = 120
768 = 140

[ExpertSingle]
0 = N
192 = N
384 = N
576 = N
768 = N
960 = N
1152 = N
1344 = N

 
Maltar Draco, I do PC gaming.

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
21st January, 2014 at 21/01/2014 01:17:34 -

i still don't fully understand what you are looking to solve for. i don't see the connection between the beats per minute and the spacing of pixels.

All i see is at 120 bpm ever new chrotchet steps by 500ms. To space that example all you need is a simple ratio for spacing pixels. Right now it looks like all have to do is times it by 4.16

but that seems to simple. So i got to wonder if i understand the question correctly. i don't see what i'm missing.

 
https://www.facebook.com/nathon.brown.7

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
21st January, 2014 at 21/01/2014 18:17:37 -

The part you're missing is that fact that at one point it changes and from there in on there the amount you calculate by from that point changes. I think!

I could very easily calculate the whole thing if the song were to be entirely in a single consistent tempo but practically everything except folk music changes tempo and my game engine has to account for that.

I have good reason to suggest that GH actually does it in the way that I want to do it, GH is very much a millisecond-based game engine, a detailed explanation of GH's game engine would probably get me to exactly what I want.

Milliseconds is also the only reliable method of doing it, if it was based on fps and then it lags, the game desynchronises and that timing window is very sensitive.

 
Maltar Draco, I do PC gaming.

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
21st January, 2014 at 21/01/2014 22:28:02 -

i see what your saying. you could use 0.3472 as a base. i came up with that number by dividing 12 into 4.16

which represents 10bpm. so if the temp went from 120 to 130 you would subtract ( 4.16 - 0.3472 )= 3.8128

then 130 * 3.8128 which gives 495.6

so if the fourth note changed to 130bpm you would add the above to the 3rd note ( 1500 + 495.6 )

That helps you build your ini file. but still has nothing to do with spacing pixels. but in trying to make my own example just to test it out. i recommend increasing the frame rate as the tempo goes up. This allows you to keep all the notes the spaced at the same distance.

 
https://www.facebook.com/nathon.brown.7

Maltar Draco



Registered
  22/08/2013 19:25:19
Points
  215
22nd January, 2014 at 22/01/2014 01:03:28 -

The positions in the ini are actually relative to the beats and not their actual position in time else the level editor would be completely impracticable.

Edit: The pixels are determined by the position in time and this moves across the screen as time progresses.

Edited by Maltar Draco

 
Maltar Draco, I do PC gaming.

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
22nd January, 2014 at 22/01/2014 19:00:33 -

if the ini file is the source for all your conditions. Then i'd suggest making a ini group for bpm.

something like

[bpm120]

note01=500
note02=1000

[bpm140]

note01=429
note02=857

then when the tempo changes. All you have to do is use the str$() function to change the group of the ini.

-Always
-set the group
-"bpm"+str$(global value A)

Then do the same for the groups item

-Always
-set the item
-"note"+str$(global value B)

That kind of implementation would only require keeping track or the bpm (global A) and the current note (global B)

it's a bit messing using all those conversions from numbers to strings, but i really don't think their is another way with ini's. because set group and item require strings.

 
https://www.facebook.com/nathon.brown.7
   

Post Reply



 



Advertisement

Worth A Click