// Run with: aspl run docs/examples/raylib/window-input.mixed.aspl // Type text, click or scroll to change color. Resize to print new dimensions. // Escape requests close. The demo also stops after 180 frames. import core::raylib; fn start_main() -> i64 { let flags = raylib::SetConfigFlags(raylib::FLAG_WINDOW_RESIZABLE); let pacing = raylib::SetTargetFPS(60); if not flags::ok or not pacing::ok { return 1; } let opened = raylib::InitWindow(640, 360, "ASPL input / إدخال رايليب"); if not opened::ok { print(opened::error::message); return 2; } let exit_key = raylib::SetExitKey(raylib::KEY_ESCAPE); if not exit_key::ok { print(exit_key::error::message); return 3; } var frame: i64 = 0; var color = raylib::SKYBLUE; while frame < 180 { let closing = raylib::WindowShouldClose(); if not closing::ok { print(closing::error::message); return 4; } if closing::value { return 0; } let clicked = raylib::IsMouseButtonPressed(raylib::MOUSE_BUTTON_LEFT); let pressed = raylib::IsKeyPressed(raylib::KEY_SPACE); let wheel = raylib::GetMouseWheelMove(); if not clicked::ok or not pressed::ok or not wheel::ok { return 5; } if clicked::value or pressed::value or wheel::value not matches 0.0 { color = raylib::MAROON; } let typed = raylib::GetCharPressed(); let key = raylib::GetKeyPressed(); if not typed::ok or not key::ok { return 6; } if typed::value not matches 0 { color = raylib::DARKGREEN; print("Unicode / محرف: "); print(format_i64(i64(typed::value))); print("\n"); } let resized = raylib::IsWindowResized(); if not resized::ok { return 7; } if resized::value or frame matches 0 { let width = raylib::GetScreenWidth(); let height = raylib::GetScreenHeight(); let render_width = raylib::GetRenderWidth(); let render_height = raylib::GetRenderHeight(); if not width::ok or not height::ok or not render_width::ok or not render_height::ok { return 8; } print("Screen / شاشة: "); print(format_i64(i64(width::value))); print("x"); print(format_i64(i64(height::value))); print(" render="); print(format_i64(i64(render_width::value))); print("x"); print(format_i64(i64(render_height::value))); print("\n"); } let begun = raylib::BeginDrawing(); if not begun::ok { print(begun::error::message); return 9; } // Sampled observations also work in an open drawing frame. let position = raylib::GetMousePosition(); let delta = raylib::GetMouseDelta(); if not position::ok or not delta::ok { return 10; } let cleared = raylib::ClearBackground(color); if not cleared::ok { print(cleared::error::message); return 11; } let ended = raylib::EndDrawing(); if not ended::ok { print(ended::error::message); return 12; } frame = frame + 1; } let closed = raylib::CloseWindow(); if not closed::ok { print(closed::error::message); return 13; } return 0; }