Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Track and field


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 trigg   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 August 2001 - 01:11 PM

Hi all I''m trying to make a game similar to track and field using flash. Please dont laugh, i''ve done the long jump using projectile motion, it took some time but works OK some small refinements. I''m currently working on the 100ms what i''m having difficulty getting a grasp of is how to decelerate the runner, accelerations is no problem. code =============================================================== HcapVal = 0.5 FPS = 30 if (Key.isDown(Key.LEFT)) { if(!lon){ // lon is activated by clicking the right key Lspeed += HcapVal lon = 1 ron = 0 } } speed = Math.round(Rspeed + Lspeed) // adds left and right values _x += speed // makes runner move on Xaxis =============================================================== i cant for the life of me get the runner to decelerate!!!! any ideas, would be gratefully accepted. Starting GCSE Physics in 3 weeks. Doh! Many thanks Trigg ============================== you can lead a horse to water but a pencil must be lead ! ============================== stan laurel ( THE BRATS)

Sponsor:

#2 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 21 August 2001 - 04:12 AM

I don''t see how you''re calculating Rspeed. It seems that Lspeed is always positive, *and* always increasing whenever the left arrow is down. Is Rspeed negative? Does Lspeed ever get reduced? The only way to achieve deceleration as I see it in your code is if Lspeed gets reduced or Rspeed is negative.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#3 trigg   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 2001 - 10:50 AM

HI

Flash is timeline based, you have a main timeline, which can have Movie clips at various frames within the animation, and each movie clip can have its own timeline,

how i''ve come to use Lspeed + Rspeed, its on the key press which adds the left key and right key values together. its when the user has either stopped pressing the keys therefore the runner needs to decelerate. also if the user hesitates for a period the runner also needs to slow down. this makes it a more enjoyable user experience, i think, well thats how the original game works.

If you dont know how the game works, try download Mame32 and you can then D/L track and field or hypersports.(same)

The difficulty is getting the runner to slow down.

i know the speed(Lspeed + R speed)
i know the FPS=30
i can get the distance if i need

i''ve come up with a formula.

speed = ( speed - ((speed/fps) * speed))

I check things in excel and i get a nice curve, and it takes a little longer for the runner to slow down, than by using

speed = speed/2

the formulas are put into a loop.

anywayz there you go, i''m now going to try and give it a go

Trigg out



==============================
you can lead a horse to water

but a pencil must be lead !

==============================
stan laurel ( THE BRATS)

#4 trigg   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 2001 - 12:36 PM

yo dude

take a ganders at

http://www.pixcel8.co.uk/longjump/longJump.html

its just in it early stages no design.



==============================
you can lead a horse to water

but a pencil must be lead !

==============================
stan laurel ( THE BRATS)

#5 grhodes_at_work   Moderators   -  Reputation: 1361

Like
Likes
Like

Posted 22 August 2001 - 04:30 AM

I remember playing Track & Field many years ago.

I looked at your demo. I think it will be quite fun once you''ve finished it!

Unfortunately, I don''t really see how to do anything. I pressed the Play button, and the "Speed" display says "0" (makes sense). Using the up/down arrows I''m able to change the angle but I don''t see how to get the character to move or jump. The left/right arrows don''t seem to do anything at all. Perhaps you could add a small area describing controls on the screen?

In your original post, you showed this code:


if (Key.isDown(Key.LEFT)) {
if(!lon){ // lon is activated by clicking the right key
Lspeed += HcapVal
lon = 1
ron = 0
}
}

Now the way I see it, Lspeed only increases here---never gets smaller. At least you have not shown any code that causes Lspeed to reduce. This logic occurs only when the left key is pressed and the right key is NOT pressed. Makes sense.

Your speed is then calcluated by:


speed = Math.round(Rspeed + Lspeed)

You then use this value of speed directly to update _x.

I have three questions:

1) How is Rspeed calculated? Is it always positive as is Lspeed or can Rspeed be negative? Show me the formula.

2) Can Lspeed ever become smaller? Is there some code that you have not shown that is like Lspeed -= some_value? It just concerns me that maybe Lspeed is growing unbounded when you continue to press the left button.

3) Where is the code that you posted later, the code that reduces speed:
speed = ( speed - ((speed/fps) * speed)) 
? Is this something you added after your original post? Also, is your speed ever > sqrt(fps)?

I understand the timeline idea. Just still trying to get a grasp of what your code is doing so I can possibly offer some suggestions to fix the problem....

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

#6 trigg   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 2001 - 10:46 AM

Sorry about the confusion.

here goes then,

controls
left/right/up // just as in T&F years ago you press the right and then the left key similtaniously, Lspeed/Rspeed these get added together which is then added to move on Xaxis.

when the runner starts moving, i check the distance to see if run over board, if not OK

when user press the up key, it stops the runner where he is then makes the angle.

if the user has a .5 of a second delay in not pressing up, the this fires the projectile motion function and gets passed the speed and angle.

this then gives me a distance that the runner has jumped i then take away the distance where the runner has stopped from the board.

i then fire a variation on the projctile motion function this gives me my nice jump etc, when the runner has landed you can move onto the next jump.

I also store the jumps into array, this gets fired straight from the runner starts to run. so when you view the replay you can view any of them in any order, at first it played the lapse when the user presses the up key, i got around this by halting the population of the array until the 0.5 delay kicks in, after this i add the positions to the array etc.

at the moment the runner does not slow down, i''m just trying to get my head around a cool formula that i can apply, i could bodge it, but i want to make other events, which use the same code.

the final result stage1 will be a 1 player game, where you can store you scores, personailse the characters etc etc.

the stage2 will be multiplayer/multi spectator/ where repeat visits will award you extra powers even if you are a spectator, you can jeer and heckle even do a streak across the screen.

lots of ideas and little time to do them in.

hope that helps dude

trigg






==============================
you can lead a horse to water

but a pencil must be lead !

==============================
stan laurel ( THE BRATS)

#7 Torn Space   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 2001 - 10:56 AM

Every update frame, have the program take X off of your velocity. Every time you hit the run buttons, add Y to your velocity. That way as long as you keep hitting buttons you''ll go faster. Stop hitting buttons and you''ll start to slow down.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS