Dissonance
Previous days I didn’t do MUCH work on this, though I think I only had one day that I didn’t do anything. So at least I made partial progress over the days. This would be day 20, but I don’t think I’ll mention days from now on since I’m not doing daily updates (though I will continue to work on it daily).
I think I may be doing more updating now though, and working more on it each day, because I’ve got at least one cool thing now to work with. I have motion now!
Video:
I had to record with the console open as the screen capture software doesn’t record the game if the game is selected for some reason.
I’ll explain this video a bit.
The lines are only for demonstration purposes, I only put them in to explain the motion.
The method of movement was surprisingly simple, I’ve made a similar type of motion, but with arrow keys, and I did it in a much more complicated way.
Basically, there’s the movement vector, stored basically as an X and a Y value. Every frame (60 frames per second) the circle is moved by its movement vector.
In the video, the movement vector is represented by the line on the RIGHT. The length of the line is the exact length the circle moves per frame. Bear in mind the video is at 20 FPS, but the game runs at 60 FPS.
Then you also have another vector which is the target vector. This is only calculated when the mouse moves.
When you move the mouse (which starts in the centre of the screen), the distance you moved it in the X and Y direction are calculated, this is divided by a mouse sensitivity variable, which is just to normalise it to a reasonable value so that you aren’t moving crazily fast.
So that gives you the target vector.
There is also a value for acceleration. This is 0.01 at the moment. Basically, you move each value of the movement vector 0.01 (1%) of the way towards the target vector.
If you are constantly moving the mouse then basically you’ll accelerate to the direction (and magnitude) you are moving the mouse.
Also, every frame decelerates the movement vector too.
Deceleration is calculated for every frame, acceleration is only calculated when you’re moving the mouse.
This all ends up a lot simpler than what I did in the last game with movement I made, in which I did crazy stuff like calculating the component of acceleration in the direction of movement, and perpendicular to it. This method is simpler, and still has the same sort of functionality, it’s just the simple method means you don’t NEED to calculate components of movement because it’s already taken account of implicitly by magical maths.
Also, to note, the movement feels cool, which is something the video can’t show I guess. But yeah it feels cool which is good.
_____
I’m eventually going to change the method of viewing so that the player is always centred on the screen. I’m also going to slow the movement down. Also I currently have no max speed, but I will create a max speed.
I’ve also sorted the screen ratio thing so a circle is a circle not stretched relative to your screen ratio.