1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
use avian2d::prelude::{Collider, Mass, RigidBody};
use bevy::{color::Color, core_pipeline::core_2d::Camera2d, ecs::system::Commands, math::Vec2, sprite::Sprite, text::{Text2d, Text2dBundle}, transform::components::Transform};
use crate::StartPlanet;
pub fn setup_starting_planet(mut cmd: Commands) {
let start_planet = StartPlanet {
display_name: String::from("Earth 2"),
planet_mass_kg: 15000.0,
radius: 50.0,
};
let collider_radius = (&start_planet).radius;
let planet_mass_kg = (&start_planet).planet_mass_kg;
cmd.spawn((
start_planet,
RigidBody::Static,
Transform::from_xyz(0.0, 0.0, 0.0),
Sprite::from_color(Color::WHITE, Vec2 { x: 50.0, y: 50.0 }),
Collider::rectangle(collider_radius, collider_radius),
Mass(planet_mass_kg),
));
}
pub fn setup_init(mut commands: Commands) {
commands.spawn(Camera2d);
commands.spawn((Text2d::new("Game - if you call it one. W A S D to move.\nLeave your planet to land on the moon,\nbut be careful of gravity pulling you."), Transform::from_xyz(0., 70., 1.)));
println!("Setup initial things");
}
|