reduce size by 4x
This commit is contained in:
parent
631a9fa407
commit
e29bb3e75a
@ -184,12 +184,7 @@ impl<'context, 'game> Context<'context, 'game> {
|
|||||||
self.canvas.copy(
|
self.canvas.copy(
|
||||||
texture,
|
texture,
|
||||||
None,
|
None,
|
||||||
Rect::new(
|
Rect::new(x, y, texture.query().width, texture.query().height),
|
||||||
x * 4,
|
|
||||||
y * 4,
|
|
||||||
texture.query().width * 4,
|
|
||||||
texture.query().height * 4,
|
|
||||||
),
|
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
10
src/main.rs
10
src/main.rs
@ -40,7 +40,7 @@ impl System for GravitySystem {
|
|||||||
fn on_update(&self, ctx: &mut engine::Context, delta: f64) -> Result<(), engine::Error> {
|
fn on_update(&self, ctx: &mut engine::Context, delta: f64) -> Result<(), engine::Error> {
|
||||||
for id in engine::Quwi::<(Gravity, Velocity)>::new().run(&ctx) {
|
for id in engine::Quwi::<(Gravity, Velocity)>::new().run(&ctx) {
|
||||||
let Velocity(_, y) = ctx.entity_component::<Velocity>(id);
|
let Velocity(_, y) = ctx.entity_component::<Velocity>(id);
|
||||||
*y = if *y < 200.0 { *y + 100.0 * delta } else { *y };
|
*y = if *y < 800.0 { *y + 400.0 * delta } else { *y };
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ impl System for PlayerMovementSystem {
|
|||||||
let a_down = ctx.key_pressed(engine::Keycode::A);
|
let a_down = ctx.key_pressed(engine::Keycode::A);
|
||||||
let Velocity(x, _) = ctx.entity_component::<Velocity>(id);
|
let Velocity(x, _) = ctx.entity_component::<Velocity>(id);
|
||||||
*x = if d_down && !a_down {
|
*x = if d_down && !a_down {
|
||||||
100.0
|
400.0
|
||||||
} else if !d_down && a_down {
|
} else if !d_down && a_down {
|
||||||
-100.0
|
-400.0
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
@ -92,8 +92,8 @@ fn main() {
|
|||||||
let sprite = context.load_sprite("textures/player.png").unwrap();
|
let sprite = context.load_sprite("textures/player.png").unwrap();
|
||||||
context.spawn(vec![
|
context.spawn(vec![
|
||||||
Box::new(Sprite { sprite }),
|
Box::new(Sprite { sprite }),
|
||||||
Box::new(Position(16.0, 140.0)),
|
Box::new(Position(16.0, 500.0)),
|
||||||
Box::new(Velocity(0.0, -150.0)),
|
Box::new(Velocity(0.0, -600.0)),
|
||||||
Box::new(Gravity),
|
Box::new(Gravity),
|
||||||
Box::new(PlayerMovement),
|
Box::new(PlayerMovement),
|
||||||
]);
|
]);
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in New Issue
Block a user