rust/lib-hedgewars-engine/src/lib.rs
changeset 14734 cc6ab1e3f7d5
parent 14728 5237b4c44d11
child 14875 aed75d439027
equal deleted inserted replaced
14733:57293f34ce59 14734:cc6ab1e3f7d5
     7     ffi::CString,
     7     ffi::CString,
     8     io::{Read, Write},
     8     io::{Read, Write},
     9     mem::replace,
     9     mem::replace,
    10     os::raw::{c_char, c_void},
    10     os::raw::{c_char, c_void},
    11 };
    11 };
       
    12 
       
    13 use integral_geometry::Point;
    12 
    14 
    13 use self::instance::EngineInstance;
    15 use self::instance::EngineInstance;
    14 
    16 
    15 #[repr(C)]
    17 #[repr(C)]
    16 #[derive(Copy, Clone)]
    18 #[derive(Copy, Clone)]
    99 #[no_mangle]
   101 #[no_mangle]
   100 pub extern "C" fn advance_simulation(engine_state: &mut EngineInstance, ticks: u32) -> bool {
   102 pub extern "C" fn advance_simulation(engine_state: &mut EngineInstance, ticks: u32) -> bool {
   101     engine_state.world.step();
   103     engine_state.world.step();
   102     true
   104     true
   103 }
   105 }
       
   106 
       
   107 #[no_mangle]
       
   108 pub extern "C" fn move_camera(engine_state: &mut EngineInstance, delta_x: i32, delta_y: i32) {
       
   109     engine_state
       
   110         .world
       
   111         .move_camera(Point::new(delta_x, delta_y), 0.0);
       
   112 }
       
   113 
   104 #[no_mangle]
   114 #[no_mangle]
   105 pub extern "C" fn cleanup(engine_state: *mut EngineInstance) {
   115 pub extern "C" fn cleanup(engine_state: *mut EngineInstance) {
   106     unsafe {
   116     unsafe {
   107         Box::from_raw(engine_state);
   117         Box::from_raw(engine_state);
   108     }
   118     }