Beginners_-_tilemap_minimum.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "raylib.h"
  2. int main(void)
  3. {
  4. // Initialization
  5. //--------------------------------------------------------------------------------------
  6. const int screenWidth = 800;
  7. const int screenHeight = 450;
  8. InitWindow(screenWidth, screenHeight, "raylib example.");
  9. int mymap[3][5] = { {1,1,1,1,1},
  10. {1,0,0,0,1},
  11. {1,1,1,1,1}
  12. };
  13. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  14. //--------------------------------------------------------------------------------------
  15. // Main game loop
  16. while (!WindowShouldClose()) // Detect window close button or ESC key
  17. {
  18. // Update
  19. //----------------------------------------------------------------------------------
  20. //----------------------------------------------------------------------------------
  21. // Draw
  22. //----------------------------------------------------------------------------------
  23. BeginDrawing();
  24. ClearBackground(RAYWHITE);
  25. for (int y = 0; y< 3 ; y++)
  26. {
  27. for (int x = 0; x< 5 ; x++)
  28. {
  29. if (mymap[y][x] == 1)
  30. {
  31. DrawRectangle(x*32,y*32,32,32,BLUE);
  32. }
  33. }
  34. }
  35. DrawText("Example of a minimal tilemap.", 100, 180, 40, LIGHTGRAY);
  36. EndDrawing();
  37. //----------------------------------------------------------------------------------
  38. }
  39. // De-Initialization
  40. //--------------------------------------------------------------------------------------
  41. CloseWindow(); // Close window and OpenGL context
  42. //--------------------------------------------------------------------------------------
  43. return 0;
  44. }