1
use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .insert_resource(WindowDescriptor{
            width: 140.0,
            height:140.0,
            title: "Game of Life".to_string(),
            ..Default::default()
        })
        .run();
}

I don't know why this isn't working and its showing the following compile-error

error[E0277]: the trait bound `bevy::prelude::WindowDescriptor: Resource` is not satisfied                                                                                             
   --> src\main.rs:7:26
    |
7   |           .insert_resource(WindowDescriptor{
    |  __________---------------_^
    | |          |
    | |          required by a bound introduced by this call
8   | |             width: 140.0,
9   | |             height:140.0,
10  | |             title: "Game of Life".to_string(),
11  | |             ..Default::default()
12  | |         })
    | |_________^ the trait `Resource` is not implemented for `bevy::prelude::WindowDescriptor`

I was following this video and it works just fine in the video

I am learning how to use bevy game engine but when i pass windowdesciptor as an argument to the add_resource function and it shows me error

  • That video is outdated, you can either try with that old version of bevy, I think it's around 0.6 or 0.5 or just find an up to date tutorial instead. – cafce25 Dec 23 '22 at 11:53

2 Answers2

5

Since bevy 0.9

The WindowDescriptor settings have been moved from a resource to WindowPlugin::window

So your code should be:

use bevy::prelude::*;

fn main() {
  App::new()
    .add_plugins(DefaultPlugins.set(WindowPlugin {
      window: WindowDescriptor { 
        width: 140.0,
        height:140.0,
        title: "Game of Life".to_string(),
        ..default()
      },
      ..default()
    }))
    .run();
}
Bruhloon
  • 110
  • 7
4

With bevy 0.10 they've changed some things again, so although this is an older post Ill leave an updated answer.

Code now should be:

use bevy::prelude::*;

fn main() {
  App::new()
    .add_plugins(WindowPlugin {
      primary_window: Some(Window {
        resolution: (140.0, 140.0).into(),
        title: "Game of Life".to_string(),
        ..default()
      }),
      ..default()
    })
    .run();
}
Maou Shimazu
  • 61
  • 1
  • 2