Compare commits

..

3 Commits

Author SHA1 Message Date
Mark 18c0fafc5a
Updated TODO 2024-01-09 14:15:23 -08:00
Mark 52f1b26d25
Starfield parallax tweak 2024-01-09 14:14:50 -08:00
Mark 94bd26b49e
Repaired engine flares 2024-01-09 14:13:16 -08:00
6 changed files with 39 additions and 24 deletions

View File

@ -16,10 +16,8 @@
- GPU limits? (texture size, texture number, particle/sprite limits)
- Particles when a ship is damaged (events)
- Sticky radar
- Clean up world and objects
- Fix gun points
- Arbitrary size resource names
- How does a player control a ship (also fix behaviors)
----------------------------------

View File

@ -10,7 +10,7 @@ pub const ZOOM_MAX: f32 = 2000.0;
/// Z-axis range for starfield stars
/// This does not affect scale.
pub const STARFIELD_Z_MIN: f32 = 100.0;
pub const STARFIELD_Z_MIN: f32 = 75.0;
/// Z-axis range for starfield stars
/// This does not affect scale.
pub const STARFIELD_Z_MAX: f32 = 200.0;

View File

@ -45,10 +45,7 @@ impl Game {
//o1.add_gun(&ct, content::GunHandle { index: 0 });
//o1.add_gun(&ct, content::GunHandle { index: 0 });
let mut o1 = OutfitSet::new(ss.space, &[]);
o1.add(&ct.get_outfit(content::OutfitHandle { index: 0 }));
//o1.add_gun(&ct, content::GunHandle { index: 0 });
print!("{:?}", o1);
let player = gamedata.create_ship(
&ct,
content::ShipHandle { index: 0 },
@ -67,6 +64,10 @@ impl Game {
&content::SystemHandle { index: 0 },
);
let mut o1 = OutfitSet::new(ss.space, &[]);
o1.add(&ct.get_outfit(content::OutfitHandle { index: 0 }));
//o1.add_gun(&ct, content::GunHandle { index: 0 });
gamedata.create_ship(
&ct,
content::ShipHandle { index: 0 },

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use content::{GunPoint, OutfitHandle, OutfitSpace};
use content::{GunPoint, OutfitHandle, OutfitSpace, SpriteHandle};
use galactica_content as content;
/// Possible outcomes when adding an outfit
@ -98,6 +98,12 @@ impl OutfitSet {
generation: o.shield_generation,
});
if self.outfits.contains_key(&o.handle) {
*self.outfits.get_mut(&o.handle).unwrap() += 1;
} else {
self.outfits.insert(o.handle, 1);
}
return OutfitAddResult::Ok;
}
@ -131,6 +137,17 @@ impl OutfitSet {
return OutfitRemoveResult::Ok;
}
// TODO: pick these better
pub fn get_flare_sprite(&self, ct: &content::Content) -> Option<SpriteHandle> {
for i in self.outfits.keys() {
let c = ct.get_outfit(*i);
if c.engine_flare_sprite.is_some() {
return c.engine_flare_sprite;
}
}
return None;
}
}
// Simple getters to make sure nobody meddles with our internal state

View File

@ -22,7 +22,7 @@ impl GPUState {
s: &ShipWorldObject,
) {
let r = state.world.get_rigid_body(s.rigid_body).unwrap();
let ship = state.data.get_ship(s.data_handle);
let ship = state.data.get_ship(s.data_handle).unwrap();
let ship_pos = util::rigidbody_position(&r);
let ship_rot = util::rigidbody_rotation(r);
let ship_ang = -ship_rot.angle(Vector2 { x: 0.0, y: 1.0 }); // TODO: inconsistent angles. Fix!
@ -85,25 +85,18 @@ impl GPUState {
);
self.vertex_buffers.object_counter += 1;
/*
// Draw engine flares if necessary
//if s.controls.thrust && !s.ship.is_dead() {
if s.controls.thrust {
for f in s.ship.outfits.iter_enginepoints() {
let flare = match s.ship.outfits.get_flare_sprite() {
None => continue,
Some(s) => s,
};
let flare = ship.get_outfits().get_flare_sprite(state.content);
if s.get_controls().thrust && flare.is_some() && !ship.is_dead() {
for engine_point in &ship_cnt.engines {
self.queue.write_buffer(
&self.global_uniform.object_buffer,
ObjectData::SIZE * self.vertex_buffers.object_counter as u64,
bytemuck::cast_slice(&[ObjectData {
xpos: f.pos.x,
ypos: f.pos.y - f.size / 2.0,
xpos: engine_point.pos.x,
ypos: engine_point.pos.y - engine_point.size / 2.0,
zpos: 1.0,
angle: 0.0,
size: f.size,
size: engine_point.size,
parent: idx as u32,
is_child: 1,
_padding: Default::default(),
@ -122,14 +115,13 @@ impl GPUState {
&self.vertex_buffers.object.instances,
ObjectInstance::SIZE * self.vertex_buffers.object_counter,
bytemuck::cast_slice(&[ObjectInstance {
sprite_index: flare.get_index(),
sprite_index: flare.unwrap().get_index(),
object_index: self.vertex_buffers.object_counter as u32,
}]),
);
self.vertex_buffers.object_counter += 1;
}
}
*/
}
pub(super) fn world_push_projectile(

View File

@ -304,3 +304,10 @@ impl ShipWorldObject {
//}
}
}
impl ShipWorldObject {
/// Get this ship's control state
pub fn get_controls(&self) -> &ShipControls {
&self.controls
}
}