mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Fix, for in-GAMEMODE sprites, their colors updating too fast
Okay, so the problem here is that Graphics::setcol() is called right before a sprite is drawn in a render function, but render functions are done in deltatime, meaning that the color of a sprite keeps being recalculated every time. This only affects sprites that use fRandom() (the other thing that can dynamically determine a color is help.glow, but that's only updated in the fixed-timestep loop), but is especially noticeable for sprites that flash wildly, like the teleporter, trinket, and elephant. To fix this, we need to make the color be recalculated only in the fixed-timestep loop. However, this means that we MUST store the color of the sprite SOMEWHERE for the delta-timesteps to render it, otherwise the color calculation will just be lost or something. So each entity now has a new attribute, `realcol`, which is the actual raw color used to render the sprite in render functions. This is not to be confused with their `colour` attribute, which is more akin to a color "ID" of sorts, but which isn't an actual color. At the end of gamelogic(), as well as when an entity is first created, the `colour` is given to Graphics::setcol() and then `realcol` gets set to the actual color. Then when it comes time to render the entity, `realcol` gets used instead. Gravitron squares are a somewhat tricky case where there's technically TWO colors for it - one is the actual sprite itself and the other is the indicator. However, usually the indicator and the square aren't both onscreen at the same time, so we can simply switch the realcol between the two as needed. However, we can't use this system for the sprite colors used on the title and map screen, so we'll have to do something else for those.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#ifndef ENT_H
|
||||
#define ENT_H
|
||||
|
||||
#include "Graphics.h"
|
||||
|
||||
#define rn( rx, ry) ((rx) + ((ry) * 100))
|
||||
|
||||
class entclass
|
||||
@@ -16,6 +18,8 @@ public:
|
||||
|
||||
void settreadmillcolour(int rx, int ry);
|
||||
|
||||
void updatecolour();
|
||||
|
||||
public:
|
||||
//Fundamentals
|
||||
bool invis;
|
||||
@@ -45,6 +49,8 @@ public:
|
||||
//Animation
|
||||
int framedelay, drawframe, walkingframe, dir, actionframe;
|
||||
int yp;int xp;
|
||||
|
||||
Uint32 realcol;
|
||||
};
|
||||
|
||||
#endif /* ENT_H */
|
||||
|
||||
Reference in New Issue
Block a user