# Programming a Reaction Time

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

## 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 on other sites

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 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.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631773
• Total Posts
3002265
×