• Advertisement
Sign in to follow this  

Programming a Reaction Time

This topic is 2377 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
Advertisement

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?


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.


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));


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
Sign in to follow this  

  • Advertisement