1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00
VVVVVV/desktop_version/src/Ent.h
Misa 351a022ebd Use SDL_Color for colors instead of colourTransform
colourTransform is a struct with only one member, a Uint32. The issue
with `Uint32`s is that it requires a bunch of bit shifting logic to edit
the colors. The issue with bit shifting logic is that people have a
tendency to hardcode the shift amounts instead of using the shift amount
variables of the SDL_PixelFormat, which makes it annoying to change the
color masks of surfaces.

This commit fixes both issues by unhardcoding the bit shift amounts in
DrawPixel and ReadPixel, and by axing the `Uint32`s in favor of using
SDL_Color.

According to the SDL_PixelFormat documentation (
https://wiki.libsdl.org/SDL2/SDL_PixelFormat ), the logic to read and
draw to pixels from colors below 32-bit was just wrong. Specifically,
for 8-bit, there's a color palette used instead of some intrinsic color
information stored in the pixel itself. But we shouldn't need that logic
anyways because we don't use colors below 32-bit. So I axed that too.
2023-01-01 16:36:43 -08:00

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;
SDL_Color realcol;
int lerpoldxp, lerpoldyp;
};
#endif /* ENT_H */