use std::ffi::CString;
use lexsdl::*;
use lexlib::*;
use sdl2_sys::*;
fn main(){
unsafe{
LEXSDL_Init(0);
let window_title = CString::new("LEXSDL Rust Example - Particles").unwrap();
LEXSDL_CreateWindow(window_title.as_ptr(),0);
LEXSDL_CreateRenderer(0);
let mut particle = Particle::new(Vec2::new(250,250), 5000, 90.);
SDL_RenderSetLogicalSize(LEXSDL_GetRenderer(), 500,500);
LEXSDL_SetDrawColor(0x36,0x36,0x36,0xff);
while LEXSDL_EventQuit() == 0 {
LEXSDL_HandleEvents();
if LEXSDL_EventKey(87) == 1 { particle.direction += 1. }
if LEXSDL_EventKey(86) == 1 { particle.direction -= 1. }
if LEXSDL_EventKey(29) == 1 { particle.spread -= 1. }
if LEXSDL_EventKey(27) == 1 { particle.spread += 1. }
print!("\x1B[2J\x1B[1;1H");
println!("direction: {}", particle.direction);
println!("spread: {}", particle.spread);
LEXSDL_NewFrame();
LEXSDL_SetDrawColor(0x10,0x10,0x10,0xff);
SDL_RenderFillRect(LEXSDL_GetRenderer(),std::ptr::null());
LEXSDL_SetDrawColor(0xff,0xff,0xff,0xff);
particle.render();
LEXSDL_SetDrawColor(0xff,0x00,0x00,0xff);
SDL_RenderDrawPoint(LEXSDLDATA.renderer, 250,250);
LEXSDL_ShowFrame();
}
LEXSDL_Terminate();
LEXSDL_Quit();
}
}