use sunshine::player::Player;
use sunshine::framebuffer::{Framebuffer, RGB};
use sunshine::map::Map;
use sunshine::renderer::render;
use sunshine::sprite::{Sprite, Sprites};
use sunshine::texture::Texture;

const PI: f64 = std::f64::consts::PI;

fn main() {
    let win_w: usize = 1024;
    let win_h: usize = 512;

    let mut framebuffer: Framebuffer = Framebuffer::new(win_h, win_w);

    let map_string = "0000222222220000\
                      1              0\
                      1      11111   0\
                      1     0        0\
                      0     0  1110000\
                      0     3        0\
                      0   10000      0\
                      0   3   11100  0\
                      5   4   0      0\
                      5   4   1  00000\
                      0       1      0\
                      2       1      0\
                      0       0      0\
                      0 0000000      0\
                      0              0\
                      0002222222200000";
    let mut map: Map = Map::new(16, 16, map_string);

    let mut player: Player = Player{
        x: 3.456,
        y: 2.345,
        direction: 1.523,
        fov: PI / 3.,
    };

    let mut sprites: Sprites = vec![
        Sprite::new(3.523, 3.812, 2),
        Sprite::new(1.843, 8.765, 0),
        Sprite::new(5.323, 5.365, 1),
        Sprite::new(4.123, 10.265, 1),
    ];

    let wall_textures: Texture = Texture::new("./examples/walltex.png");
    let mon_textures: Texture = Texture::new("./examples/montex.png");

    render(&mut framebuffer, &mut map, &mut player, &mut sprites, &mon_textures, &wall_textures);
    framebuffer.write_file("frame.ppm");
}