survivor

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

commit
84670de341ef6ef4a4a334569f1a320669798a10
parent
313b7cf0bdd6c774126d3e284b4d74ba6f42f260
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-02-18 21:37
perf: skip some loops when painting sprites on the right/bottom edge

Diffstat

M src/main.rs 10 ++++++++--

1 files changed, 8 insertions, 2 deletions


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

@@ -46,14 +46,20 @@ fn sprite(screen: &mut term::Screen, cx: f32, cy: f32, sprite: &sprites::Sprite,
   46    46 
   47    47     for dy in 0..sprites::HEIGHT {
   48    48         let y = y0 + dy as i64;
   49    -1         if y < 0 || y >= screen.height as i64 {
   -1    49         if y < 0 {
   50    50             continue;
   51    51         }
   -1    52         if y >= screen.height as i64 {
   -1    53             break;
   -1    54         }
   52    55         for dx in 0..sprites::WIDTH {
   53    56             let x = x0 + dx as i64;
   54    -1             if x < 0 || x >= screen.width as i64 {
   -1    57             if x < 0 {
   55    58                 continue;
   56    59             }
   -1    60             if x >= screen.width as i64 {
   -1    61                 break;
   -1    62             }
   57    63             let cx = if invert { sprites::WIDTH - dx - 1 } else { dx };
   58    64             let c = sprite[dy][cx];
   59    65             if c != sprite[0][0] {