mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-10 21:19:43 +01:00
b8a4b4dfe7
I was investigating a desync in my Nova TAS, and it turns out that the gravity line collision functions check for the `oldxp` and `oldyp` of the player, i.e. their position on the previous frame, along with their position on the current frame. So, if the player either collided with the gravity line last frame or this frame, then the player collided with the gravity line this frame. Except, that's not actually true. It turns out that `oldxp` and `oldyp` don't necessarily always correspond to the `xp` and `yp` of the player on the previous frame. It turns out that your `oldyp` will be updated if you stand on a vertically moving platform, before the gravity line collision function gets ran. So, if you were colliding with a gravity line on the previous frame, but you got moved out of there by a vertically moving platform, then you just don't collide with the gravity line at all. However, this behavior changed in 2.3 after my over-30-FPS patch got merged (#220). That patch took advantage of the existing `oldxp` and `oldyp` entity attributes, and uses them to interpolate their positions during rendering to make everything look real smooth. Previously, `oldxp` and `oldyp` would both be updated in `entityclass::updateentitylogic()`. However, I moved it in that patch to update right before `gameinput()` in `main.cpp`. As a result, `oldyp` no longer gets updated whenever the player stands on a vertically moving platform. This ends up desyncing my TAS. As expected, updating `oldyp` in `entityclass::movingplatformfix()` (the function responsible for moving the player whenever they stand on a vertically moving platform) makes it so that my TAS syncs, but the visuals are glitchy when standing on a vertically moving platform. And as much as I'd like to get rid of gravity lines checking for whether you've collided with them on the previous frame, doing that desyncs my TAS, too. In the end, it seems like I should just leave `oldxp` and `oldyp` alone, and switch to using dedicated variables that are never used in the physics of the game. So I'm introducing `lerpoldxp` and `lerpoldyp`, and replacing all instances of using `oldxp` and `oldyp` that my over-30-FPS patch added, with `lerpoldxp` and `lerpoldyp` instead. After doing this, and applying #503 as well, my Nova TAS syncs after some minor but acceptable fixes with Viridian's walkingframe.
55 lines
960 B
C++
55 lines
960 B
C++
#ifndef ENT_H
|
|
#define ENT_H
|
|
|
|
#include <SDL.h>
|
|
|
|
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
|
|
|
class entclass
|
|
{
|
|
public:
|
|
entclass();
|
|
|
|
bool outside();
|
|
|
|
void setenemy(int t);
|
|
|
|
void setenemyroom(int rx, int ry);
|
|
|
|
void settreadmillcolour(int rx, int ry);
|
|
|
|
void updatecolour();
|
|
|
|
public:
|
|
//Fundamentals
|
|
bool invis;
|
|
int type, size, tile, rule;
|
|
int state, statedelay;
|
|
int behave, animate;
|
|
float para;
|
|
int life, colour;
|
|
|
|
//Position and velocity
|
|
int oldxp, oldyp;
|
|
float ax, ay, vx, vy;
|
|
int cx, cy, w, h;
|
|
float newxp, newyp;
|
|
bool isplatform;
|
|
int x1,y1,x2,y2;
|
|
//Collision Rules
|
|
int onentity;
|
|
bool harmful;
|
|
int onwall, onxwall, onywall;
|
|
|
|
//Platforming specific
|
|
bool gravity;
|
|
int onground, onroof;
|
|
//Animation
|
|
int framedelay, drawframe, walkingframe, dir, actionframe;
|
|
int yp;int xp;
|
|
|
|
Uint32 realcol;
|
|
int lerpoldxp, lerpoldyp;
|
|
};
|
|
|
|
#endif /* ENT_H */
|