Beginners_-_Struct_in_Struct.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "raylib.h"
  2. struct inventory{
  3. bool pepper;
  4. bool salt;
  5. bool potion;
  6. };
  7. struct aiMushroom{
  8. int x;
  9. int y;
  10. int energy;
  11. struct inventory leftPocket;
  12. };
  13. static struct aiMushroom myaiMushroom = {10,20,99,{true,false,true}};
  14. int main(void)
  15. {
  16. // Initialization
  17. //--------------------------------------------------------------------------------------
  18. const int screenWidth = 800;
  19. const int screenHeight = 450;
  20. InitWindow(screenWidth, screenHeight, "raylib example.");
  21. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  22. //--------------------------------------------------------------------------------------
  23. // Main game loop
  24. while (!WindowShouldClose()) // Detect window close button or ESC key
  25. {
  26. // Update
  27. //----------------------------------------------------------------------------------
  28. //----------------------------------------------------------------------------------
  29. // Draw
  30. //----------------------------------------------------------------------------------
  31. BeginDrawing();
  32. ClearBackground(RAYWHITE);
  33. DrawText("The mushroom is here at :",100,180,20,BLACK);
  34. DrawText(FormatText("x: %i y: %i Energy : %i",myaiMushroom.x,myaiMushroom.y,myaiMushroom.energy),100,200,20,BLACK);
  35. if(myaiMushroom.leftPocket.pepper){
  36. DrawText("The mushroom has pepper in his left pocket..",100,220,20,BLACK);
  37. }else{
  38. DrawText("The mushroom has no pepper in his left pocket..",100,220,20,BLACK);
  39. }
  40. EndDrawing();
  41. //----------------------------------------------------------------------------------
  42. }
  43. // De-Initialization
  44. //--------------------------------------------------------------------------------------
  45. CloseWindow(); // Close window and OpenGL context
  46. //--------------------------------------------------------------------------------------
  47. return 0;
  48. }