Advertisement
Guest User

muh code

a guest
Jul 20th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.31 KB | None | 0 0
  1. #![allow(unused)]
  2. use bevy::{prelude::*, sprite};
  3.  
  4. const MAINDUDE: &str = "Playersprite.png";
  5. const PLAYER_SIZE: (f32, f32) = (144., 74.);
  6.  
  7. fn main() {
  8.     App::new()
  9.         .insert_resource(ClearColor(Color::rgb(0.04,0.04,0.04)))
  10.         .insert_resource(WindowDescriptor {
  11.             title: "hehe".to_string(),
  12.             width: 598.0,
  13.             height: 676.0,
  14.             ..Default::default()
  15.      })
  16.      .add_plugins(DefaultPlugins)
  17.      .add_startup_system(setup_system)
  18.      .run();
  19.      }
  20.  
  21.      fn setup_system(
  22.         mut commands: Commands,
  23.         asset_server: Res<AssetServer>,
  24.         mut texture_atlases: ResMut<Assets<TextureAtlas>>,
  25.         mut windows: ResMut<Windows>,
  26.     ) {
  27.         commands.spawn_bundle(OrthographicCameraBundle::new_2d());
  28.  
  29.         let window = windows.get_primary_mut().unwrap();
  30.         let (win_w, win_y) = (window.width(),window.height());
  31.  
  32.         window.set_position(IVec2::new(2780, 4900));
  33.  
  34.         let bottom = -win_y / 2.;
  35.  
  36.         commands.spawn_bundle(SpriteBundle{
  37.              texture: asset_server.load(MAINDUDE),
  38.              transform: Transform{
  39.                 translation: Vec3::new(0., bottom + PLAYER_SIZE.1 / 2. +5., 10.),
  40.                 ..Default::default()
  41.              },
  42.              ..Default::default()
  43.         });
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement