Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = "0.14.2"
bevy = "0.15"
fastrand = "2.1.1" # ref: https://github.com/bevyengine/bevy/pull/3992

[workspace]
Expand Down
4 changes: 2 additions & 2 deletions src/game/actor/bullet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl AiBulletBundle for StandardBullet {
speed: Vec2::new(10.0, 10.0),
},
scene_bundle: StarRustSceneBundle {
scene: models.default_bullet.clone(),
scene: SceneRoot(models.default_bullet.clone()),
transform: Transform::from_xyz(
weapon_data.translation.x,
weapon_data.translation.y,
Expand Down Expand Up @@ -80,7 +80,7 @@ impl AiBulletBundle for StandardEnemyBullet {
weapon_data: &WeaponFiredEvent,
) -> BulletActorBundle {
let mut bullet = StandardBullet::get_bullet_bundle(models, weapon_data).clone();
bullet.scene_bundle.scene = models.default_enemy_bullet.clone();
bullet.scene_bundle.scene = SceneRoot(models.default_enemy_bullet.clone());
return bullet;
}
}
2 changes: 1 addition & 1 deletion src/game/actor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait BundledActor<T: Bundle> {

#[derive(Bundle, Clone, Default)]
pub struct StarRustSceneBundle {
pub scene: Handle<Scene>,
pub scene: SceneRoot,
pub transform: Transform,
pub global_transform: GlobalTransform,
pub visibility: Visibility,
Expand Down
10 changes: 5 additions & 5 deletions src/game/actor/ship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl BundledActor<PlayerActorBundle> for PlayerShipDefault {
speed: Vec2::new(6.0, 6.0),
},
scene_bundle: StarRustSceneBundle {
scene: models.default_player.clone(),
scene: SceneRoot(models.default_player.clone()),
transform: Transform::from_xyz(spawn_position.x, spawn_position.y, 2.0)
.with_scale(Vec3::splat(ASSET_SCALE))
.with_rotation(Quat::from_rotation_y(std::f32::consts::PI * 1.5)),
Expand Down Expand Up @@ -76,7 +76,7 @@ impl BundledActor<AiActorBundle> for DefaultEnemyShip {
speed: Vec2::new(1.5, 1.5),
},
scene_bundle: StarRustSceneBundle {
scene: models.default_enemy.clone(),
scene: SceneRoot(models.default_enemy.clone()),
transform: Transform::from_xyz(spawn_position.x, spawn_position.y, 2.0)
.with_scale(Vec3::splat(23.0))
.with_rotation(Quat::from_rotation_y(std::f32::consts::PI * 0.5)),
Expand Down Expand Up @@ -131,7 +131,7 @@ impl BundledActor<AiActorBundle> for JetCharger {
spawn_position: Vec2,
) -> AiActorBundle {
let mut variant = DefaultEnemyShip::get_bundle(audio_clips, models, spawn_position).clone();
variant.actor_bundle.scene_bundle.scene = models.jet_charger.clone();
variant.actor_bundle.scene_bundle.scene = SceneRoot(models.jet_charger.clone());
variant.actor_bundle.actor.speed = Vec2::new(8.0, 8.0);
variant.ai.mode = AiMode::ChargeForward1;
// Disable Weapon
Expand Down Expand Up @@ -159,7 +159,7 @@ impl BundledActor<AiActorBundle> for SpacePlatformBare {
spawn_position: Vec2,
) -> AiActorBundle {
let mut variant = DefaultEnemyShip::get_bundle(audio_clips, models, spawn_position).clone();
variant.actor_bundle.scene_bundle.scene = models.space_platform.clone();
variant.actor_bundle.scene_bundle.scene = SceneRoot(models.space_platform.clone());
variant.actor_bundle.actor.speed = Vec2::new(2.0, 2.0);
variant.actor_bundle.health.hp = 100;
variant.actor_bundle.collider.rect = Vec2::new(210.0, 40.0);
Expand Down Expand Up @@ -190,7 +190,7 @@ impl BundledActor<AiActorBundle> for Star {
) -> AiActorBundle {
let mut variant = DefaultEnemyShip::get_bundle(audio_clips, models, spawn_position).clone();
variant.actor_bundle.camera_shake_on_death.magnitude = 0.0;
variant.actor_bundle.scene_bundle.scene = models.powerup_star.clone();
variant.actor_bundle.scene_bundle.scene = SceneRoot(models.powerup_star.clone());
// FIXME: Make a dedicated hitmask for player bullets and powerups
variant.actor_bundle.collider.hitmask = ENEMY_HITMASK;
variant.actor_bundle.collider.damage = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/game/ai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ fn sine_charge(
frequency: f32,
) {
let forward = t.translation + t.forward() * forward_speed;
let up_down = t.up() * amplitude * (time.elapsed_seconds() as f32 * frequency).sin();
let up_down = t.up() * amplitude * (time.elapsed_secs() * frequency).sin();
t.translation = forward + up_down;
}
8 changes: 1 addition & 7 deletions src/game/audio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ fn on_audio_event(mut commands: Commands, mut audio_events: EventReader<AudioEve
}

for event in audio_events.read() {
commands.spawn(AudioBundle {
source: event.clip.clone(),
settings: PlaybackSettings {
mode: PlaybackMode::Once,
..default()
},
});
commands.spawn((AudioPlayer(event.clip.clone()), PlaybackSettings::DESPAWN));
}
}
9 changes: 4 additions & 5 deletions src/game/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ pub fn setup_lights(mut commands: Commands) {
});*/

// Directional Light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
commands.spawn((
DirectionalLight {
illuminance: 25000.0,
color: Color::WHITE,
..default()
},
transform: Transform::from_xyz(0.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
Transform::from_xyz(0.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

pub fn setup_starfield(commands: Commands) {}
35 changes: 12 additions & 23 deletions src/game/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,21 @@ fn setup_scoreboard(
) {
scoreboard.score = 0;
commands
.spawn(
TextBundle::from_sections([
TextSection::new(
"SCORE: ",
TextStyle {
font: asset_server.load("fonts/Arame-Bold.ttf"),
font_size: SCOREBOARD_FONT_SIZE,
color: UI_COLOR,
},
),
TextSection::new(
"0",
TextStyle {
font: asset_server.load("fonts/Arame-Bold.ttf"),
font_size: SCOREBOARD_FONT_SIZE,
color: UI_COLOR,
},
),
])
.with_style(Style {
.spawn((
Text::new("SCORE: 0"),
TextFont {
font: asset_server.load("fonts/Arame-Bold.ttf"),
font_size: SCOREBOARD_FONT_SIZE,
..default()
},
TextColor(UI_COLOR),
Node {
position_type: PositionType::Absolute,
top: Val::Px(SCOREBOARD_TEXT_PADDING),
left: Val::Px(SCREEN_WIDTH * 0.10),
..default()
}),
)
},
))
.insert(PlayerScoreBoard);
}

Expand All @@ -65,7 +54,7 @@ fn on_score_event(
for score_event in score_events.read() {
scoreboard.score += score_event.increment;
let mut player_score_text = text_query.single_mut();
player_score_text.sections[1].value = scoreboard.score.to_string();
**player_score_text = format!("SCORE: {}", scoreboard.score);
}
score_events.clear(); // Clear buffer to prevent double registration of scoring events (???)
}
42 changes: 11 additions & 31 deletions src/game/walls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ fn setup_walls(
// This bundle is a collection of the components that define a "wall" in our game
#[derive(Bundle)]
struct WallBundle {
// You can nest bundles inside of other bundles like this
// Allowing you to compose their functionality
//#[bundle]
//sprite_bundle: SpriteBundle,
pbr_bundle: PbrBundle,
mesh: Mesh3d,
material: MeshMaterial3d<StandardMaterial>,
transform: Transform,
collider: Collider,
wall: Wall,
}
Expand All @@ -62,33 +60,15 @@ impl WallBundle {
materials: &mut ResMut<Assets<StandardMaterial>>,
) -> WallBundle {
WallBundle {
/*
sprite_bundle: SpriteBundle {
transform: Transform {
// We need to convert our Vec2 into a Vec3, by giving it a z-coordinate
// This is used to determine the order of our sprites
translation: location.position().extend(0.0),
// The z-scale of 2D objects must always be 1.0,
// or their ordering will be affected in surprising ways.
// See https://github.com/bevyengine/bevy/issues/4149
scale: location.size().extend(1.0),
..default()
},
sprite: Sprite {
color: WALL_COLOR,
..default()
},
mesh: Mesh3d(meshes.add(Mesh::from(Cuboid {
half_size: Vec3::new(0.5, 0.5, 0.5),
}))),
material: MeshMaterial3d(materials.add(StandardMaterial {
base_color: WALL_COLOR,
..default()
},*/
pbr_bundle: PbrBundle {
mesh: meshes.add(Mesh::from(Cuboid {
half_size: Vec3::new(0.5, 0.5, 0.5),
})),
material: materials.add(WALL_COLOR),
transform: Transform::from_translation(location.position().extend(1.0))
.with_scale(location.size().extend(1.0)),
..default()
},
})),
transform: Transform::from_translation(location.position().extend(1.0))
.with_scale(location.size().extend(1.0)),
collider: Collider {
rect: location.size(),
damage: 0,
Expand Down
17 changes: 8 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ fn setup_camera(mut commands: Commands) {
); // FIXME: this does not render at all*/
// Bevy 2d camera is at Z=999.9
commands
.spawn(Camera3dBundle {
camera_3d: Camera3d { ..default() },
camera: Camera {
.spawn((
Camera3d::default(),
Camera {
order: 0,
..default()
},
projection: Projection::Orthographic(OrthographicProjection {
Projection::from(OrthographicProjection {
scale: 1.0,
..default()
far: CAMERA_FAR,
..OrthographicProjection::default_3d()
}),
transform: Transform::from_xyz(0.0, 0.0, CAMERA_FAR - 0.1)
.looking_at(Vec3::ZERO, Vec3::Y),
..default()
})
Transform::from_xyz(0.0, 0.0, CAMERA_FAR - 0.1).looking_at(Vec3::ZERO, Vec3::Y),
))
.insert(CameraShaker { ..default() });
}
Loading
Loading