sevenx_engine 0.2.11

Engine de jogos 2D/3D completa com suporte Android, física, áudio, partículas, tilemap, UI, eventos e sistema 3D avançado com PBR.
Documentation
// SevenX Engine - Android Simple Demo (sem winit)
// Exemplo básico que funciona 100% no Android

#[cfg(target_os = "android")]
use android_activity::{
    AndroidApp, InputStatus, MainEvent, PollEvent,
};

#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app: AndroidApp) {
    use std::time::{Duration, Instant};
    
    println!("🤖 SevenX Android Simple - Iniciando!");
    
    let mut score = 0;
    let mut touches = Vec::new();
    let mut last_update = Instant::now();
    
    loop {
        app.poll_events(Some(Duration::from_millis(16)), |event| {
            match event {
                PollEvent::Wake => {
                    println!("Wake event");
                }
                PollEvent::Timeout => {
                    // Update game
                    let now = Instant::now();
                    let dt = now.duration_since(last_update).as_secs_f32();
                    last_update = now;
                    
                    // Simples update
                    if !touches.is_empty() {
                        score += 1;
                        println!("Score: {} | Touches: {}", score, touches.len());
                    }
                }
                PollEvent::Main(main_event) => {
                    match main_event {
                        MainEvent::InitWindow { .. } => {
                            println!("✅ Window initialized!");
                        }
                        MainEvent::TerminateWindow { .. } => {
                            println!("❌ Window terminated");
                        }
                        MainEvent::WindowResized { .. } => {
                            println!("📐 Window resized");
                        }
                        MainEvent::RedrawNeeded { .. } => {
                            // Render
                            println!("🎨 Redraw - Score: {}", score);
                        }
                        MainEvent::InputAvailable { .. } => {
                            // Process input
                            touches.clear();
                            
                            if let Ok(mut iter) = app.input_events_iter() {
                                loop {
                                    let read_input = iter.next(|event| {
                                        if let Some(motion_event) = event.motion_event() {
                                            let pointer_count = motion_event.pointer_count();
                                            println!("👆 Touch: {} pointers", pointer_count);
                                            
                                            for i in 0..pointer_count {
                                                let pointer = motion_event.pointer_at_index(i);
                                                let x = pointer.x();
                                                let y = pointer.y();
                                                touches.push((x, y));
                                                println!("  Pointer {}: ({:.0}, {:.0})", i, x, y);
                                            }
                                            
                                            InputStatus::Handled
                                        } else {
                                            InputStatus::Unhandled
                                        }
                                    });
                                    
                                    if !read_input {
                                        break;
                                    }
                                }
                            }
                        }
                        MainEvent::ContentRectChanged { .. } => {
                            println!("📏 Content rect changed");
                        }
                        MainEvent::GainedFocus => {
                            println!("🎯 Gained focus");
                        }
                        MainEvent::LostFocus => {
                            println!("😴 Lost focus");
                        }
                        MainEvent::ConfigChanged { .. } => {
                            println!("⚙️  Config changed");
                        }
                        MainEvent::LowMemory => {
                            println!("⚠️  Low memory!");
                        }
                        MainEvent::Start => {
                            println!("▶️  Start");
                        }
                        MainEvent::Resume { .. } => {
                            println!("▶️  Resume");
                        }
                        MainEvent::SaveState { .. } => {
                            println!("💾 Save state");
                        }
                        MainEvent::Pause => {
                            println!("⏸️  Pause");
                        }
                        MainEvent::Stop => {
                            println!("⏹️  Stop");
                        }
                        MainEvent::Destroy => {
                            println!("💥 Destroy");
                            return;
                        }
                        MainEvent::InsetsChanged { .. } => {
                            println!("📐 Insets changed");
                        }
                        _ => {}
                    }
                }
                _ => {}
            }
        });
    }
}

#[cfg(not(target_os = "android"))]
fn main() {
    println!("❌ Este exemplo só funciona no Android!");
    println!("Execute: cargo apk run --example android_simple");
}