use bevy_ecs::{event::Events, world::World}; use components::{Camera, Part, Player, RecvPacket, SendPacket, Texture, Transform}; use nalgebra::{Rotation2, Rotation3, Scale2, Scale3, Translation2, Translation3, Vector3}; use networking::ws::Ws; use rendering::{assets::Assets, App}; use starkingdoms_common::packet::Packet; use tracing::info; use winit::event_loop::{ControlFlow, EventLoop}; #[cfg(target_arch = "wasm32")] #[path = "wasm/mod.rs"] pub mod platform; #[cfg(not(target_arch = "wasm32"))] #[path = "native/mod.rs"] pub mod platform; pub mod rendering; pub mod components; pub mod networking; // Hi, you've found the real main function! This is called AFTER platform-specific initialization code. pub fn start() { info!( "Hello, world! StarKingdoms.TK v{} says hello, running on {}", env!("CARGO_PKG_VERSION"), if cfg!(target_arch = "wasm32") { "wasm" } else { "native" } ); info!("Creating the ECS world..."); let mut world = World::new(); world.insert_resource(Camera { x: 0.0, y: 0.0, zoom: 1.0, width: 0, height: 0, }); world.insert_resource(Assets::new()); world.insert_resource(Ws::new()); let mut send_packet_events = Events::::default(); let recv_packet_events = Events::::default(); world.spawn((Transform { translation: Translation3::new(0.0, 0.0, 0.0), rotation: Rotation2::new(0.0), scale: Scale3::new(25.0, 25.0, 1.0), }, Texture { name: "hearty.svg".to_string() }, Player, Part)); let event_loop = EventLoop::new().unwrap(); event_loop.set_control_flow(ControlFlow::Wait); event_loop.run_app(&mut App::new(world, send_packet_events, recv_packet_events)).unwrap(); }