Advertisement
janducev

Untitled

Nov 25th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. /*******************************************************************************************
  2. *
  3. * raylib [core] example - Basic window
  4. *
  5. * Welcome to raylib!
  6. *
  7. * To test examples, just press F6 and execute raylib_compile_execute script
  8. * Note that compiled executable is placed in the same folder as .c file
  9. *
  10. * You can find all basic examples on C:\raylib\raylib\examples folder or
  11. * raylib official webpage: www.raylib.com
  12. *
  13. * Enjoy using raylib. :)
  14. *
  15. * This example has been created using raylib 1.0 (www.raylib.com)
  16. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  17. *
  18. * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
  19. *
  20. ********************************************************************************************/
  21.  
  22. #include "raylib.h"
  23.  
  24. int main()
  25. {
  26. // Initialization
  27. //--------------------------------------------------------------------------------------
  28. int screenWidth = 800;
  29. int screenHeight = 450;
  30.  
  31. InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
  32.  
  33. Color recColor = RED;
  34.  
  35. Vector2 point1,point2,point3;
  36. point1.x = screenWidth/2;
  37. point1.y = screenHeight/2;
  38.  
  39. point2.x = screenWidth/2 - 60;
  40. point2.y = screenHeight/2 +50;
  41.  
  42. point3.x = screenWidth/2 + 60;
  43. point3.y = screenHeight/2 +50;
  44.  
  45.  
  46. bool fadeOut = true;
  47. float alpha = 0;
  48. float fadeSpeed = 0.01f;
  49.  
  50. SetTargetFPS(60);
  51. //--------------------------------------------------------------------------------------
  52.  
  53. // Main game loop
  54. while (!WindowShouldClose()) // Detect window close button or ESC key
  55. {
  56. // Update
  57. //----------------------------------------------------------------------------------
  58. // TODO: Update your variables here
  59. if(fadeOut)
  60. {
  61. alpha += fadeSpeed;
  62.  
  63. if(alpha >= 1.0f)
  64. {
  65. alpha = 1.0f;
  66. fadeOut = !fadeOut;
  67. }
  68. }
  69. else
  70. {
  71. alpha -= fadeSpeed;
  72. if(alpha <= 0.0f)
  73. {
  74. alpha = 0.0f;
  75. fadeOut = !fadeOut;
  76. }
  77. }
  78.  
  79. if(IsKeyPressed(KEY_SPACE))
  80. {
  81. fadeOut = !fadeOut;
  82. }
  83. //----------------------------------------------------------------------------------
  84.  
  85. // Draw
  86. //----------------------------------------------------------------------------------
  87. BeginDrawing();
  88.  
  89. ClearBackground(RAYWHITE);
  90.  
  91. DrawTriangle(point1, point2, point3, Fade(RED, alpha));
  92.  
  93. DrawText(FormatText("%f", alpha), 10,10, 20, WHITE);
  94.  
  95.  
  96. EndDrawing();
  97. //----------------------------------------------------------------------------------
  98. }
  99.  
  100. // De-Initialization
  101. //--------------------------------------------------------------------------------------
  102. CloseWindow(); // Close window and OpenGL context
  103. //--------------------------------------------------------------------------------------
  104.  
  105. return 0;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement