Macroquad cannot find "prelude"

use macroquad::prelude::*;

#[macroquad::main("BasicShapes")]
async fn main()
{
    loop
    {
        clear_background(RED);
 
        draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
        draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
        draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
        draw_text("HELLO", 20.0, 20.0, 20.0, DARKGRAY);
 
        next_frame().await
    }
}

Just having a bit of issue compiling this,

   Compiling local v0.1.0 (C:\Users\joe\Desktop\Programming\Rust\local)
error[E0432]: unresolved import `macroquad::prelude`
 --> src\main.rs:1:16
  |
1 | use macroquad::prelude::*;
  |                ^^^^^^^ could not find `prelude` in `macroquad`

error[E0425]: cannot find function `clear_background` in this scope
 --> src\main.rs:8:9
  |
8 |         clear_background(RED);
  |         ^^^^^^^^^^^^^^^^ not found in this scope
  |
help: consider importing this function
  |
1 | use macroquad::clear_background;
  |

error[E0425]: cannot find value `RED` in this scope
 --> src\main.rs:8:26
  |
8 |         clear_background(RED);
  |                          ^^^ not found in this scope
  |
help: consider importing this constant
  |
1 | use macroquad::RED;
  |

error[E0425]: cannot find function `draw_line` in this scope
  --> src\main.rs:10:9
   |
10 |         draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
   |         ^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::draw_line;
   |

error[E0425]: cannot find value `BLUE` in this scope
  --> src\main.rs:10:51
   |
10 |         draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
   |                                                   ^^^^ not found in this scope
   |
help: consider importing this constant
   |
1  | use macroquad::BLUE;
   |

error[E0425]: cannot find function `draw_rectangle` in this scope
  --> src\main.rs:11:9
   |
11 |         draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
   |         ^^^^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::draw_rectangle;
   |

error[E0425]: cannot find function `screen_width` in this scope
  --> src\main.rs:11:24
   |
11 |         draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
   |                        ^^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::screen_width;
   |

error[E0425]: cannot find value `GREEN` in this scope
  --> src\main.rs:11:73
   |
11 |         draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
   |                                                                         ^^^^^ not found in this scope
   |
help: consider importing this constant
   |
1  | use macroquad::GREEN;
   |

error[E0425]: cannot find function `draw_circle` in this scope
  --> src\main.rs:12:9
   |
12 |         draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
   |         ^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::draw_circle;
   |

error[E0425]: cannot find function `screen_width` in this scope
  --> src\main.rs:12:21
   |
12 |         draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
   |                     ^^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::screen_width;
   |

error[E0425]: cannot find function `screen_height` in this scope
  --> src\main.rs:12:44
   |
12 |         draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
   |                                            ^^^^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::screen_height;
   |

error[E0425]: cannot find value `YELLOW` in this scope
  --> src\main.rs:12:74
   |
12 |         draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
   |                                                                          ^^^^^^ not found in this scope
   |
help: consider importing this constant
   |
1  | use macroquad::YELLOW;
   |

error[E0425]: cannot find function `draw_text` in this scope
  --> src\main.rs:13:9
   |
13 |         draw_text("HELLO", 20.0, 20.0, 20.0, DARKGRAY);
   |         ^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::draw_text;
   |

error[E0425]: cannot find value `DARKGRAY` in this scope
  --> src\main.rs:13:46
   |
13 |         draw_text("HELLO", 20.0, 20.0, 20.0, DARKGRAY);
   |                                              ^^^^^^^^ not found in this scope
   |
help: consider importing this constant
   |
1  | use macroquad::DARKGRAY;
   |

error[E0425]: cannot find function `next_frame` in this scope
  --> src\main.rs:15:9
   |
15 |         next_frame().await
   |         ^^^^^^^^^^ not found in this scope
   |
help: consider importing this function
   |
1  | use macroquad::next_frame;
   |

error: aborting due to 15 previous errors

Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `local`.

To learn more, run the command again with --verbose.

In my cargo.toml file I have this:

[dependencies]
macroquad = "0.2.9"

So I am not too sure what is going on or why this is happening?

I don’t quite know why you would expect there to be a prelude modules in macroquad. At least in the docs there is no mention of such a thing. If you want to *-import everything on top-level, you could do use macroquad::*;.

1 Like

Oh, my bad