🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

X axis is now working

Published September 01, 2020
Advertisement

It has been a long road, and it may not be much to look at but this to me represents a lot of progress. Behind the scenes of this brief clip,

an instance of the Controller class has had its controlStatus linked to the controlStatus of Actors[0], which is player 1 or Bob in this case. A change in that controller's state like hitting a button will cause the control status of Bob to change.

GamePage.OnAppearing() which is the apps main loop is iterating at ~ 30fps, invoking its Binding Context, GamePageViewModel's EvaluateMotion() command.

Once per frame, GPVM_.EvaluateMotion in turn calls GPVM.EvaluateHorizontalMotion() and (soon) GPVM.EvaluateVerticalMotion().

These functions evaluate the list GPVM.Actors, examining their control states to see if they are getting commands to move left or right.

If they are getting commands to move left or right, that actor's X Acceleration Rate is changed, either going up (moving right) or going down (moving left).

If they are not getting commands to move left or right (neither button pressed), then GPVM.EvaluateHorizontalMotion() invokes that actor's .DecelerateXAxis() function, slowing it down until speed and acceleration are both 0. If the actor is moving left, speed and and acceleration are negative and gradually have to increase until they reach 0. If the actor is moving right, speed and acceleration have to decrease until they reach 0.

There were many missteps to reach this point, no sense dwelling on them now. What is next is collision detection since its going to be very hard to get into debugging Y axis motion without that. I am actually not very scared of this, collision detection is a matter of linear algebra. It is just that there are slow cumbersome ways to do this which would result in a lot of execution time every frame and a slow choppy framerate – and there are fast optimal ways to do this which detects collisions in the least amount of time. That is definitely a topic worthy of its own post, so stay tuned for Collision Detection

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement