Compare commits

..

No commits in common. "10e1ef8107ed0f9bc53c66dac171d84f7a1d98ec" and "fdce0a7d3b03ded25b997f6a0273626ee915b58e" have entirely different histories.

9 changed files with 11 additions and 30 deletions

2
assets

@ -1 +1 @@
Subproject commit 7b00da4f1971908d389d906fe537bfecd3d03b50 Subproject commit 45f65b6a639f3e59d9d1db2a4cf452fe406bd4b2

View File

@ -4,8 +4,8 @@ name = "12 Autumn above"
[object.star] [object.star]
sprite = "star::star" sprite = "star::star"
position = [0.0, 0.0, 30.0] position = [0.0, 0.0, 20.0]
size = 2000 size = 1000
[object.earth] [object.earth]

View File

@ -11,8 +11,6 @@ pub struct Game {
pub player: Ship, pub player: Ship,
pub system: System, pub system: System,
pub camera: Camera, pub camera: Camera,
paused: bool,
pub time_scale: f32,
} }
impl Game { impl Game {
@ -26,8 +24,6 @@ impl Game {
zoom: 500.0, zoom: 500.0,
}, },
system: System::new(&ct.systems[0]), system: System::new(&ct.systems[0]),
paused: false,
time_scale: 1.0,
} }
} }
@ -43,17 +39,8 @@ impl Game {
self.input.process_scroll(delta, phase) self.input.process_scroll(delta, phase)
} }
pub fn set_paused(&mut self, pause: bool) {
if pause {
self.paused = true;
self.input.release_all()
} else {
self.paused = false;
}
}
pub fn update(&mut self) { pub fn update(&mut self) {
let t: f32 = self.last_update.elapsed().as_secs_f32() * self.time_scale; let t: f32 = self.last_update.elapsed().as_secs_f32();
if self.input.key_thrust { if self.input.key_thrust {
self.player.physicsbody.thrust(50.0 * t); self.player.physicsbody.thrust(50.0 * t);

View File

@ -19,12 +19,6 @@ impl InputStatus {
} }
} }
pub fn release_all(&mut self) {
self.key_left = false;
self.key_right = false;
self.key_thrust = false;
}
pub fn process_key(&mut self, state: &ElementState, key: &VirtualKeyCode) { pub fn process_key(&mut self, state: &ElementState, key: &VirtualKeyCode) {
let down = state == &ElementState::Pressed; let down = state == &ElementState::Pressed;
match key { match key {

View File

@ -30,6 +30,7 @@ async fn run(mut game: game::Game) -> Result<()> {
event_loop.run(move |event, _, control_flow| { event_loop.run(move |event, _, control_flow| {
match event { match event {
Event::RedrawRequested(window_id) if window_id == gpu.window().id() => { Event::RedrawRequested(window_id) if window_id == gpu.window().id() => {
gpu.update();
game.update(); game.update();
match gpu.render(&game) { match gpu.render(&game) {
Ok(_) => {} Ok(_) => {}
@ -53,9 +54,6 @@ async fn run(mut game: game::Game) -> Result<()> {
window_id, window_id,
} if window_id == gpu.window.id() => { } if window_id == gpu.window.id() => {
match event { match event {
WindowEvent::Focused(state) => {
game.set_paused(!state);
}
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: input:

View File

@ -194,6 +194,8 @@ impl GPUState {
self.update_starfield_buffer(game) self.update_starfield_buffer(game)
} }
pub fn update(&mut self) {}
/// Make a SpriteInstance for each of the game's visible sprites. /// Make a SpriteInstance for each of the game's visible sprites.
/// Will panic if SPRITE_INSTANCE_LIMIT is exceeded. /// Will panic if SPRITE_INSTANCE_LIMIT is exceeded.
/// ///

View File

@ -84,7 +84,7 @@ fn vertex_main(
fn fragment_main(in: VertexOutput) -> @location(0) vec4<f32> { fn fragment_main(in: VertexOutput) -> @location(0) vec4<f32> {
return textureSampleLevel( return textureSampleLevel(
texture_array[in.index], texture_array[in.index],
sampler_array[0], sampler_array[in.index],
in.texture_coords, in.texture_coords,
0.0 0.0
).rgba; ).rgba;

View File

@ -135,7 +135,7 @@ fn fragment_main(in: VertexOutput) -> @location(0) vec4<f32> {
return textureSampleLevel( return textureSampleLevel(
texture_array[global.starfield_texture.x], texture_array[global.starfield_texture.x],
sampler_array[0], sampler_array[global.starfield_texture.x],
in.texture_coords, in.texture_coords,
0.0 0.0
).rgba * vec4<f32>( ).rgba * vec4<f32>(

View File

@ -63,7 +63,7 @@ impl TextureArray {
binding: 1, binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT, visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering), ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
count: NonZeroU32::new(1), count: NonZeroU32::new(loader.texture_data.len() as u32),
}, },
], ],
}); });
@ -80,7 +80,7 @@ impl TextureArray {
}, },
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 1, binding: 1,
resource: wgpu::BindingResource::SamplerArray(&[&sampler]), resource: wgpu::BindingResource::SamplerArray(&[&sampler].repeat(views.len())),
}, },
], ],
}); });