Home › Forums › Software Development › Move only on the X axe
- This topic has 2 replies, 2 voices, and was last updated 8 years, 9 months ago by TheMyrel.
- AuthorPosts
- 27/11/2015 at 12:26 #3838TheMyrelParticipant
Hello!
I’m trying to create the game pong and I want to move a paddle only horizontally.
For now it’s moveing anywere I’m looking on the screen.
Can someone please give me an idea how can I achive that?I have the code here if you want to take a look:www.dropbox.com/s/2afveqo3m2iyww8/joc.rar?dl=0
I’m working with Visual Studio 2010 and XNA 4.0
Thanks!
02/12/2015 at 11:33 #3856Jenny [Tobii]ParticipantHi,
If you only want to change the X value, then only change the X value in your code.
Hard-code the Y value to the Y position you want your paddle to slide along, and update the X value according to the Gaze Point’s X value.You should probably also do some filtering of the Gaze Point’s X value so that the paddle does not jiggle or jump back and forth.
You can filter the eye-gaze data by calculating a moving average using the last 10 Gaze Points. Here is a simple description of how to calculate a moving average:
http://www.statisticshowto.com/moving-average/
This will make all paddle movements overall slower and smoother.A more advanced filtering would be to use an exponentially decaying filter as explained here:
http://stackoverflow.com/questions/3760506/smoothing-values-over-time-moving-average-or-something-better
This would make the paddle steady when the eye-gaze is focused on specific point, but fast when moving the eye-gaze to another part of the screen.02/12/2015 at 14:30 #3858TheMyrelParticipantThank you a lot for the answer!
I’ll give it a try. - AuthorPosts
- You must be logged in to reply to this topic.