INNER CODE UNIT · Rust

alpha_at

OpenGMK/OpenGMK · gm8decompiler/src/collision.rs:41

    fn alpha_at(frame: &Frame, x: u32, y: u32) -> Option<u8> {
        frame.data.get(((y * frame.width + x) * 4 + 3) as usize).copied()
    }

    // The various bits of data we want to collect:
    let mut all_have_collision = true;
    let mut lowest_alpha_with_col = 255u8;
    let mut highest_alpha_no_col = 0u8;

    // Iterate through each pixel in the collision rectangle
    for y in top..=bottom {
        for x in left..=right {
            // Check if there are any pixels with no collision
            for map in maps {
                all_have_collision &= map.data.get((y * map.width + x) as usize)?;
            }

            // Check relationships between collision and pixel alpha

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…