Sign in to follow this  

Programming a Reaction Time

This topic is 2306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Based on the player's cordinates on screen I'm adjusting a 'angle'... However I'd like to it be 1 second or so behind the actual cordinates..

I'm using XNA so the game run's at 60 fps, I was thinking of creating a counter of creating an array of 60 elements

And on each frame
> downshift all elements
>add the current cordinate to the first element
>process the last element

Any other ideas?

Share this post


Link to post
Share on other sites
[quote name='Watermelon Chris' timestamp='1313094166' post='4847888']
Based on the player's cordinates on screen I'm adjusting a 'angle'... However I'd like to it be 1 second or so behind the actual cordinates..

I'm using XNA so the game run's at 60 fps, I was thinking of creating a counter of creating an array of 60 elements

And on each frame
> downshift all elements
>add the current cordinate to the first element
>process the last element

Any other ideas?
[/quote]

Implementing a ring buffer (i.e. circular queue) would be much more efficient than shifting.

Share this post


Link to post
Share on other sites
For future reference: I got it working like this.

[code]
if (timerCountGame >= 60)
{
enemyBullet[0] = new Rectangle(
Convert.ToInt32(playerPositionHistory[0].X)
,Convert.ToInt32(playerPositionHistory[0].Y)
, 80, 80);

playerPositionHistory.RemoveAt(0);

}

playerPositionHistory.Add(new Vector2(player1Rec.X, player1Rec.Y));
[/code]

The timer is just there as a 'warmup' but it also effects the 'reaction time' since there are 60 updates a second theres a 1 second reaction time.

Share this post


Link to post
Share on other sites

This topic is 2306 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this