Created
March 5, 2020 15:11
-
-
Save satinxs/e55461da74ba378a09d813cb6767ffae to your computer and use it in GitHub Desktop.
bleed bug when drawing rectangles with RayLib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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