#include "raylib.h" #include int map[512][512]; int mapWidth = 128; int mapHeight = 128; int screenWidth; int screenHeight; float tileWidth; float tileHeight; void makerandommap(); int main(void) { // Initialization //-------------------------------------------------------------------------------------- screenWidth = 800; screenHeight = 450; tileWidth = ceil((float)screenWidth/(float)mapWidth); tileHeight = ceil((float)screenHeight/(float)mapHeight); InitWindow(screenWidth, screenHeight, "raylib example."); int d=GetRandomValue(-1,1); SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- int newmaptime=0; // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- newmaptime--; if(newmaptime<=0){ makerandommap(); newmaptime=60; } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(BLUE); for(int y=0;y0 && map[y][x]<50){ DrawRectangle(x*tileWidth,y*tileHeight,tileWidth,tileHeight,(Color){map[y][x]+150,150,0,255}); } if(map[y][x]>=50 && map[y][x]<200){ DrawRectangle(x*tileWidth,y*tileHeight,tileWidth,tileHeight,(Color){map[y][x],map[y][x],0,255}); } if(map[y][x]>=200){ DrawRectangle(x*tileWidth,y*tileHeight,tileWidth,tileHeight,(Color){map[y][x],map[y][x],map[y][x],255}); } }} EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } void makerandommap(){ for(int y=0;y=mapWidth-1)npx=mapWidth-1; if(npy>=mapHeight-1)npy=mapHeight-1; lastx = currentx; lasty = currenty; for(int cnt=0;cnt<6;cnt++){ for(int i=0;i=mapWidth-1)npx=mapWidth-1; if(npy>=mapHeight-1)npy=mapHeight-1; break; } } } pos++; path[pos] = (Vector2){npx,npy}; map[npy][npx]=1; px=npx; py=npy; } // Grow edges for(int i=0;i0){ int h=0; for(int y1=y-1;y10)h++; }} if(h>5 && map[y][x]<240)map[y][x]+=h; } } }