Skip to content
Snippets Groups Projects
Verified Commit 98046acd authored by Louis's avatar Louis :fire:
Browse files

Include assets, spawn ship in centre

parent 00ba6b7d
No related branches found
No related tags found
No related merge requests found
Showing with 64 additions and 2 deletions
*.png filter=lfs diff=lfs merge=lfs -text
*.ogg filter=lfs diff=lfs merge=lfs -text
File added
File added
File added
File added
File added
File added
File added
File added
File added
assets/sprites/alien_boss.png

130 B

assets/sprites/alien_mini_boss.png

130 B

assets/sprites/alien_ship.png

129 B

assets/sprites/background.png

131 B

assets/sprites/powerup.png

129 B

assets/sprites/ship.png

129 B

use bevy::asset::AssetServer;
use bevy::core_pipeline::clear_color::ClearColorConfig; use bevy::core_pipeline::clear_color::ClearColorConfig;
use bevy::math::Vec3; use bevy::math::Vec3;
use bevy::prelude::{ use bevy::prelude::{
App, Camera2d, Camera2dBundle, Color, Commands, OrthographicProjection, PluginGroup, Rect, App, Camera2d, Camera2dBundle, Color, Commands, OrthographicProjection, PluginGroup, Rect, Res,
Transform, Vec2, Window, WindowPlugin, Transform, Vec2, Window, WindowPlugin,
}; };
use bevy::render::camera::ScalingMode; use bevy::render::camera::ScalingMode;
use bevy::sprite::SpriteBundle;
use bevy::window::{WindowMode, WindowResolution}; use bevy::window::{WindowMode, WindowResolution};
use bevy::DefaultPlugins; use bevy::DefaultPlugins;
static VIEWPORT_WIDTH: f32 = 480.0; static VIEWPORT_WIDTH: f32 = 680.0;
static VIEWPORT_HEIGHT: f32 = 300.0; static VIEWPORT_HEIGHT: f32 = 300.0;
fn spawn_camera(mut commands: Commands) { fn spawn_camera(mut commands: Commands) {
...@@ -30,6 +32,18 @@ fn spawn_camera(mut commands: Commands) { ...@@ -30,6 +32,18 @@ fn spawn_camera(mut commands: Commands) {
}); });
} }
fn spawn_ship(mut commands: Commands, assets: Res<AssetServer>) {
commands.spawn(SpriteBundle {
texture: assets.load("sprites/ship.png"),
transform: Transform::from_translation(Vec3::new(
VIEWPORT_WIDTH / 2.0,
VIEWPORT_HEIGHT / 2.0,
0.0,
)),
..Default::default()
});
}
fn main() { fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin { .add_plugins(DefaultPlugins.set(WindowPlugin {
...@@ -44,5 +58,6 @@ fn main() { ...@@ -44,5 +58,6 @@ fn main() {
..Default::default() ..Default::default()
})) }))
.add_startup_system(spawn_camera) .add_startup_system(spawn_camera)
.add_startup_system(spawn_ship)
.run(); .run();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment