pub fn draw(&mut self, x: i16, y: i16, buf: &[u8]) -> bool {
        let mut overlap = false;

        let (x, y) = (x as i32, y as i32);
        let (w, h) = (self.spritew as i32, self.spriteh as i32);

        for j in max(0, y)..min(240, y + h) {
            for i in (max(-1, x)..min(320, x + w * 2)).filter(|z| (z - x) % 2 == 0) {
                let a = if !self.hflip { (i - x) / 2 } else { w - (i - x) / 2 - 1 } as usize;
                let b = if !self.vflip { j - y } else { h - (j - y) - 1 } as usize;
                let (mut high, mut low) = half_bytes(buf[a + b * w as usize]);
                if self.hflip { swap(&mut high, &mut low) };
                let p = i + j * 320;
                if i >= 0 && high != 0 {
                    let p = p as usize;
                    if self.fg[p] != 0 {
                        overlap = true;
                    }
                    self.fg[p] = high;
                }
                if i < 319 && low != 0 {
                    let p = (p + 1) as usize;
                    if self.fg[p] != 0 {
                        overlap = true;
                    }
                    self.fg[p] = low;
                }
            }
        }

        overlap
    }
/// Draw a sprite to the foreground
Draw a sprite to the foreground
Draw a sprite to the foreground
pub fn draw(&mut self, x: i16, y: i16, buf: &[u8]) -> bool {
        let mut overlap = false;
        let (x, y) = (x as i32, y as i32);
        let (w, h) = (self.spritew as i32, self.spriteh as i32);
        for j in max(0, y)..min(240, y + h) {
            for i in (max(-1, x)..min(320, x + w * 2)).filter(|z| (z - x) % 2 == 0) {
                let a = if !self.hflip { (i - x) / 2 } else { w - (i - x) / 2 - 1 } as usize;
                let b = if !self.vflip { j - y } else { h - (j - y) - 1 } as usize;
                let (mut high, mut low) = half_bytes(buf[a + b * w as usize]);
                if self.hflip { swap(&mut high, &mut low) };
                let p = i + j * 320;
                if i >= 0 && high != 0 {
                    let p = p as usize;
                    if self.fg[p] != 0 {
                        overlap = true;
                    }
                    self.fg[p] = high;
                }
                if i < 319 && low != 0 {
                    let p = (p + 1) as usize;
                    if self.fg[p] != 0 {
                        overlap = true;
                    }
                    self.fg[p] = low;
                }
            }
        }
        overlap
    }
pub fn draw ( & mut self , x : i16 , y : i16 , buf : & [ u8 ] ) -> bool { let mut overlap = false ; let ( x , y ) = ( x as i32 , y as i32 ) ; let ( w , h ) = ( self . spritew as i32 , self . spriteh as i32 ) ; for j in max ( 0 , y ) .. min ( 240 , y + h ) { for i in ( max ( - 1 , x ) .. min ( 320 , x + w * 2 ) ) . filter ( | z | ( z - x ) % 2 == 0 ) { let a = if ! self . hflip { ( i - x ) / 2 } else { w - ( i - x ) / 2 - 1 } as usize ; let b = if ! self . vflip { j - y } else { h - ( j - y ) - 1 } as usize ; let ( mut high , mut low ) = half_bytes ( buf [ a + b * w as usize ] ) ; if self . hflip { swap ( & mut high , & mut low ) } ; let p = i + j * 320 ; if i >= 0 && high != 0 { let p = p as usize ; if self . fg [ p ] != 0 { overlap = true ; } self . fg [ p ] = high ; } if i < 319 && low != 0 { let p = ( p + 1 ) as usize ; if self . fg [ p ] != 0 { overlap = true ; } self . fg [ p ] = low ; } } } overlap }
Draw a sprite to the foreground
Draw a sprite to the foreground
&mut self
x
i16
y
i16
buf
&[u8]
&mut self
x
i16
y
i16
buf
&[u8]