Skip to content

Instantly share code, notes, and snippets.

@satinxs

satinxs/bleed.c

Created Mar 5, 2020
Embed
What would you like to do?
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