use raylib::prelude::*; use raylib::consts::KeyboardKey; use peachy::Colour; // todo state fn main() { // todo load game let game = peachy::mock::game::bitsy(); let (mut rl, thread) = raylib::init() .size((game.config.width * 4) as i32, (game.config.height * 4) as i32) .title("peachy") .build(); rl.set_target_fps(30); // appropriate? let key_up: KeyboardKey = raylib::core::input::key_from_i32(87).unwrap(); let key_left: KeyboardKey = raylib::core::input::key_from_i32(65).unwrap(); let key_down: KeyboardKey = raylib::core::input::key_from_i32(83).unwrap(); let key_right: KeyboardKey = raylib::core::input::key_from_i32(68).unwrap(); const SIZE: i32 = 32; let mut x = SIZE; let mut y = SIZE; let palette = game.palettes.get(0).unwrap(); let avatars = game.get_entities_by_tag(&"avatar".to_string()); let avatar = avatars.get(0).unwrap(); let image = game.get_image_by_name(&avatar.image).unwrap().clone().into_image(palette); // todo how do I create a texture without a file? let mut texture = rl.load_texture( &thread, "src/test-resources/images/avatar.png" ).unwrap(); texture.update_texture(image.as_bytes()); // let font = rl.load_font(&thread, "src/FuturaStd-Light.otf").unwrap(); let mut audio = audio::RaylibAudio::init_audio_device(); let mut music = raylib::audio::Music::load_music_stream( &thread, "src/test-resources/music/another-night.xm" ).unwrap(); audio.play_music_stream(&mut music); println!("{}", rl.window_should_close()); while !rl.window_should_close() { if rl.is_key_pressed(key_up) { y -= SIZE; } else if rl.is_key_pressed(key_left) { x -= SIZE; } else if rl.is_key_pressed(key_down) { y += SIZE; } else if rl.is_key_pressed(key_right) { x += SIZE; } audio.update_music_stream(&mut music); let mut d = rl.begin_drawing(&thread); // d.clear_background(palette.get_colour_raylib(&0)); d.clear_background(Color::WHITE); d.draw_texture_ex( &texture, raylib::core::math::Vector2 { x: x as f32, y: y as f32 }, 0.0, 4.0, Color::WHITE ); // d.draw_text_ex( // &font, // "hello", // raylib::core::math::Vector2 { x: 64.0, y: 64.0 }, // 32.0, // 4.0, // Color::WHITE // ); } }