survivor

graphical action game for the linux terminal
git clone https://git.ce9e.org/survivor.git

commit
27a37b70e7b8bc6c0d53e3b8d1b114f6c328252c
parent
15200d55a6ca585c740d17a0cfb6441818afc303
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-03-28 06:16
chore: rustfmt

Diffstat

M src/game.rs 15 ++++++++++++---
M src/term.rs 6 +++++-
M src/weapons.rs 8 ++++++--
M src/win.rs 4 ++--

4 files changed, 25 insertions, 8 deletions


diff --git a/src/game.rs b/src/game.rs

@@ -134,7 +134,7 @@ impl Game {
  134   134             Some(Dir::Right) => self.player.p.x += self.player.speed * dt,
  135   135             Some(Dir::Down) => self.player.p.y += self.player.speed * dt,
  136   136             Some(Dir::Left) => self.player.p.x -= self.player.speed * dt,
  137    -1             None => {},
   -1   137             None => {}
  138   138         };
  139   139     }
  140   140 
@@ -332,7 +332,12 @@ impl Game {
  332   332         );
  333   333 
  334   334         for diamond in self.diamonds.iter() {
  335    -1             win.sprite(diamond.x + dx, diamond.y + dy, &sprites::DIAMOND, Dir::Right);
   -1   335             win.sprite(
   -1   336                 diamond.x + dx,
   -1   337                 diamond.y + dy,
   -1   338                 &sprites::DIAMOND,
   -1   339                 Dir::Right,
   -1   340             );
  336   341         }
  337   342 
  338   343         let mut player_rendered = false;
@@ -352,7 +357,11 @@ impl Game {
  352   357                 enemy.p.x + dx,
  353   358                 enemy.p.y + dy,
  354   359                 enemy.t.sprite,
  355    -1                 if enemy.p.x > self.player.p.x { Dir::Left } else { Dir::Right },
   -1   360                 if enemy.p.x > self.player.p.x {
   -1   361                     Dir::Left
   -1   362                 } else {
   -1   363                     Dir::Right
   -1   364                 },
  356   365             );
  357   366         }
  358   367         if !player_rendered {

diff --git a/src/term.rs b/src/term.rs

@@ -101,7 +101,11 @@ impl Drop for Screen {
  101   101 
  102   102 impl Screen {
  103   103     pub fn new() -> Self {
  104    -1         let mut screen = Self { width: 0, height: 0, pixels: vec![] };
   -1   104         let mut screen = Self {
   -1   105             width: 0,
   -1   106             height: 0,
   -1   107             pixels: vec![],
   -1   108         };
  105   109         screen.resize();
  106   110         ti::civis();
  107   111         ti::ed();

diff --git a/src/weapons.rs b/src/weapons.rs

@@ -36,7 +36,7 @@ impl Weapon {
   36    36             last: 0.0,
   37    37             t: t,
   38    38             projectiles: vec![],
   39    -1         }
   -1    39         };
   40    40     }
   41    41 }
   42    42 
@@ -86,7 +86,11 @@ pub fn move_spiral(projectile: &mut Projectile, center: &Pos, speed: f32, dt: f3
   86    86     projectile.p.x = center.x + cos * r2;
   87    87     projectile.p.y = center.y + sin * r2;
   88    88 
   89    -1     projectile.dir = if projectile.p.y > center.y { Dir::Left } else { Dir::Right };
   -1    89     projectile.dir = if projectile.p.y > center.y {
   -1    90         Dir::Left
   -1    91     } else {
   -1    92         Dir::Right
   -1    93     };
   90    94 }
   91    95 
   92    96 pub const AXE: WeaponType = WeaponType {

diff --git a/src/win.rs b/src/win.rs

@@ -1,6 +1,6 @@
   -1     1 use crate::game::Dir;
    1     2 use crate::sprites;
    2     3 use crate::term::Screen;
    3    -1 use crate::game::Dir;
    4     4 
    5     5 const ASPECT_RATIO: f32 = 1.4;
    6     6 
@@ -90,7 +90,7 @@ impl Window<'_> {
   90    90                 if x >= self.width as i64 {
   91    91                     break;
   92    92                 }
   93    -1                 let cy = if invert {sprites::WIDTH - dy - 1 } else { dy };
   -1    93                 let cy = if invert { sprites::WIDTH - dy - 1 } else { dy };
   94    94                 let c = sprite[dx][cy];
   95    95                 if c != sprite[0][0] {
   96    96                     self.set(x as usize, y as usize, c);