#include "raylib.h" #include float direction(float x, float y); // Return the angle from - to in float float getangledeg(float x1,float y1,float x2,float y2); void createXtexture(); RenderTexture2D target; int tw = 640; int th = 480; int main(void) { // Initialization //-------------------------------------------------------------------------------------- const int screenWidth = 800; const int screenHeight = 600; //tw=screenWidth; //th=screenHeight; InitWindow(screenWidth, screenHeight, "raylib example."); //ToggleFullscreen(); createXtexture(); SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- int x1=200; int y1=200; int x2=0; int y2=0; float an=0; int val=0; // Main game loop while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- //an+=.01; //x2 = x1+cos(an)*64; //y2 = y1+sin(an)*64; //if(an>PI*2.0f)an=0; val++; if(val>200){ val=0; createXtexture(); } //---------------------------------------------------------------------------------- // Draw //---------------------------------------------------------------------------------- BeginDrawing(); ClearBackground(RAYWHITE); // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) //void DrawTexturePro(Texture2D texture, Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint); DrawTexturePro(target.texture, (Rectangle){ 0, 0,tw,-th }, (Rectangle){ 0,0,screenWidth,screenHeight}, (Vector2){ 0,0 },0, WHITE); //float n = direction(cos(an),sin(an));//getangledeg(x1,y1,x2,y2); //*(180/PI));//direction(0.0f,0.0f); //float n = direction(0,-1); //DrawText(FormatText("%f",n),10,10,20,RED); //DrawLine(x1,y1,x2,y2,RED); EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- UnloadRenderTexture(target); // Unload render texture CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- return 0; } void createXtexture(){ // A map array for getting the tiny spots on the canvas int map[tw][th]; for(int y=0;y=0 && y>=0 && x=0 && y>=0 && x0){ int nx=GetRandomValue(-1,1); int ny=GetRandomValue(-1,1); map[x+nx][y+ny]=map[x][y]; } } // add some light dots with shadow for(int i=0;i255)tc.r=255; if(tc.g>255)tc.g=255; if(tc.b>255)tc.b=255; DrawPixel(x,y,tc); } if(map[x][y]==1) DrawPixel(x,y,low); if(map[x][y]==2) DrawPixel(x,y,high); if(map[x][y]==3) DrawPixel(x,y,BLACK); }} // here we create the cracks!! for(int j=0;j