mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-09-29 17:57:23 +02:00
3ca7b09012
This fixes a regression that desyncs my Nova TAS after re-removing the 1-frame input delay. Quick stopping is simply holding left/right but for less than 5 frames. Viridian doesn't decelerate when you let go and they immediately stop in place. (The code calls this tapping, but "quick stopping" is a better name because you can immediately counter-strafe to stop yourself from decelrating in the first place, and that works because of this same code.) So, the sequence of events in 2.2 and previous looks like this: - gameinput() - If quick stopping, set vx to 0 - gamerender() - Change drawframe depending on vx - gamelogic() - Use drawframe for collision (whyyyyyyyyyyyyyyyyyyyyyyyyyyy) And now (ignoring the intermediate period where the whole loop order was wrong), the sequence of events in 2.3 looks like this: - gamerenderfixed() - Change drawframe depending on vx - gamerender() - gameinput() - If quick stopping, set vx to 0 - gamelogic() - Use drawframe for collision (my mind has become numb to pain) So, this means that all the player movement stuff is completely the same. Except their drawframe is going to be different. Unfortunately, I had overlooked that gameinput() sets vx and that animateentities() (in gamerenderfixed()) checks vx. Although, to be fair, it's a pretty dumb decision to make collision detection be based on the actual sprites' pixels themselves, instead of a hitbox, in the first place, so you'd expect THAT to be the end of the dumb parade. Or maybe you shouldn't, I don't know. So, what's the solution? What I've done here is added duplicates of framedelay, drawframe, and walkingframe, for collision use only. They get updated in gamelogic(), after gameinput(), which is after when vx could be set to 0. I've kept the original framedelay, drawframe, and walkingframe around, to keep the same visuals as closely as possible. However, due to the removal of the input delay, whenever you quick stop, your sprite will be wrong for just 1 frame - because when you let go of the direction key, the game will set your vx to 0 and the logical drawframe will update to reflect that, but the previous frame cannot know in advance that you'll release the key on the next frame, and so the visual drawframe will assume that you keep holding the key. Whereas in 2.2 and below, when you release a direction key, the player's position will only update to reflect that on the next frame, but the current frame can immediately recognize that and update the drawframe now, instead of retconning it later. Basically the visual drawframe assumes that you keep holding the key, and if you don't, then it takes on the value of the collision drawframe anyway, so it's okay. And it's only visual, anyway - the collision drawframe of the next frame (when you release the key) will be the same as the drawframe of the frame you release the key in 2.2 and below. But I really don't care to try and fix this for if you re-enable the input delay because it's minor and it'd be more complicated.
60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#ifndef ENT_H
|
|
#define ENT_H
|
|
|
|
#include <SDL.h>
|
|
|
|
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
|
|
|
class entclass
|
|
{
|
|
public:
|
|
entclass(void);
|
|
void clear(void);
|
|
|
|
bool outside(void);
|
|
|
|
void setenemy(int t);
|
|
|
|
void setenemyroom(int rx, int ry);
|
|
|
|
void settreadmillcolour(int rx, int ry);
|
|
|
|
void updatecolour(void);
|
|
|
|
bool ishumanoid(void);
|
|
|
|
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 collisionframedelay, collisiondrawframe, collisionwalkingframe;
|
|
int visualonground, visualonroof;
|
|
int yp;int xp;
|
|
|
|
Uint32 realcol;
|
|
int lerpoldxp, lerpoldyp;
|
|
};
|
|
|
|
#endif /* ENT_H */
|