Skip to content

Instantly share code, notes, and snippets.

@satinxs
Created March 5, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satinxs/e55461da74ba378a09d813cb6767ffae to your computer and use it in GitHub Desktop.
Save satinxs/e55461da74ba378a09d813cb6767ffae to your computer and use it in GitHub Desktop.
bleed bug when drawing rectangles with RayLib
#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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment