[尝试在RayLib 2.6中绘制矩形时,我发现这种“出血”效果:bleeding effect
我试图搜索这种效果(我称之为出血),但是我没有找到正确的名称。
我设法在this最小代码示例中重现了它:
#include <raylib.h>
#define MAP_SIZE 64
#define TILE_SIZE 8
static int map[MAP_SIZE][MAP_SIZE];
static Color mappedColor[] = {
{255, 0, 0, 255},
{0, 255, 0, 255},
{0, 0, 255, 255},
};
#define GetMapColor(c) mappedColor[c]
void Render(float dt)
{
ClearBackground(BLACK);
for (int x = 0; x < MAP_SIZE; x++)
for (int y = 0; y < MAP_SIZE; y++)
DrawRectangle(x * TILE_SIZE, y * TILE_SIZE, (x + 1) * TILE_SIZE, (y + 1) * TILE_SIZE, GetMapColor(map[x][y]));
}
void CreateMap()
{
for (int x = 0; x < MAP_SIZE; x++)
for (int y = 0; y < MAP_SIZE; y++)
map[x][y] = GetRandomValue(0, 3);
}
int main(int argc, char **argv)
{
InitWindow(800, 600, "Bleeding");
SetTargetFPS(60);
CreateMap();
while (!WindowShouldClose())
{
float dt = GetFrameTime();
BeginDrawing();
Render(dt);
EndDrawing();
}
CloseWindow();
return 0;
}
谢谢!
这是因为DrawRectangle
函数采用的参数与该代码可能期望的参数不同。