From e29bb3e75a8de2a56202289597b40697a2094571 Mon Sep 17 00:00:00 2001 From: Theis Pieter Hollebeek Date: Wed, 10 Apr 2024 08:31:58 +0200 Subject: [PATCH] reduce size by 4x --- src/engine.rs | 7 +------ src/main.rs | 10 +++++----- textures/player.png | Bin 1189 -> 2306 bytes 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/engine.rs b/src/engine.rs index 358b490..97b554e 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -184,12 +184,7 @@ impl<'context, 'game> Context<'context, 'game> { self.canvas.copy( texture, None, - Rect::new( - x * 4, - y * 4, - texture.query().width * 4, - texture.query().height * 4, - ), + Rect::new(x, y, texture.query().width, texture.query().height), )?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index ffd24a9..902b05a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ impl System for GravitySystem { fn on_update(&self, ctx: &mut engine::Context, delta: f64) -> Result<(), engine::Error> { for id in engine::Quwi::<(Gravity, Velocity)>::new().run(&ctx) { let Velocity(_, y) = ctx.entity_component::(id); - *y = if *y < 200.0 { *y + 100.0 * delta } else { *y }; + *y = if *y < 800.0 { *y + 400.0 * delta } else { *y }; } Ok(()) } @@ -70,9 +70,9 @@ impl System for PlayerMovementSystem { let a_down = ctx.key_pressed(engine::Keycode::A); let Velocity(x, _) = ctx.entity_component::(id); *x = if d_down && !a_down { - 100.0 + 400.0 } else if !d_down && a_down { - -100.0 + -400.0 } else { 0.0 }; @@ -92,8 +92,8 @@ fn main() { let sprite = context.load_sprite("textures/player.png").unwrap(); context.spawn(vec![ Box::new(Sprite { sprite }), - Box::new(Position(16.0, 140.0)), - Box::new(Velocity(0.0, -150.0)), + Box::new(Position(16.0, 500.0)), + Box::new(Velocity(0.0, -600.0)), Box::new(Gravity), Box::new(PlayerMovement), ]); diff --git a/textures/player.png b/textures/player.png index 881d686c0b6072a2f5c114b389103c7e79883c2c..55371d1287751cfde8cf9a9373342cdeb9b7145f 100644 GIT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